Author Topic: Copy objects to layouts  (Read 3426 times)

0 Members and 1 Guest are viewing this topic.

HasanCAD

  • Swamp Rat
  • Posts: 1422
Copy objects to layouts
« on: January 18, 2011, 08:53:10 AM »
I created this very simple routine to copy objects to layouts
Any suggestions are welcomed

Code: [Select]
(defun c:CTLyot (/ Ctb Obj Lyt)
  (prompt "\nSelect objects to copy to all alyouts")
  (setq Ctb (getvar "CTAB"))
  (setq Obj (ssget))
  (setq ObjCcnt (sslength Obj))
  (command "_copybase" '(0 0) Obj "")

  (foreach Lyt (layoutlist)
    (command "LAYOUT" "S" Lyt)
    (command "PSPACE")
    (command "_pasteclip" '(0 0))
  )
  (setvar "CTAB" Ctb)
  (command "ERASE" obj "")
  (princ)
  )

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Copy objects to layouts
« Reply #1 on: January 18, 2011, 09:05:26 AM »
Take a look here:
http://www.theswamp.org/index.php?topic=3012.msg98505#msg98505

I have modified the routine to copy any object if you need I will post the revised routine.
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.

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: Copy objects to layouts
« Reply #2 on: January 18, 2011, 10:54:14 AM »
Take a look here:
...
Its good link I am thinking about Borrow (steal ;)) DCL file.

...
I have modified
...
It is very kind of you to upload your routine

But is there any comment about this routine

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Copy objects to layouts
« Reply #3 on: January 18, 2011, 11:18:46 AM »
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.

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Copy objects to layouts
« Reply #4 on: January 18, 2011, 11:22:28 AM »
Good try hasan .

But some comments . :-)

- There is no need for the following code within your routine .
Code: [Select]
(setq ObjCcnt (sslength Obj))

- It better to use decimal numbers for the coordinate points like '(0.0 0.0 0.0) .

Good luck

kruuger

  • Swamp Rat
  • Posts: 637
Re: Copy objects to layouts
« Reply #5 on: January 18, 2011, 02:57:02 PM »
Take a look here:
http://www.theswamp.org/index.php?topic=3012.msg98505#msg98505

I have modified the routine to copy any object if you need I will post the revised routine.

CAB this is great. Previously i got something similar to HasanCAD but your routine is "silent" (no skipping)  :-)
Why this can't wotk with Viewport? What problem is with them?

thanks
kruuger

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Copy objects to layouts
« Reply #6 on: January 18, 2011, 03:45:11 PM »
After changing the copy part to use vlax-invoke:

Code: [Select]
(mapcar '(lambda (x) (vlax-invoke *adoc* 'copyobjects objs (vla-get-block x) nil)) lays)
I have not had any issues copying viewports.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Copy objects to layouts
« Reply #7 on: January 18, 2011, 04:15:04 PM »
Thanks Ron, I updated the code.  8-)
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.

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Copy objects to layouts
« Reply #8 on: January 18, 2011, 04:43:19 PM »
Thanks Ron, I updated the code.  8-)

No prob  :-) I think the idea was actually spurred from some of TWilley's code.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Malzer

  • Guest
Re: Copy objects to layouts
« Reply #9 on: February 03, 2011, 08:19:54 AM »
Try AutoCAD command: CHSPACE

Lee Mac

  • Seagull
  • Posts: 12922
  • London, England
Re: Copy objects to layouts
« Reply #10 on: February 04, 2011, 11:51:38 AM »
Was bored so quickly put this together  :-)

Code: [Select]
<-- Old Code Removed -->
« Last Edit: February 10, 2011, 02:19:58 PM by Lee Mac »

Lee Mac

  • Seagull
  • Posts: 12922
  • London, England
Re: Copy objects to layouts
« Reply #11 on: February 10, 2011, 02:20:35 PM »
Updated my code here:

http://lee-mac.com/copytolayouts.html

Not dissimilar to CAB's I think - but it was fun to write all the same.  ;-)