Looking to Open Newly Created Schedule View à la fin

I have created a script that creates and then builds a Schedule. The trouble I am having is: how do you tell Dynamo to open a schedule view by feeding the node a scheduleView (Revit.Elements.Views.ScheduleView)? I’ve tried using the “Show Element” node from GeniusLoci (I’ll paste the Python code below) but Revit then tells me there is “No good view could be found.”

Has anyone been able to ‘call up’ a schedule view, with a node that is fed a Revit.Elements.Views.ScheduleView element/input?

import clr
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import ElementId

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

import System
from System.Collections.Generic import List

elements = UnwrapElement(IN[0]) if isinstance(IN[0],list) else [UnwrapElement(IN[0])]

elemId = List[ElementId](x.Id for x in elements)
uidoc.ShowElements(elemId)
uidoc.Selection.SetElementIds(elemId)	
OUT = IN[0]

The active view can only be changed when there is no active transaction, as noted in the remarks here: ActiveView Property

Because Dynamo runs a transaction for each, I am not sure if this is possible in the context of Dynamo.

I can confirm that this is not possible within a single script, you’ll have to split it up into multiple, where one ends with changing the active view.

Thank you both for verifying, I’ll have to ignore this feature in my subsequent scripts.

You can actually still do this if you use the RequestViewChange() method instead. You just need to use a transaction node to ensure the view is available first.

uiapp.ActiveUIDocument.RequestViewChange(myView)

1 Like