I would like to replicate the functionality described in this post, but in native pyrevit / revit api. Here’s what I have so far:
from pyrevit import forms
from pyrevit import revit
selected_views = forms.select_views(title='Select Views to Reassign Parent View',use_selection=True)
if selected_views:
parent_view = forms.select_views(title='Select New Parent View',multiple=False)
if parent_view:
missed = []
with revit.Transaction('Set Parent View'):
for v in selected_views:
try:
v.LookupParameter('Parent View').Set(parent_view.Id)
except Exception as err:
print(err)
missed.append(v.Name)
if missed:
forms.alert('Could not assign parent to the following views. \n{}'.format(missed))
This was just a quick try. Doesn’t work - should have guessed that!
I’m not sure how that magical SetParameterByName node works and it doesn’t seem to have a parallel in the API. Is this sort of thing not possible at the moment or just far more complicated than I realized? The Autodesk forum post makes it seem soo easy.
Note, I would just use the Dynamo script (and still might) but my coworkers aren’t used to the Dynamo UI - though it’s definitely gotten better in recent releases!