TheSwamp

CAD Forums => CAD General => Topic started by: jonesy on February 11, 2009, 08:50:01 AM

Title: Copy part of xref into active drawing
Post by: jonesy on February 11, 2009, 08:50:01 AM
One thing I used to find useful in Microstation was the ability to copy objects through from the reference file to the active drawing file by using "locate" (I think... its been a long time since I fired up that particular beastie) All this happens without having to leave the active file.

Is there any way this can be done in AutoCAD? (natively or a routine someone has stashed away somewhere)

Many thanks in advance
T :)
Title: Re: Copy part of xref into active drawing
Post by: CAB on February 11, 2009, 09:22:56 AM
Could not find a partial copy but did find this:
http://www.theswamp.org/index.php?topic=8416.msg108349#msg108349 (http://www.theswamp.org/index.php?topic=8416.msg108349#msg108349)
Title: Re: Copy part of xref into active drawing
Post by: Gliderider on February 11, 2009, 11:11:59 AM
You can try Express tools' Ncopy... I've never had much luck using it though
Title: Re: Copy part of xref into active drawing
Post by: sinc on February 11, 2009, 11:16:08 AM
I've got a tool like that, but currently it only works in Civil 3D.  It's been so incredibly useful, though, that maybe I should try and break it out into something for Autocad in general...
Title: Re: Copy part of xref into active drawing
Post by: ronjonp on February 11, 2009, 11:22:35 AM
I cobbled this together a while back...could probably be improved, but it's been working for me :).

Code: [Select]
(defun c:copyn (/ blk blks e i lst obj tm ss)
  (setq blks (vla-get-blocks
       (vla-get-activedocument (vlax-get-acad-object))
     )
ss   (ssadd)
  )
  (while (and (setq e (nentselp "Select nested object to copy: "))
      (setq tm (caddr e))
      (setq blk (car (cadddr e)))
      (setq blk (vlax-ename->vla-object blk))
      (setq i (vla-item blks (vla-get-name blk)))
)
    (if (= (vla-get-isxref i) :vlax-false)
      (vlax-for be i
(if (and (setq e (entget (vlax-vla-object->ename be)))
(not (cdr (assoc 102 e)))
(setq obj (entmakex e))
(setq obj (vlax-ename->vla-object obj))
    )
  (progn
    (vla-transformby obj (vlax-tmatrix tm))
    (setq lst (cons (list obj (vla-get-color obj)) lst))
    (vla-put-color obj 1)
    (vla-update obj)
  )
  (princ (strcat "\nComplex entity not created [ "
(cdr (assoc 0 e))
" ]"
)
  )
)
      )
      (progn
(setq obj (vlax-ename->vla-object (entmakex (entget (car e)))))
(vla-transformby obj (vlax-tmatrix tm))
(setq lst (cons (list obj (vla-get-color obj)) lst))
(vla-put-color obj 1)
(vla-update obj)
      )
    )
  )
  (if lst
    (progn (foreach o lst
     ;;(vla-put-color (car o) (cadr o))
     (setq ss (ssadd (vlax-vla-object->ename (car o)) ss))
     (command ".draworder"
      (vlax-vla-object->ename (car o))
      ""
      "front"
     )
   )
   (sssetfirst nil ss)
    )
  )
  (princ)
)
Title: Re: Copy part of xref into active drawing
Post by: jonesy on February 11, 2009, 11:26:00 AM
Oh thanks guys, I'll try the code tomorrow.

Its one of the only commands I miss from Microstation
Title: Re: Copy part of xref into active drawing
Post by: wannabe on February 12, 2009, 01:54:37 PM
Doesn't Refedit work? Open Refedit, choose items, copy using the same base point twice and then remove from the working set? Cancel all changes to the reference just to be safe?
Title: Re: Copy part of xref into active drawing
Post by: wannabe on February 12, 2009, 02:44:25 PM
Oh, and you might be keener on the new Microstation   :-)
Title: Re: Copy part of xref into active drawing
Post by: danglar on December 17, 2015, 01:55:28 AM
I did a little modification of routine from here:

http://www.theswamp.org/index.php?topic=27354.msg329179#msg329179

Now you can copy nested blocks and/or other entities and move it in a same time (see attached lisp)

Remain a "little" issue: Routine explode blocks in current drawing...
Is it  possible to fix it?
Title: Re: Copy part of xref into active drawing
Post by: Escape on August 20, 2016, 08:56:44 PM
ronjonp, thanks a lot for your cobbled routine - it's too useful and there's no other places on all over the Internet I found something similar.
But I've noticed a couple of "little issues". In addition to found by danglar (posted one message higher), routine can't copy objects with any linetypes but "Continuous", even if that linetype definition attends in the drawing. It's too pity. Routine terminates with report: "Bad argument type: lentityp nil". Can somebody give me a foggiest idea why it happens?