Author Topic: Insert dynamic block with attributes - from custom menu  (Read 1484 times)

0 Members and 1 Guest are viewing this topic.

like_citrus

  • Newt
  • Posts: 114
Insert dynamic block with attributes - from custom menu
« on: February 21, 2021, 12:02:39 AM »
This will insert a dynamic block with attributes, from a custom menu.

1. Create a folder which contains the dynamic blocks, and the MNU file mentioned below.
2. Load the MNU file using CUILOAD from the command menu. AutoCAD automatically creates a CUIX file.
3. In Tools, Options, Files tab, Support File Search Path ... add the folder mentioned above.
4. The LISP code for "BlockInsert" is shown below and can be set to autoload.

The issue is: I don't want to enter the attributes in the command line when inserting the block.
Is there a code which would ignore this and just insert only?



MNU FILE
Code: [Select]
***MENUGROUP=AID_DYNAMIC
***POP111
**CTOPopAID_DYNAMIC
            [Aid (D)]
            [<-View-Reference]^C^C(BlockInsert "Aid_View-Reference");scale;1;
            [--]

LISP FILE
Code: [Select]
(defun BlockInsert (blkname)
    (command "_.-insert" (substr (strcat blkname "-" (menucmd "m=$(edtime,0,yymoddhhmmss)") "=" blkname) (+ (vl-string-position (ascii "_") blkname 1) 2)) pause 1 "" 0)
)

Daniel J. Ellis

  • Swamp Rat
  • Posts: 811
Re: Insert dynamic block with attributes - from custom menu
« Reply #1 on: February 21, 2021, 04:24:38 AM »
I think the variable you're looking for is ATREQ - it controls whether autoCAD prompts for attribute values.

1 means is DOES require an entry
0 means it DOESN'T and just accepts the default value built into the attribute definition.

dJE
===
dJE

like_citrus

  • Newt
  • Posts: 114
Re: Insert dynamic block with attributes - from custom menu
« Reply #2 on: February 21, 2021, 08:51:09 AM »
That command is not available in my version of AutoCAD.
A web search of "ATREQ AutoCAD" doesn't bring up anything.

Edit: Sorry, You were right but it was spelled ATTREQ. Thanks for advising.
« Last Edit: February 21, 2021, 09:31:30 AM by like_citrus »

like_citrus

  • Newt
  • Posts: 114
Re: Insert dynamic block with attributes - from custom menu
« Reply #3 on: February 22, 2021, 02:21:54 AM »
There is another setting ATTDIA which when set to a value of 1, brings up a dialogue.
For some reason, AutoCAD crashes when one of my blocks is inserted from the pull down menu. But when the block is inserted using INSERT there are no issues.
What I wanted to try was to try and just specify the rotation, on the off-chance that it may solve the issue.
I tried the following but still get asked for rotation.

Code: [Select]
[<-View-Reference]^C^C(BlockInsert "Aid_View-Reference");scale;1;rotation;0;
Code: [Select]
[<-View-Reference]^C^C(BlockInsert "Aid_View-Reference");scale;1;rotate;0;

BIGAL

  • Swamp Rat
  • Posts: 1398
  • 40 + years of using Autocad
Re: Insert dynamic block with attributes - from custom menu
« Reply #4 on: February 24, 2021, 08:49:32 PM »
Try [<-View-Reference]^C^C(BlockInsert "Aid_View-Reference") you define the scale and rotation in blockInsert. Else go back to old -insert.
A man who never made a mistake never made anything

like_citrus

  • Newt
  • Posts: 114
Re: Insert dynamic block with attributes - from custom menu
« Reply #5 on: February 24, 2021, 09:33:38 PM »
If you look at the last part of the LISP code in BlockInsert:
pause 1 "" 0
This is my attempt to give it a scale of "1" and a rotation of "0".
When inserted using this, it doesn't ask for a scale (what is required) but it does ask for a rotation.

BIGAL

  • Swamp Rat
  • Posts: 1398
  • 40 + years of using Autocad
Re: Insert dynamic block with attributes - from custom menu
« Reply #6 on: February 25, 2021, 06:42:15 PM »
(command "_.-insert" .. blkname .. pause 1 "" 0)
   (command "_.-insert" .. blkname ..
select insertion point
x scale is 1
y scale is same as x ""
rotation is 0)

So your trying to do stuff again after insert no need creates error ! Remove ;scale;1;rotation;0; as I said. If you want scale add (getreal "\Enter X scale ")
A man who never made a mistake never made anything

like_citrus

  • Newt
  • Posts: 114
Re: Insert dynamic block with attributes - from custom menu
« Reply #7 on: February 25, 2021, 09:34:38 PM »
Great thanks for that, it did work.
By removing "scale;1;" from the MNU file.