Holo
August 16, 2025, 10:13am
1
Hi, is there a way in Rhino 8 where I can figure out what named views are selected in the Named Views panel?
I am working on a small render script and this would be a cool way to choose frames from.
I found this thread from 2019 that says it isn’t possible, but has anything changed in UI accessibility since then @dale ?
Hi @maito78 ,
There isn’t any way of accessing the panel’s selected named view - sorry.
– Dale
Hi @Holo , since Rhino 8.5 you can do this:
#! python 2
import scriptcontext
def DoSomething():
view_names = scriptcontext.doc.NamedViews.Selection
if not view_names: return
for view_name in view_names:
view_index = scriptcontext.doc.NamedViews.FindByName(view_name)
view_info = scriptcontext.doc.NamedViews.Item[view_index]
print "ViewName: {} >>> view_info: {}".format(view_name, view_info)
DoSomething()
From view_info you can get all kinds of things eg. view_info.Viewport
_
c
Holo
August 18, 2025, 9:37am
3
Thanks, this is really helpful, but do you know why this works in Rhino Python Editor but not in Script Editor? I need it to work with Python 3 to be able to manipulate the bitmaps properly.
@eirannejad maybe this is a question for you?
Hi @Holo , below seems to work with Python 3 in the new script editor:
#! python 3
import scriptcontext
def DoSomething():
view_names = scriptcontext.doc.NamedViews.Selection
if not view_names: return
for view_name in view_names:
view_index = scriptcontext.doc.NamedViews.FindByName(view_name)
view_info = scriptcontext.doc.NamedViews[view_index]
print("ViewName: {} >>> view_info: {}".format(view_name, view_info))
DoSomething()
I have no idea why NamedViews.Item does not exits for the new editor.
_
c.
Holo
August 18, 2025, 7:48pm
5
Amazing, how did you figure that out? Trail and error? Thank you though!
And I find it strange that it works in one editor and not the other, since both import the same scriptcontext library, don’t they?
Hi @Holo , i just thought that if the NamedViews.Item cannot be accessed then it might work as expected using the default indexer. Fun part is that the second code example also works in the old editor. I hope @eirannejad can explain to us the difference.
_
c.
Holo
August 18, 2025, 8:23pm
8
Hi Martin, I don’t understand what you try to show here, can you please explain?
Nothing special. Cool that it also works in Grasshopper.