Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Distinguished Contributor
iwafb
Posts: 156
Registered: ‎05-17-2004
Message 1 of 12 (580 Views)
Accepted Solution

Transferring objects from model space to paper space

580 Views, 11 Replies
02-05-2014 07:36 PM

Hi All,

 

Does anyone have a solution for moving objects from model space to paper space other than creating blocks? I'm thinking something like using entmod and changing DXF code 410, but this doesn't seem to work (Is code 410 read only?).

 

Any suggestions will be most welcome.

 

Cheers

John


iwafb wrote:

The positioning of the entities will be exactly the same in paper space as it is in model space. At the moment, the process is to copy all entites using 0,0,0 and pasting in paper space at 0,0,0. We do have more than one layout tab, and eventually we may want to copy these entities over several layout tabs. But, for the moment, just happy to move the elements to the first layout tab available (generally "Layout1")...

 

Thanks,

John


(defun c:m2s (/ i aDoc LayoutColl MoveToLayout ss ObjToMove)
;;; pBeFeb2014 ;;;
(vl-load-com)
(setq i -1
adoc (vla-get-activedocument (vlax-get-acad-object))
LayoutColl (vla-get-layouts adoc)
)
(if (and (setq MoveToLayout nil
ss (ssget "_:L")
)
(not (textscr))
(foreach itm (layoutlist)
(princ (strcat "\nInput "
(itoa (setq i (1+ i)))
" for layout "
itm
)
)
)
(setq lnum (getint "\nEnter Index value: "))
(setq NLNAme (nth lnum (layoutlist)))
)
(progn
(vlax-for x (setq ObjToMove (vla-get-activeselectionset aDoc))
(setq MoveToLayout (cons x MoveToLayout))
)
(vla-delete ObjToMove)
(vla-CopyObjects
ADoc
(vlax-make-variant
(vlax-safearray-fill
(vlax-make-safearray
vlax-vbObject
(cons 0 (1- (length MoveToLayout)))
)
MoveToLayout
)
)
(vla-get-block (vla-item LayoutColl NLNAme))
)
(foreach O MoveToLayout (vla-delete O))
)
)
(princ)
)(vl-load-com)

 

Contributor
mattok
Posts: 19
Registered: ‎07-29-2009
Message 2 of 12 (578 Views)

Re: Transferring objects from model space to paper space

02-05-2014 07:38 PM in reply to: iwafb

Is this able to be done by selecting the objects then;

CTRL-C

(Switch to Other space)

CTRL-V

Distinguished Contributor
iwafb
Posts: 156
Registered: ‎05-17-2004
Message 3 of 12 (575 Views)

Re: Transferring objects from model space to paper space

02-05-2014 07:43 PM in reply to: mattok
That's the way we are doing it at the moment. I was looking for a LISP solution...
Thanks
John
*Expert Elite*
pbejse
Posts: 2,500
Registered: ‎11-24-2009
Message 4 of 12 (556 Views)

Re: Transferring objects from model space to paper space

02-05-2014 09:27 PM in reply to: iwafb

iwafb wrote:
That's the way we are doing it at the moment. I was looking for a LISP solution...
Thanks
John

Curious, why not use 

command: chspace

 

If you really want a lisp solution , i think i wrote something similar to that a long time ago. I'll have a look-see if i can find it at all....

 

 

 

Distinguished Contributor
iwafb
Posts: 156
Registered: ‎05-17-2004
Message 5 of 12 (549 Views)

Re: Transferring objects from model space to paper space

02-05-2014 09:40 PM in reply to: pbejse

The reason I want lisp is because this is a small part of a much larger process and could all be done at the literal "click of a button". I have not used CHSPACE before, but i did see it referenced on other posts. However, when I investigated it, the command was not allowed in model space so I didn't think if a viable option. In case I'm missing something, how would you propose to use chspace in this instance?

 

Cheers,

John

*Expert Elite*
pbejse
Posts: 2,500
Registered: ‎11-24-2009
Message 6 of 12 (541 Views)

Re: Transferring objects from model space to paper space

02-05-2014 10:14 PM in reply to: iwafb

iwafb wrote:

The reason I want lisp is because this is a small part of a much larger process and could all be done at the literal "click of a button". I have not used CHSPACE before, but i did see it referenced on other posts. However, when I investigated it, the command was not allowed in model space so I didn't think if a viable option. In case I'm missing something, how would you propose to use chspace in this instance?

 

Cheers,

John


So you are wanting to transfer the Model space entity to Pspace but the problem is you are at Model Space and there are no viewports correct?

What about the positions of the entities? where exactly would it land on the layout tab? and is there more than one layout tab?

 

Distinguished Contributor
iwafb
Posts: 156
Registered: ‎05-17-2004
Message 7 of 12 (537 Views)

Re: Transferring objects from model space to paper space

02-05-2014 10:19 PM in reply to: pbejse

The positioning of the entities will be exactly the same in paper space as it is in model space. At the moment, the process is to copy all entites using 0,0,0 and pasting in paper space at 0,0,0. We do have more than one layout tab, and eventually we may want to copy these entities over several layout tabs. But, for the moment, just happy to move the elements to the first layout tab available (generally "Layout1")...

 

Thanks,

John

*Expert Elite*
pbejse
Posts: 2,500
Registered: ‎11-24-2009
Message 8 of 12 (532 Views)

Re: Transferring objects from model space to paper space

02-05-2014 10:42 PM in reply to: iwafb

iwafb wrote:

The positioning of the entities will be exactly the same in paper space as it is in model space. At the moment, the process is to copy all entites using 0,0,0 and pasting in paper space at 0,0,0. We do have more than one layout tab, and eventually we may want to copy these entities over several layout tabs. But, for the moment, just happy to move the elements to the first layout tab available (generally "Layout1")...

 

Thanks,

John


(defun c:m2s (/ i aDoc LayoutColl MoveToLayout ss ObjToMove)
;;;		pBeFeb2014		;;;
  (vl-load-com)
  (setq	i	   -1
	adoc	   (vla-get-activedocument (vlax-get-acad-object))
	LayoutColl (vla-get-layouts adoc)
  )

  (if (and (setq MoveToLayout nil
		 ss (ssget "_:L")
	   )
	   (not (textscr))
	   (foreach itm	(layoutlist)
	     (princ (strcat "\nInput "
			    (itoa (setq i (1+ i)))
			    " for layout "
			    itm
		    )
	     )
	   )
	   (setq lnum (getint "\nEnter Index value: "))
	   (setq NLNAme (nth lnum (layoutlist)))
      )
    (progn
      (vlax-for	x (setq ObjToMove (vla-get-activeselectionset aDoc))
	(setq MoveToLayout (cons x MoveToLayout))
      )
      (vla-delete ObjToMove)
      (vla-CopyObjects
	ADoc
	(vlax-make-variant
	  (vlax-safearray-fill
	    (vlax-make-safearray
	      vlax-vbObject
	      (cons 0 (1- (length MoveToLayout)))
	    )
	    MoveToLayout
	  )
	)
	(vla-get-block (vla-item LayoutColl NLNAme))
      )
      (foreach O MoveToLayout (vla-delete O))
    )
  )
  (princ)
)(vl-load-com)

 

*Expert Elite*
hmsilva
Posts: 2,873
Registered: ‎12-17-2004
Message 9 of 12 (520 Views)

Re: Transferring objects from model space to paper space

02-06-2014 01:47 AM in reply to: pbejse

Nicely done, pBe :smileyhappy:

 

Cheers

Henrique

*Expert Elite*
Lee_Mac
Posts: 1,179
Registered: ‎12-29-2009
Message 10 of 12 (500 Views)

Re: Transferring objects from model space to paper space

02-06-2014 12:53 PM in reply to: iwafb

An old program of mine: Copy to Layouts

Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)
Expert Elite
With Mathematics there is the possibility of perfect rigour, so why settle for less?
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.