View Full Version : help putting the Ctrl+R into lisp
FRAMEDNLV
2007-10-10, 08:00 PM
How can I Cycles layout viewports in a lisp routine. I tried reading threw the help section and search on this site (along with autodesk), but found nothing.
Any help would be greatly appreciated,
Chris
RobertB
2007-10-10, 08:47 PM
Look at the ActivePVierwport property. Follow the cautions in the help file carefully.
T.Willey
2007-10-10, 09:37 PM
Or you can get a selection set of all the viewports in the current paper space, then cycle the the viewport ids with the system variable cvport. Just remember that the viewport that has an id of 1 is the main paper space viewport.
Mike_R
2007-10-10, 10:42 PM
A few things to keep in mind...
In order to change viewports with LISP, you have to make sure you're inside an active viewport. which means running the mspace command before attempting to switch.
This may seem dumb, but it's an easy oversight... You have to be on a layout tab to use a viewport at all. Forgetting to program in a check for that will cause an error.
The stuff RobertB and T.Willey said... ;)
If you want some sample code, just holler. But keep the stuff we've told you in mind and it shouldn't be too difficult.
FRAMEDNLV
2007-10-10, 10:50 PM
Thanks everyone!!!!!:beer:
I was able to get the whole thing done and working. It is goes threw and sets the ucs follow to off on all viewports.
;Make_lsp.lsp - Auto-Lisp Routine Maker.
;
;
(setvar "cmdecho" 1)
(COMMAND "TILEMODE" "0")
(command "pspace")
(command "-vports" "lock" "on" "all" "" )
(command "mspace")
(defun C:VP-F-FX( / en enlist eset cntr)
(setvar "cmdecho" 1)
(princ "\n \n....Please Wait.....Building Selection Set....\n ")
(if(setq eset (ssget "x" (list (cons 0 "VIEWPORT") (cons 410 (getvar "ctab")))));edit
(progn
(setq cntr (- (sslength eset) 1))
(princ "\n \n....Please Wait.....Altering Selection Set....\n ")
(while (>= cntr 1)
(COMMAND "CVPORT" (+ 1 CNTR))
(COMMAND "UCSFOLLOW" "0")
(setq cntr(- cntr 1))
)
))
(setvar "cmdecho" 1)
(command "pspace")
(command "-vports" "lock" "OFF" "all" "" )
(princ ".....VP-F-FX.lsp Complete. \n ")
(princ)
)
I used the Make_lisp program to get the selection set part, modified some numbers for Viewports and added the rest of it junk (kinda, sort of).
This should help out the drafting.
Thanks,
Chris
RobertB
2007-10-10, 11:10 PM
Note that you don't need to use (command) to change a system variable. You can use (setvar) instead.
T.Willey
2007-10-10, 11:45 PM
Also you may want to limit the selection of viewports to the current tab. So the selection set part would look like
(setq eset (ssget "x" (list (cons 0 "VIEWPORT") (cons 410 (getvar "ctab")))))
Won't be a problem is you have only one paper space, but if you have two, and one has more viewports than the other, you routine should error.
FRAMEDNLV
2007-10-10, 11:54 PM
Also you may want to limit the selection of viewports to the current tab. So the selection set part would look like
(setq eset (ssget "x" (list (cons 0 "VIEWPORT") (cons 410 (getvar "ctab")))))
Won't be a problem is you have only one paper space, but if you have two, and one has more viewports than the other, you routine should error.
I made the change to the lisp in the thread to include the current tab.
Thanks,
Chris
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.