Jump to content

MSPACE doesn't always take new viewport


ElAmigo

Recommended Posts

Hello friends,

 

I have the following piece of code:

      (command "CTAB" Document_ID)
      (command "MVIEW" PVPP1 PVPP2)
      (command "_MSPACE")
      (command "_CANNOSCALE" nieuweSchaal "")
      (command "ZOOM" "S" zsch2 "")
      (command "ZOOM" "C" nieuwPunt "" "")
      (command "_PSPACE")

 

Document_ID is the layout name so it redirects to paperspace. Then I use with two variables to make the viewport. All of this works. But then I use MSPACE and sometimes it takes the wrong Viewport. The other viewport is locked and in a different layer than 0. The new viewport always goes to layer 0. The problem occurs when I run this in a big piece of code that also sets up the first viewport. But when I use all command seperately it works fine. In the big code it always takes the wrong viewport after making the new one. I hope someone can help with this.

Edited by ElAmigo
Link to comment
Share on other sites

try using 
 

(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(vla-put-activepviewport doc pviewport) ; pviewport = vla-obj
(vla-put-mspace doc :vlax-true)

 

Edited by EnM4st3r
Link to comment
Share on other sites

so while creating your viewport save its ename / vla-objname and use that as pviewport

Link to comment
Share on other sites

2 hours ago, EnM4st3r said:

try using 
 

(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(vla-put-activepviewport doc pviewport) ; pviewport = vla-obj
(vla-put-mspace doc :vlax-true)

 

Doesn't work. For some reason after creating the viewport the code still goes into the wrong viewport using MSPACE. Using your code sadly only gave me errors

Link to comment
Share on other sites

You can get how many viewports you have say 2 as minimum ie Pspace and your 1st viewport, so when you add a new viewport you can set that viewport as the current viewport.

 

Something like this not really tested. Its pulled out of other code to get around multi viewport problems. 

(setq sss (ssget "X" (list (cons 0 "Viewport")(cons 410 (getvar 'ctab)))))
(setq cspace (cdr (assoc 69 (entget (ssname sss 0)))))
(setvar 'cvport cspace)

 

Edited by BIGAL
Link to comment
Share on other sites

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