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.
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 clr.AddReference("RevitNodes") import Revit clr.ImportExtensions(Revit.GeometryConversion) from Revit.Elements import * clr.AddReference('System') from System.Collections.Generic import * clr.AddReference('RevitAPI') from Autodesk.Revit.DB import * clr.AddReference('RevitServices') 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) uiapp.ActiveUIDocument.RequestViewChange(myView) #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.
@Nick_Boyts, I would imagine a simple modification, but maybe not. What would need to be done to the script to do the opposite and close a view instead?
@Nick_Boyts, is this something simple you could help with or not?
Check out the last post here: https://forums.autodesk.com/t5/revit-api-forum/close-open-views/td-p/3743092
That should get you started.
If that doesn’t work out best to start a new thread as this is 2+ years old and already has a solution. Please link back here and to the other thread Nick noted, and any other relevant threads you have stumbled across.
can this be adapted to open a sheet instead of a view?
@vanman, have you tried it?
Or course haha. But I’m not sure how to change it for a sheet view then a view. Says expected view got list. Maybe I’ll have a hunt through the api. Although I’m not very good at python, it’s really stab in the dark stuff. I tagged you in my other post
It’s expecting a single View and you’re supplying a list. It works with Sheets (they are views) but you need to make it work with a list. You can either change the python code to accept lists or you can pack it in a custom node and use lacing. The forums cover both options extensively.