TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: PM on August 14, 2021, 06:44:59 AM
-
Hi iam using two type of code to insert block .In the first method insert and explode the block and in the second code insert the block and stay as block
(command "insert" "*block1" dt1 scl1
"0") )
(COMMAND "_layer" "_m" "block2" "_c" "7" "" "") (command "insert" "block2" dt1 scl1 scl1
"0") )
I want to insert block from specific folder
I try to change the code to
(command "insert" "c:\\Myblock\\symbols\\*block1" dt1 scl1
"0") ;<----- not working )
(COMMAND "_layer" "_m" "block2" "_c" "7" "" "") (command "insert" "c:\\Myblock\\symbols\\block2" dt1 scl1 scl1
"0") ; <--- This works but i am not sure if it is the correct way to write it )
Thanks
-
The block has to have a physical name not a wildcard. Its looking for a block with * as 1st character.
-
The explode block in the first example works because its at the front. its just reinserting block1 from definition the * means to explode it after insert.
in the second example reason its not working its looking for "*block1" in the symbols folder not "block1"
(Defun c:block1 ()
(vl-cmdf "insert" "*c:\\Myblock\\symbols\\block1.dwg" pause "1000" "") ;need the full path the * goes at the front of that path. pause is so you can pick the insert point.
(setvar 'clayer "0") ;setvar with this command not in command line ;try to avoid using command line less errors in the long run.
(princ)
)
(Defun c:block2 ()
(if (tblsearch "Layer" "block2") ;checks for block2 & switches to it. if not makes it
(setvar 'clayer "CHECK")
(vl-cmdf "-Layer" "M" "block2" "C" "7" "" "")
)
(vl-cmdf "insert" "c:\\Myblock\\symbols\\block2" pasue "" "") ;defualts to 1 scale and 0 rotation
(vl-cmdf "setvar" "clayer" "0")
)
-
Thanks
-
You have should do the same for the blocks. if its already in the drawing either redefine, reinsert, or alert you that its already in the drawing.
(if (tblsearch "block" "block2") ;checks for block2
(vl-cmdf "_.Insert" "block2=*c:\\Myblock\\symbols\\block2.dwg" pause "" "") ;(vl-cmdf "_.Insert" "*block2" pause "" "") or (Alert "\nBlock2 is already defined in drawing")
(vl-cmdf "_.Insert" "*c:\\Myblock\\symbols\\block2.dwg" pause "" "")
(setvar 'clayer "0")
)
-
I want to ask a question. I use this code to insert an annotation attribiute block from path.
when i use this code the insert block is 4 time smaller !!!!!!!
(COMMAND "_layer" "_m" "_Ο.Τ" "_c" "61" "" "") (command "insert" "c:\\topocad\\MBLANNOT\\Symbols\\AnnotAROT1.dwg" dt1 scl1 scl1
"0") )
When i delete the .dwg from the code the block insert in corrent scale
(COMMAND "_layer" "_m" "_Ο.Τ" "_c" "61" "" "") (command "insert" "c:\\topocad\\MBLANNOT\\Symbols\\AnnotAROT1" dt1 scl1 scl1
"0") )
Can anyone tell me why ???
Thanks
-
I'm surprised you get past this: (COMMAND "_layer" "_m" "_Ο.Τ" "_c" "61" "" "")
-
This is my fault.I use greek and i don't translate it
(COMMAND "_layer" "_m" "_O.T;" "_c" "61" "" "")
-
Any other ideas?
Thanks
-
Are the drawing units the same between drawings? the path with the dwg it might pull all drawing information aswell.
without the dwg it might default all those settings to the drawing your inserting into and just pull in the geometry.
This is just a guess.
-
Any other ideas?
Thanks
Try setting INSUNITS to 0.
-
I check the units from my template and the units in the dwg and i find that the Iighting was not International. I change it . Then i change the path in the lisp to c:\\topocad\\MBLANNOT\\Symbols\\AnnotAROT1.dwg. And works fine.
Thanks