Jump to content

Recommended Posts

Posted

I am trying to pick a viewport outline and get its CVPORT number, I have  a dwg and its vport has been made pretty sure using the object option of picking a pline. The assoc 69 will give cvport number but some viewports do not have a 69, if you use (setvar 'cvport 2) the correct port is selected. 

 

The sample has multi mviews using (setq dxf_69 (cdr(assoc 69 (entget (car (entsel)))))) will return vport number try on all and the lower left does not.

Using (setvar 'cvport 2) sets the correct vport ,try (setvar 'cvport 3) 4 5 etc

 

This is part of a bigger program and needs to know which vport picked.

 

mview test.dwg

Posted

These are clipped VPs. You are not necessarily selecting the VP when you use (entsel). You may also select the object (polyline) used to clip the VP. So you code should check what object has been selected:

  (if
    (and
      ; ...
      ; ...
      (setq elst (entget enm))
      (setq typ (cdr (assoc 0 elst)))
      (or
        (= typ "VIEWPORT")
        (and
          (= typ "LWPOLYLINE")
          (setq enm (cdadr (member '(102 . "{ACAD_REACTORS") elst)))
          (setq elst (entget enm))
          (= (cdr (assoc 0 elst)) "VIEWPORT")
        )
        (prompt "\nError: not a viewport ")
      )
      ; ...
      ; ...
    )
    (progn
      ; ...
    )
  )

 

Posted (edited)

Thanks roy_043 should have said using (setq sss (ssget "_+.:E:S" (list (cons 0 "Viewport")))) in code, that may have been my problem using entsel for testing did not see it was not picking the viewport but rather the poly outline, the vport object is a "group" with 2 objects a viewport and  polyline.

 

Changed test code and tried in Acad and Bricscad both working. The answer sometimes is just staring at you. Thanks again.

 

Need to shut down and take dog for walk more often.
 

 

 

Edited by BIGAL
Posted (edited)

Back at it again found a problem I run Civ3D 2020 if you do (setvar 'CVPORT X) where X is a mview number Autocad returns rejected, Bricscad works OK I am not sure if its a bug. 

 

Trying to find some other way of setting current viewport any one have an idea ?

 

To test my code just double clicked inside a viewport then back to pspace code works perfect ran on multiple viewports. Trying to avoid the dbl click.

Edited by BIGAL
Posted

Found the answer for any one else provided by a co worker not using any code, you must be in mspace before you can change vports.

 

(command "mspace")
(setvar 'cvport x)

 

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