Author Topic: Copy part of xref into active drawing  (Read 10640 times)

0 Members and 1 Guest are viewing this topic.

jonesy

  • SuperMod
  • Seagull
  • Posts: 15568
Copy part of xref into active drawing
« 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 :)
Thanks for explaining the word "many" to me, it means a lot.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Copy part of xref into active drawing
« Reply #1 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
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Gliderider

  • Guest
Re: Copy part of xref into active drawing
« Reply #2 on: February 11, 2009, 11:11:59 AM »
You can try Express tools' Ncopy... I've never had much luck using it though

sinc

  • Guest
Re: Copy part of xref into active drawing
« Reply #3 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...

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Copy part of xref into active drawing
« Reply #4 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)
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

jonesy

  • SuperMod
  • Seagull
  • Posts: 15568
Re: Copy part of xref into active drawing
« Reply #5 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
Thanks for explaining the word "many" to me, it means a lot.

wannabe

  • Guest
Re: Copy part of xref into active drawing
« Reply #6 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?

wannabe

  • Guest
Re: Copy part of xref into active drawing
« Reply #7 on: February 12, 2009, 02:44:25 PM »
Oh, and you might be keener on the new Microstation   :-)

danglar

  • Newt
  • Posts: 161
  • Read My Li(s)(p)
Re: Copy part of xref into active drawing
« Reply #8 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?

Escape

  • Mosquito
  • Posts: 1
Re: Copy part of xref into active drawing
« Reply #9 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?
« Last Edit: September 05, 2016, 10:28:05 AM by Escape »