ElAmigo Posted March 15 Share Posted March 15 (edited) 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 March 15 by ElAmigo Quote Link to comment Share on other sites More sharing options...
EnM4st3r Posted March 15 Share Posted March 15 (edited) 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 March 15 by EnM4st3r Quote Link to comment Share on other sites More sharing options...
EnM4st3r Posted March 15 Share Posted March 15 so while creating your viewport save its ename / vla-objname and use that as pviewport Quote Link to comment Share on other sites More sharing options...
ElAmigo Posted March 15 Author Share Posted March 15 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 Quote Link to comment Share on other sites More sharing options...
BIGAL Posted March 16 Share Posted March 16 (edited) 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 March 16 by BIGAL Quote Link to comment Share on other sites More sharing options...
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.