TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: like_citrus 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
***MENUGROUP=AID_DYNAMIC
***POP111
**CTOPopAID_DYNAMIC
[Aid (D)]
[<-View-Reference]^C^C(BlockInsert "Aid_View-Reference");scale;1;
[--]
LISP FILE
(defun BlockInsert (blkname)
(command "_.-insert" (substr (strcat blkname "-" (menucmd "m=$(edtime,0,yymoddhhmmss)") "=" blkname) (+ (vl-string-position (ascii "_") blkname 1) 2)) pause 1 "" 0)
)
-
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
-
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.
-
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.
[<-View-Reference]^C^C(BlockInsert "Aid_View-Reference");scale;1;rotation;0;
[<-View-Reference]^C^C(BlockInsert "Aid_View-Reference");scale;1;rotate;0;
-
Try [<-View-Reference]^C^C(BlockInsert "Aid_View-Reference") you define the scale and rotation in blockInsert. Else go back to old -insert.
-
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.
-
(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 ")
-
Great thanks for that, it did work.
By removing "scale;1;" from the MNU file.