Extract objects to new drawing

Extract objects to new drawing

Anonymous
Not applicable
2,039 Views
6 Replies
Message 1 of 7

Extract objects to new drawing

Anonymous
Not applicable

Hi everyone,

 

Is it possible with a LISP to do this:

  1. Select objects (polylines, circles,etc.)
  2. Extract them in a new drawing
  3. Show the 'Save as' window

I have a drawing with a lot of objects, and I need to export them in new drawings (1 object by drawing) for CNC Laser cutting.

 

I'm on AutoCAD 2019.

 

Regards,

0 Likes
Accepted solutions (1)
2,040 Views
6 Replies
Replies (6)
Message 2 of 7

Moshe-A
Mentor
Mentor
Accepted solution

@Anonymous  hi,

 

check this:

 

Note: the WBLOCK command erases the selected objects from the current drawing. if you do not want that, use OPPS or U command.

 

enjoy

moshe

 

 

; save to dwg
(defun c:s2d (/ ss)
 (if (setq ss (ssget))
  (command "._wblock" "~" "" "0,0" "_si" ss)
 )
 (princ) 
)

 

Message 3 of 7

Anonymous
Not applicable

Hi @Moshe-A,

 

great job. It works perfectly.

 

I use different drawing templates for different customers. Would it be possible to select a drawing template after selecting the objects, before the objects are saved in the new file?

 

Many thanks

0 Likes
Message 4 of 7

Anonymous
Not applicable

Thank you so much @Moshe-A !

 

This is exactly what I was looking for.

 

Take care of you

 

0 Likes
Message 5 of 7

Moshe-A
Mentor
Mentor

@Anonymous  hi,

 

AutoCAD lets you create a new drawing base on dwf or dwg file so any dwg can serve as dwt and vise versa so after a wblock change it to a dwt?!

 

Moshe

 

0 Likes
Message 6 of 7

Anonymous
Not applicable

Hi @Moshe-A ,

 

yes, I know that well. Only my templates contain many settings and objects that you will use later. Therefore I would first have to create blank drawings from the templates and then export the objects to them. I thought it was the other way round, but it works that way too. Thank you very much.

0 Likes
Message 7 of 7

Sea-Haven
Mentor
Mentor

Use wblock as before you know file name, then you can open a blank dwt and insert the "newblock" dwg explode it once so it becomes objects again can purge the dummy insert "newblock".

 

Using VL it is possible to open and jump around in dwgs but can be complicated.

 

I would make the lisp write a script for the wblock, open, insert and purge. You would give the new name of the dwg to be saved, possibly closing so can make more. Yes will need to type command again etc. or else write a big script for multi dwgs.

 

So for multi newblockX can use findfile to check if exists so overwrite is ticked as well.

 

Any reason not using copyclip and paste no real code needed.

 

 

0 Likes