Call View to Open



Looking for a way to open a view before running the rest of the definition. This way i can view what is going on in that view.

Open View from Viewport on Sheet

I’ve gotten around this in the past by using stuff on the active view only, or putting in a "is active view 3D (or whatever) and popping a message asking them to set the view to the correct type if not.


I think I actually just figured this out…

import clr
import Revit
from Revit.Elements import *
from System.Collections.Generic import *
from Autodesk.Revit.DB import *
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
#The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
myView = UnwrapElement(IN[0])


#Assign your output to the OUT variable.
OUT = "ActiveView set to: " + myView.Name



Can you show an example of yours working? I cant get it to work on a newly created Drafting view that was just created by Dynamo. I can get it to work with the get current view node.


If you’re creating the view in the same graph you’ll have to put a Transaction.End node between your newly created view and the python node.


OK,Set Active View.dyn (15.1 KB)
I had bake with a Passthrough instead of Transaction end. Still not working, here is my definition.


Can you show a preview of your whole graph? I don’t have a few of those nodes so I’m not sure what they’re doing.

Edit: I think you’re taking an extra step. DraftingView.ByName outputs the view you just created. There’s no need to create the view then get the view with its name. Just take the Transaction.End output directly to the Python node.

Either way, the issue is because you’re sending a list to the Python node when it expects a singleton.


Awesome It works now. Here is the new graph.