Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Distinguished Contributor
vladimir.ninic
Posts: 160
Registered: ‎01-29-2007
Message 1 of 10 (1,419 Views)
Accepted Solution

export parts of drawing to another dwg....

1419 Views, 9 Replies
10-01-2012 01:14 PM

i've searche but didn't find answer...

 

i have one big pipeline drawing and need to "split" it into smaller drawings...

there are layers, v500, v250, v100 that represent size of pipeline.

i'd like to extract all elements from layer v500  to drawing v500.dwg, after that v250... etc.

problem is that i would select only elements from v500, erase all other and than save it as v500.dwg... and then what? undo all and repeat everything with another layer?

is there a way to copy elements to another drawing and save and then return to original drawing and execute another set of commands?

 

thnx!

Why not just use the WBLOCK command to send objects out to their own drawing while leaving you in the current drawing?

Distinguished Mentor
gasty1001
Posts: 582
Registered: ‎04-11-2010
Message 2 of 10 (1,413 Views)

Re: export parts of drawing to another dwg....

10-01-2012 02:14 PM in reply to: vladimir.ninic

Hi,

 

I'm not sure about your work flow, but there are several ways to copy entities from one dwg to another, Ctrl+C/Ctrl+V, wblock/insert, export using some intermediate format, etc . As for the layers issue and selection, you can use qselect to filter the entities, or make some layer filter in the  layer manager and activate it before selection, or use the filter command to make a selection set, also a lisp using ssget with a filter, etc.

 

Gaston Nunez

*Expert Elite*
pbejse
Posts: 2,529
Registered: ‎11-24-2009
Message 3 of 10 (1,397 Views)

Re: export parts of drawing to another dwg....

10-01-2012 08:05 PM in reply to: vladimir.ninic

vladimir.ninic wrote:..

 ...

is there a way to copy elements to another drawing and save and then return to original drawing and execute another set of commands?...

 

thnx!


(defun wblayer (lst path / aDoc)
  (vl-load-com)
  	(setq aDoc (vla-get-ActiveDocument (vlax-get-acad-object)))
		(foreach lyr lst
		  (if (ssget "_x" (list (cons 8 lyr)))
		    (progn
			  (vla-wblock aDoc
			   (strcat path lyr ".dwg")
			    (setq objts (vla-get-ActiveSelectionSet aDoc))
			  )
		  	(vla-delete objts)
		      )
		    )
		)
  (princ)
  )

 

USAGE

(wblayer '("v500" "v250" "v100") "C:\\Users\\path\\sample\\")

 

HTH

 

Contributor
mattok
Posts: 19
Registered: ‎07-29-2009
Message 4 of 10 (1,386 Views)

Re: export parts of drawing to another dwg....

10-01-2012 10:36 PM in reply to: vladimir.ninic

I'd probably just use the FILTER command and copy / paste to original coordinates into a new drawing

*Expert Elite*
M_Hensley
Posts: 1,731
Registered: ‎12-11-2003
Message 5 of 10 (1,373 Views)

Re: export parts of drawing to another dwg....

10-02-2012 04:05 AM in reply to: vladimir.ninic

Why not just use the WBLOCK command to send objects out to their own drawing while leaving you in the current drawing?

*Expert Elite*
pendean
Posts: 23,727
Registered: ‎11-06-2003
Message 6 of 10 (1,366 Views)

Re: export parts of drawing to another dwg....

10-02-2012 05:19 AM in reply to: vladimir.ninic

Select, ERASE, SAVEAS and UNDO and repeat? What are you using, AutoCAD version1? Forgive my surprise at your post, no offense meant or directed at you.

 

If the objects are on seaprate layers, why do you need to erase the other objects on all the other layers first? Do you not know you can make active the one layer and freeze all the others?

In addition to the comments about using WBLOCK command noted above.

 

While the code provided above is great and a quick method, you appear to be missing some key built-in AutoCAD features IMHO and might benefit from a good basic overview tutorial/lesson or a **** good book.

Dean Saadallah Blog | Facebook | Google+ | Twitter | PINS
Distinguished Contributor
vladimir.ninic
Posts: 160
Registered: ‎01-29-2007
Message 7 of 10 (1,361 Views)

Re: export parts of drawing to another dwg....

10-02-2012 05:38 AM in reply to: pendean

sorry for asking for advice. noone said that i know that much lisp... thnx for advice...

*Expert Elite*
pendean
Posts: 23,727
Registered: ‎11-06-2003
Message 8 of 10 (1,353 Views)

Re: export parts of drawing to another dwg....

10-02-2012 05:48 AM in reply to: vladimir.ninic

No, I was not questioning why you posted, I was asking why you did not try the correct built-in feautres of AutOCAD that require no lisp to do what you want.

 

You posted this, which is very much the wrong way to do what you want:

"problem is that i would select only elements from v500, erase all other and than save it as v500.dwg... and then what? undo all and repeat everything with another layer?"

 

And then you asked:

"is there a way to copy elements to another drawing and save and then return to original drawing and execute another set of commands?"

 

You don't need lisp to do things already avaiable in AutoCAD, Lisp is to speed the process up. LAYISO and WBLOCK in your file would have been all you needed to do inside AutoCAD, without lisp.

Dean Saadallah Blog | Facebook | Google+ | Twitter | PINS
Distinguished Contributor
vladimir.ninic
Posts: 160
Registered: ‎01-29-2007
Message 9 of 10 (1,341 Views)

Re: export parts of drawing to another dwg....

10-02-2012 09:06 AM in reply to: pendean

ok. let's stop. i've asked for advice, so i can understand concept so i can write my lisp file... next time i'll explain better...

 

thnx!

*Expert Elite*
pbejse
Posts: 2,529
Registered: ‎11-24-2009
Message 10 of 10 (1,323 Views)

Re: export parts of drawing to another dwg....

10-02-2012 06:45 PM in reply to: M_Hensley

For what its worth,I did use  Wblock :smileywink:

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.