Jump to content

Recommended Posts

Posted (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 by stevedrew
sentence corrections
Posted

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.

Posted

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

Posted

Thanks for your help.

 

GOT IT!

Posted

Please add CODE TAGS to your first post.

Posted

I tried to edit my post to include CODE but when I highlighted the text there was no # to select....

Posted

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.
Posted
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

Posted
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.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...