stevedrew Posted May 21, 2012 Posted May 21, 2012 (edited) Have not used lisp in ages... Working with viewports... I want to make active the viewport in the layout I am working in. Automatically select the "only" viewport I have within the layout Zoom to any scale in which I am prompted. Deactivate the viewport Then regenall Below is a "very" basic routine (almost embarrased to show) but hopefully it will demonstrate what I am wanting to do. I have seem many variations where developers have code to turn on or off the viewports but have not been able to translate it into my existing routine... I just don't have a high enough level of understanding ActiveX or AutoLISP. I tried using MSPACE and VPORTS commands (to toggle and or turn on/off) in my code but was not successful... Note: There is only one viewport in layout.... I tried this but it didn't fly... Everything works except the unlocking and locking of (model space) Evidently locking and unlocking vports are not that staightforward in AutoLISP... Anyone have any suggestions? (vl-load-com) (defun c:zxp () (command "vports" "l" "off") (vl-cmdf "_.MSPACE") (setq MYXP (getstring "Enter Scale Factor: ")) (command "zoom" (strcat "1/" MYXP "XP")) (command "regenall") (vl-cmdf "_.PSPACE") (command "vports" "l" "on") ) Any help is appreciated... Edited May 23, 2012 by stevedrew sentence corrections Quote
MSasu Posted May 21, 2012 Posted May 21, 2012 I think you will get better results accessing the associated list of that viewport - check the SSGET, ENTGET and ENTMOD functions. Should investigate the DXF codes 41, 45 and 90 (check this document for more information, page 150). By the way, please edit your post to add code tags to your example. Thank you. Quote
Tharwat Posted May 21, 2012 Posted May 21, 2012 This ... ? (defun c:Test (/ vp sc) (vl-load-com) (if (and (setq vp (ssget "_x" (list '(0 . "VIEWPORT") (cons 410 (getvar 'ctab))))) (setq sc (getdist "\n Enter Scale Factor:")) ) (vla-put-customscale (vlax-ename->vla-object (ssname vp 0)) sc ) (princ) ) (princ) ) Quote
stevedrew Posted May 22, 2012 Author Posted May 22, 2012 I tried to edit my post to include CODE but when I highlighted the text there was no # to select.... Quote
MSasu Posted May 23, 2012 Posted May 23, 2012 When edit your post, on the bottom-right side of the editor will find a button named "Go Advanced" - this will activate the enhanced version of the editor. Alternatively may write by yourself the tags at the end ("[/code]"), respectively beginning (" ") of your code excerpt. Quote
stevedrew Posted May 23, 2012 Author Posted May 23, 2012 When edit your post, on the bottom-right side of the editor will find a button named "Go Advanced" - this will activate the enhanced version of the editor. Alternatively may write by yourself the tags at the end ("[/code]"), respectively beginning (" ") of your code excerpt. Thanks got it Quote
Lee Mac Posted May 27, 2012 Posted May 27, 2012 I think you will get better results accessing the associated list of that viewport - check the SSGET, ENTGET and ENTMOD functions. Should investigate the DXF codes 41, 45 and 90 (check this document for more information, page 150). Note that you cannot use entmod to modify a Viewport entity; from the VLIDE Help: There are restrictions on the changes the entmod function can make: An entity's type and handle cannot be changed. If you want to do this, use entdel to delete the entity, and then make a new entity with the command or entmake function. The entmod function cannot change internal fields, such as the entity name in the -2 group of a seqend entity. Attempts to change such fields are ignored. You cannot use the entmod function to modify a viewport entity. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.