Hello,
I wonder if there is any method for closing viewports? I have some scripts for cleaning and managing documents generated from some other models, like removing unwanted entities and so on. And also I feel cravings for having one and single viewport in some of these documents… Is it possible, with Python or Rhinoscript? I see there are lots of methods for handling views, but none of them seems to close a viewport… And I see there is a bit messing with views and viewports, I think it could be handled a bit more people friendly
I still use Rhino 6, but I am almost ready to move to Rhino 8.
import scriptcontext
def CloseFloatingViewports():
for view in scriptcontext.doc.Views.GetStandardRhinoViews():
if view.Floating == True: view.Close()
if __name__=="__main__":
CloseFloatingViewports()
Thank you very much, @clement
This almost works, the only drawback is that your script is closing floating viewports only… Maybe you know how to convert a regular one to the floating one?
Cheers, Jaro
Hi @jerry.bakowski, there should be no difference if the view is floating or not. Below is an example which closes all perspective views:
import scriptcontext
def ClosePerspectiveViewports():
for view in scriptcontext.doc.Views.GetStandardRhinoViews():
if view.ActiveViewport.IsPerspectiveProjection:
view.Close()
if __name__=="__main__":
ClosePerspectiveViewports()
What you want to do with your viewport(s) in order to clean them up ? To get eg. back to the default 4 View layout you could use: