Which viewport is activated when typing MSPACE?

Which viewport is activated when typing MSPACE?

Kh.mbkh
Advocate Advocate
390 Views
4 Replies
Message 1 of 5

Which viewport is activated when typing MSPACE?

Kh.mbkh
Advocate
Advocate

I'm using a loop to repeatedly do these actions while building various viewports:

(setq LayoutName (last (GetLayoutOrdered)))   ; Get last Layout
(setvar 'ctab LayoutName)  
(command "._pspace" "._-vports" Pi Pf )
(setq vp (entlast)) 
(command "._Mspace" )
(command "_.ZOOM" "w" PBG PHD)
(command "._pspace" ) 

Variables Pi, Pf, PBG and PHD change during the REPEAT loop.

My issue was with the "Mspace" command; it did not select the last viewport I just created. It remembered other previous viewports.

So my question is: how to specify the viewport that will be activated with "Mspace"?

 

 

0 Likes
Accepted solutions (2)
391 Views
4 Replies
Replies (4)
Message 2 of 5

SAPER59
Advocate
Advocate
Accepted solution

You can set the variable entvp as the ename of the desired Vport

and follow this that ensure you go to mspace and set selected vport as active 

(setq MsVp (vlax-ename->vla-object entvp))
(vla-put-mspace acadDoc :vlax-true)
(vla-put-activepviewport acadDoc MsVp)

0 Likes
Message 3 of 5

andkal
Collaborator
Collaborator
Accepted solution

Hi there

alternatively you can activate the specific viewport with this code:

 

(setq vpnum (cdr (assoc 69 (entget vprt_ename) ) ) ) )
(vl-cmdf "_.mspace")
(setvar "CVPORT" vpnum)

 

where vprt_ename variable ist that viewport ename


• www.autolisps.blogspot.com - Productivity plugins for Autocad and Autocad MEP
• Autodesk AppStore
0 Likes
Message 4 of 5

TomBeauford
Advisor
Advisor

You've got the points you used to create the viewport, use one of those in an ssget filter like '((0 . "VIEWPORT")) to select then activate it.

64bit AutoCAD Map & Civil 3D 2023
Architecture Engineering & Construction Collection
2023
Windows 10 Dell i7-12850HX 2.1 Ghz 12GB NVIDIA RTX A3000 12GB Graphics Adapter
0 Likes
Message 5 of 5

Sea-Haven
Mentor
Mentor

Trying to find it had similar problem picking correct viewport, when you make the viewports you can get then back as a VL variable and set current using a VL-item with correct number. Easy to work out how many. Will keep looking. I think removed from problem that I was trying to solve why I can not find.

0 Likes