Wait for revit then get active view


When I have a script let’s say I’m opening up a new 3D window I want to wait till revit finishes the opening of new view, then collect elements from there.
This is not the case right now. Script finishes and dynamo is rushing to next task. As a result I’m having the current view from the view I have opened my 3d window.

Any way to wait till revit finishes and get the active

Can you share your graph, or an overall view of the graph with previews expanded?

It sounds like you need a wait for node or a code block to set the sequence but it’s unclear as I can’t really tell what you’re doing overall.

Lets say you use this script from John to open up a generic 3d and we add something at the end to output.

import clr

import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc =  DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIDocument
app = DocumentManager.Instance.CurrentUIApplication.Application
uiapp = DocumentManager.Instance.CurrentUIApplication

import Revit

from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *

pCmd = RevitCommandId.LookupPostableCommandId(PostableCommand.Default3DView)
msg = "OK"
OUT = uiapp.PostCommand(pCmd),msg

The OK is outputted almost instantly and the 3d view is getting generated as the model is heavy. So if I take the active view in the next step waiting for OK I still get the previous view. I need the newly generated view.

So you’re wiring in a wait for how? Needs an actual graph not just some python script to control data flow the way I was describing.

I really don’t know what to show. This script creates a 3D view then I want to get that view as an output. Right now I can’t find the way to do that as dynamo running to the next node before revit can open the 3d window for me to get the active view.

Post an image of your current dyn creates by the camera export so I can see this in relation to the other nodes. Can’t show you how to connect your dots if I don’t know what dots you have. :slight_smile:

Here you go

So your example function has no input to kick it off? In that case you need to ether make a custom node or call it via design script after the previous node functions. Something like this for Design Script should work:

ViewInput!=“nothing to see here”?
“Any command”:

More likely you have something else that starts the initial selection built into the “any command.” One example would be “all elements of category” where you can build a list of the desired category and the resulting output from the view node and get the category out of the list. Would work like this:

{DesiredCategory, ViewCreationOutput}[0];

I wish I could be more specific for you but you aren’t sharing enough to show you exactly where the trigger point lies.

Try having python return the actual view instead. That way you can check for elements in a specified view instead of active view.