Hi, I’m trying to get the name of the detail view object of the active viewport on a layout.
To clarify, I’m not talking about pageview.ActiveViewport.Name. Rather, I’m trying to get the name attribute of the detail view geometry object of the active viewport.
Thank you!
Carl
Hi @carlRTC,
a layout page can have multiple detail views from which only one can be active at a time. Below python script prints detail.Viewport.Name
, detail.IsActive
state and detail.Name
for all detailview objects of all pages.
import Rhino
import scriptcontext
def DoSomething():
# get all page views
page_views = scriptcontext.doc.Views.GetPageViews()
if page_views.Count == 0: return
# iterate page views
for pv in page_views:
# get detail views for this page view
detail_views = pv.GetDetailViews()
# list page name and detail count
print "'{}' has {} details:".format(pv.PageName, detail_views.Count)
# list viewport name, active state and object name
for dv in detail_views:
msg = " Viewport.Name {} IsActive: {} ObjectName={}"
print msg.format(dv.Viewport.Name, dv.IsActive, dv.Name)
DoSomething()
you might check out other properties of detailview objects here
_
c.
Hi, Clement, thanks for the reply.
That’s interesting … the ActiveVeiwport doesn’t inherently know which detail view it’s currently in. So I cycle through all the page’s detail views until I find the active one. Ok, good to know.
Thank you!
Carl