I have a lisp routine that I constructed from other lisps that I found around the forums. This lisp selects only the objects in Modelspace that can be seen in the selected viewport and moves them to Paperspace. What I would like for it to do is run on all viewports in a single tab with no user input.
Any help in helping me understand would be greatly appreciated.
Code:
;;; ChangeSpace.lsp moves objects from MSpace to Pspace
;;; Based on VPLIM.lsp written by Rebecca L. Johnson, June 1, 2007
(defun c:CS (/ vp ht wd vn ctr ctrx ctry vs xp iw bl br tr tl items)
(command "pspace")
(setq vp (entget
(car (entsel "\nSelect Viewport to move Item from Modelspace to Paperspace.... "))
);entget
);setq
(setq ht (cdr (assoc 41 vp))) ; Get Viewport height
(setq wd (cdr (assoc 40 vp))) ; Get Viewport width
(setq vn (cdr (assoc 69 vp))) ; Get Viewport CVPort variable
(command "mspace")
(setvar "cvport" vn) ; Set correct viewport
(command ".ucs" "v") ; Set UCS to View
(setq ctr (getvar "viewctr")) ; Get VIEWCTR
(setq ctrx (car ctr)) ; Get X of CTR
(setq ctry (cadr ctr)) ; Get Y of CTR
(setq vs (getvar "viewsize")) ; Get inside Viewport height
(setq xp (/ ht vs)) ; Get XP Factor with height
(setq iw (* (/ vs ht) wd)) ; Get inside width of Viewport
(setq bl (list (- ctrx (/ iw 2)) (- ctry (/ vs 2))))
; Find four corners of Viewport
(setq br (list (+ ctrx (/ iw 2)) (- ctry (/ vs 2))))
(setq tr (list (+ ctrx (/ iw 2)) (+ ctry (/ vs 2))))
(setq tl (list (- ctrx (/ iw 2)) (+ ctry (/ vs 2))))
(Setq items (ssget "w" bl tr)) ;Makes a selection set of all objects in selected vport
(command "chspace" items "" "")
(command "pspace"))
(princ)
);defun