I really like this simple routine. It shows the power of AutoLISP. You can take an existing command in AutoCAD (CHSPACE in this example) and add an option.
The CHSPACE command (CHange SPACE) allows you to move objects from a paper space viewport to model space or from model space to paper space. It moves these objects and keeps their scaling proportional to the viewport scale. The command is limited to moving objects. That’s where this routine comes in handy. With this routine, you now have an easy way to copy objects through viewports in the same manner as the CHSPACE command moves objects.
- CHSPACECOPY <enter> to start
- Select objects to copy to model space or paper space (depending on your current “space”)
hit <enter> to execute and finish
Shown below: Copying objects from model space to paper space.
Shown below: Copying objects from paper space to model space.
(defun c:CHSpaceCopy (/ ss2 ss i) (vl-load-com) (if (setq ss2 (ssadd) ss (ssget "_:L") ) (progn (repeat (setq i (sslength ss)) (ssadd (vlax-vla-object->ename (vla-copy (vlax-ename->vla-object (ssname ss (setq i (1- i)))))) ss2 ) ) (vl-cmdf "_.chspace" ss2 "") ) ) (princ) )