Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Valued Contributor
Grigs
Posts: 101
Registered: ‎09-29-2004
Message 1 of 6 (47 Views)

Viewports and choosing which one

47 Views, 5 Replies
04-10-2006 10:45 AM
I am trying to write a lisp that sets the viewport scale based on a menu choice.

Is there a way to prompt the user for which viewport to activate?

For instance, if there are 2 viewports on the paperspace layout and one has to be 1/4" and the other 1/8". Can it be done in lisp so that the lisp stops and lets the user chose which viewport to activate, switch to that viewport, then continue with changing the zoom factor?
Valued Contributor
Grigs
Posts: 101
Registered: ‎09-29-2004
Message 2 of 6 (47 Views)

Re: Viewports and choosing which one

04-10-2006 11:17 AM in reply to: Grigs
Basically:

Choose a zoom factor from a pulldown menu

let the user highlight which model window to change

switch to that model window and set the zoom factor.
Distinguished Contributor
pnorman
Posts: 614
Registered: ‎02-24-2006
Message 3 of 6 (47 Views)

Re: Viewports and choosing which one

04-10-2006 12:26 PM in reply to: Grigs
Hi Grigs,

Not sure why you don't want to just use change porperties, and no I don't have a lisp that will do exactly that BUT if you're feeling like a challenge and want to have a go at writing your own here are some clues...

You don't need to switch from PS to MS or from viewport to viewport to change or set the scale, unless of course you really want to??

;;;to get the scale of the psviewports
;;;create a selection set of the viewports on the current layout tab only
(setq SS (ssget "X" (list '(0 . "VIEWPORT")(cons 410 (getvar "ctab")))))
;get the scale of the first viewport in the selection set
(setq VP_SC (/ 1 (vla-get-customscale (vlax-ename->vla-object (ssname SS 0)))))
;set the scale of the first viewport in the selection set
(vla-put-customscale (vlax-ename->vla-object (ssname SS 0)) (/ 1.0 VP_SC))
;highlight the viewport
(redraw (ssname SS 0) 3)
;un-highlight the viewport
(redraw (ssname SS 0) 4)
;number of viewports on current layout tab including Paper space!
(sslength SS)

Regards
Phill
Valued Contributor
Grigs
Posts: 101
Registered: ‎09-29-2004
Message 4 of 6 (47 Views)

Re: Viewports and choosing which one

04-10-2006 12:31 PM in reply to: Grigs
Personally, I don't care if just the properties are changed or if you actually go into the viewport and change the zoomxp factor. Whichever way works the easiest.
Distinguished Contributor
pnorman
Posts: 614
Registered: ‎02-24-2006
Message 5 of 6 (47 Views)

Re: Viewports and choosing which one

04-10-2006 12:38 PM in reply to: Grigs
Hi Grigs,

Sorry to leave you hanging but I don't have time this week to write a lisp for you :smileysad:

Also if you have started some lisp already then post it so people can see what you have so far...

If anyone else wants to help Grigs out....

Cheers
Phill
Valued Contributor
Grigs
Posts: 101
Registered: ‎09-29-2004
Message 6 of 6 (47 Views)

Re: Viewports and choosing which one

04-10-2006 12:49 PM in reply to: Grigs
Well, this was my first attempt. It kinda of doesn't work tho :smileyhappy:

(defun c:z48 ()
(SETQ T_1 (GETVAR "TILEMODE"))
(IF (= T_1 1)
(PROGN
(PROMPT "\nTILEMODE = 1, You are in Model Space..") ; IF EQ 0
(PROMPT "\nPlease change to Paperspace")
(PRINC)
)
(PROGN
(PROMPT "\nSWITCHING TO MODELSPACE...")
(PROMPT "\nSELECT ACTIVE VIEWPORT...")
(command ".select" "auto" pause)
(command "MSPACE")
(TEXTSCR)
(command "zoom" "1/48xp")
)
)
(GRAPHSCR)
(PRINC)
)
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.