Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Abort insert with command-s

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
pierre.lassard
417 Views, 5 Replies

Abort insert with command-s

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 !

  

5 REPLIES 5
Message 2 of 6


@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.]

Kent Cooper, AIA
Message 3 of 6

I Know it's possible to use foreach or repeat.
But my lisp function is more complex and i want to Return list value, then i d prefer use mapcar.
Thanks
Message 4 of 6
hgasty1001
in reply to: pierre.lassard

Hi,

 

You can insert a block using entmake/entmakex as this a pure autolisp function you can use it inside a mapcar.

 

Gaston Nunez

Message 5 of 6
Lee_Mac
in reply to: pierre.lassard

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.

Message 6 of 6
pierre.lassard
in reply to: Lee_Mac

Of course.
This is the best Idea.
Insert block, and delete it.
Thanks

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost