• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Visual LISP, AutoLISP and General Customization

    Reply
    Distinguished Contributor
    Posts: 160
    Registered: ‎01-29-2007
    Accepted Solution

    export parts of drawing to another dwg....

    292 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!

    Please use plain text.
    Mentor
    Posts: 225
    Registered: ‎04-11-2010

    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

    Please use plain text.
    *Expert Elite*
    Posts: 2,070
    Registered: ‎11-24-2009

    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

     

    Please use plain text.
    Active Member
    Posts: 10
    Registered: ‎07-29-2009

    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

    Please use plain text.
    *Pro
    M_Hensley
    Posts: 1,575
    Registered: ‎12-11-2003

    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?

    Please use plain text.
    *Expert Elite*
    pendean
    Posts: 15,039
    Registered: ‎11-06-2003

    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 | RSS | Twitter | PINS
    Please use plain text.
    Distinguished Contributor
    Posts: 160
    Registered: ‎01-29-2007

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

    Please use plain text.
    *Expert Elite*
    pendean
    Posts: 15,039
    Registered: ‎11-06-2003

    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 | RSS | Twitter | PINS
    Please use plain text.
    Distinguished Contributor
    Posts: 160
    Registered: ‎01-29-2007

    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!

    Please use plain text.
    *Expert Elite*
    Posts: 2,070
    Registered: ‎11-24-2009

    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:

    Please use plain text.