Hi,
With AutoCAD 2014, i often use a lisp like :
(mapcar '(lambda (x)
(progn
(Command "Insert" x)
(Command)
)
'("C:\\Temp\\Testblock.dwg" "C:\\Temp\\Testblock2.dwg" ...)
)
The block is loaded in the DWG but i don't want to insert this block immediatly. For example, just to redefine the block.
With AutoCAD 2015, this lisp create an error,i know it' s not possible to use Command or vl-cmdf with Mapcar.
But i can't use (command-s).
Is there a way to load blocks without inserting with Autolisp or Visual Lisp.
Thanks !
Solved! Go to Solution.
Solved by Lee_Mac. Go to Solution.
@pierre.lassard wrote:
....With AutoCAD 2014, i often use a lisp like :
(mapcar '(lambda (x)
(progn
(Command "Insert" x)
...
With AutoCAD 2015, this lisp create an error,i know it' s not possible to use Command or vl-cmdf with Mapcar.
....
Does it need to be via (mapcar)? Try it, for example, this way [I'm not where I have 2015 right now to test it]:
(foreach x '("C:\\Temp\\Testblock" "C:\\Temp\\Testblock2" ...)
(command "_.insert" x) (command)
)
[By the way, you don't need to include the .dwg filetype ending -- it won't recognize any other filetype to Insert.]
Hi,
You can insert a block using entmake/entmakex as this a pure autolisp function you can use it inside a mapcar.
Gaston Nunez
Try the following method:
(vl-load-com) (setq spc (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))) (mapcar '(lambda ( dwg ) (if (findfile dwg) (progn (vla-delete (vla-insertblock spc (vlax-3D-point 0 0) dwg 1.0 1.0 1.0 0.0)) dwg ) ) ) '("C:\\Temp\\Testblock.dwg" "C:\\Temp\\Testblock2.dwg") )
By supplying the ActiveX insertblock method with a full filepath, the block should be redefined if already present in the Block Collection of the active drawing. The above example will return a list of the filepaths of those blocks successfully defined/redefined.