ElAmigo Posted March 15, 2024 Posted March 15, 2024 (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, 2024 by ElAmigo Quote
EnM4st3r Posted March 15, 2024 Posted March 15, 2024 (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, 2024 by EnM4st3r Quote
EnM4st3r Posted March 15, 2024 Posted March 15, 2024 so while creating your viewport save its ename / vla-objname and use that as pviewport Quote
ElAmigo Posted March 15, 2024 Author Posted March 15, 2024 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
BIGAL Posted March 16, 2024 Posted March 16, 2024 (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, 2024 by BIGAL 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.