Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Viewports and choosing which one

5 REPLIES 5
Reply
Message 1 of 6
Anonymous
161 Views, 5 Replies

Viewports and choosing which one

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?
5 REPLIES 5
Message 2 of 6
Anonymous
in reply to: Anonymous

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.
Message 3 of 6
Anonymous
in reply to: Anonymous

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
Message 4 of 6
Anonymous
in reply to: Anonymous

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.
Message 5 of 6
Anonymous
in reply to: Anonymous

Hi Grigs,

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

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
Message 6 of 6
Anonymous
in reply to: Anonymous

Well, this was my first attempt. It kinda of doesn't work tho 🙂

(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)
)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost