Hi everyone,
I’m working on a python script that adds named views to the document by receiving an input from the query Viewports node in Rhino 8.
I am using the new Rhino 8 viewport nodes to create orthographic and axonometric views of referenced objects in GH.
I have all the view set as I would like them but struggling to get the script to add them to the doc as expected.
One problem is my script isn’t adding the full set of views to the list to be baked (I think the flaw is in my for loop under def main.
Another problem is the script is not respecting the camera positions/extents/or projection type. It simply creates whatever view is current in the active viewport.
Any help or leads is greatly appreciated,
Thank you!
Graph Space:
Current Method (Manual):
Right click on View node and “Bake”
Desired Result (Automated):
Current Script:
import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc
dm = Rhino.Display.DisplayModeDescription.FindByName("Rendered") # Specify the display mode
sc.doc = Rhino.RhinoDoc.ActiveDoc
# Define the function that creates a named view
def create_named_view(view_name, view):
view.Viewport.DisplayMode = dm # Set the display mode of the view (optional)
Rhino.RhinoDoc.ActiveDoc.NamedViews.Restore(view_name, view.ActiveViewportID) # Create the named view
# Define the main script
def main(view_list, activate):
if activate:
named_views = Rhino.RhinoDoc.ActiveDoc.NamedViews
for view_name in view_list:
print view_name
rs.AddNamedView(view_name)
print "Added view: "
# Provide input parameters here
view_list = Views # List of view names to check
activate = Activate # Activate the script (True) or deactivate it (False)
print view_list
#print activate
# Call the main script
main(view_list, activate)
sc.doc = ghdoc
1 post - 1 participant