Author Topic: Copy entities from Xref to working drawing  (Read 4622 times)

0 Members and 1 Guest are viewing this topic.

dannypd

  • Guest
Copy entities from Xref to working drawing
« on: April 25, 2009, 11:30:03 PM »
Hi
Does anyone has lisp routine which copy objects from xref to the working drawing without opening the xref (keeping xref's object layer as it is).  "Ncopy" from express tools can do similar job but it doesnt copy its xref's layer.
Thanks & Regards,

Patrick_35

  • Guest
Re: Copy entities from Xref to working drawing
« Reply #1 on: April 27, 2009, 06:03:15 AM »
Hi

An example to import layer from a dwg

Code: [Select]
(defun ila(lst nom_dwg / Ouvrir_dessin_dbx cp dbx doc lan lay)
  (defun Ouvrir_dessin_dbx(dwg / dbx)
    (vl-load-com)
    (if (< (atoi (substr (getvar "ACADVER") 1 2)) 16)
      (setq dbx (vlax-create-object "ObjectDBX.AxDbDocument"))
      (setq dbx (vlax-create-object (strcat "ObjectDBX.AxDbDocument." (substr (getvar "ACADVER") 1 2))))
    )
    (vla-open dbx dwg)
    dbx
  )

  (and (setq nom_dwg (findfile nom_dwg))
    (progn
      (if (vl-catch-all-error-p (setq doc (vl-catch-all-apply 'vla-item (list (vla-get-documents (vlax-get-acad-object)) (strcat (vl-filename-base nom_dwg) (vl-filename-extension nom_dwg))))))
(setq dbx (ouvrir_dessin_dbx nom_dwg) lan T)
(setq dbx doc)
      )
      (foreach lay lst
(or (vl-catch-all-error-p (setq cp (vl-catch-all-apply 'vla-item (list (vla-get-layers dbx) lay))))
  (vla-CopyObjects Dbx
   (vlax-safearray-fill
     (vlax-make-safearray vlax-vbObject '(0 . 0))
     (list cp)
   )
   (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))
  )
)
      )
    )
  )
  (and lan (vlax-release-object dbx))
  (princ)
)

Code: [Select]
(ila '("layer1" "layer2") "c:/file.dwg")

@+
« Last Edit: April 27, 2009, 08:10:49 AM by Patrick_35 »

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Copy entities from Xref to working drawing
« Reply #2 on: April 27, 2009, 11:07:02 AM »
[ http://www.theswamp.org/index.php?topic=24251.msg293032#msg293032 ]

This thread has a file attached that has the option to copy a layers contents from an xref drawings to the current drawing, or just items you select one at a time.  You will also need the code that is posted within the thread, and not just the lisp file attached.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

dannypd

  • Guest
Re: Copy entities from Xref to working drawing
« Reply #3 on: April 27, 2009, 11:40:41 AM »
Thanks for the reply. but it doesnt copy xref entity layer to the working drawing.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Copy entities from Xref to working drawing
« Reply #4 on: April 27, 2009, 11:54:16 AM »
Thanks for the reply. but it doesnt copy xref entity layer to the working drawing.

It does when I use it.  I just tested it in a drawing with two layers.  I copied one object, and now there are three layers.  It is the correct name, ie:
E-Gridline
instead of
Xrefname|E-Gridline
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.