Pause graph for user Revit command

Is it possible to run a graph and have it pause after running part of it, then the user uses the “wt” command to tile windows, then continue running the graph.

I have had a lot of help with this package from other posts and would like to thank those that have contributed in those posts. So much help!

What this package is doing is selecting all views in revit and filters out nulls. It then filters out views that are not placed on certain sheets with specific criteria. It then runs Python code (thanks to @Nick_Boyts and @john_pierson ). The code opens up all the filtered views. At this point it would be nice to pause the script to hit the “wt” command so to tile all the windows and then proceed with the dynamo script. After tiling the windows it toggles the annotation crop on or off then back off or on depending if the view already had it on or off.

The reason I need to toggle on and off or off then on the annotation crop is to fix keynote bubble numbers that disappear. One of the easiest and only ways to fix it is to toggle the annotation crop. The view also needs to be open and can’t be in done in the background, hence I open up all views that contain a keynote.

Toggle on_off Annotation Boundaries.dyn (86.7 KB)

Thank you

Just for clarity, a package typically refers to a shared group of custom nodes. You’re talking about a graph.

Why exactly does the view have to be open in order to make changes? First, I’d say this is not an efficient way to run your code as it just means that you could have dozens if not hundreds of views open in Revit at once and likely crash the application. (Especially if you have them all tiled.)

You specifically say it can’t be done in the background, but there are no API commands (that I can think of) that require an open view. There are some nodes that run on the active view, but that’s usually for simplicity and not due to a restriction in the code. Even if the case is to use the active view, active does not just mean open, and would require you to activate each view one at a time. Can you give us some more information? Background is almost certainly the way to go.

Yep you’re right about the clarification and thank you. I meant graph.

I am not sure why the views have to be open and tiled, it just does in order for the fix to work. The view doesn’t need to be active, just open and tiled. It doesn’t make any sense to me either. I have run many tests and the only way it works is if you have the view open. The windows can’t be tabbed either; they must be tiled. Currently when I run my graph without the python code, it fixes the bubbles as long as the views are open. I can run the graph without the views open and it doesn’t fix the issue. But currently I have to open all the views myself and then tile them and then run dynamo. This new graph would open all those views for me which would save sooooo much time! Let me know if you need any further explanation as to my process in this and the tests I’ve done. Here is reddit post about the issue: https://www.reddit.com/r/Revit/comments/chriew/user_keynotes_and_vanishing_numbers/

The most views in a project, to date, that we need is about 75 and I’ve run my previous dynamo with all 75 windows tiled just fine. It takes a while but it’s better than opening each view individually. (Unless I create my dynamo graph to open them individually of course)

I could create a graph that opens one view at a time and toggles the annotation crop and then close the view; but I was just working with my current graph and decided it wasn’t worth starting from scratch and using what I already have…I may be wrong with this approach.

My guess is that your API call requires refreshing the view in order to force an update to the correct value via ensuring they were already calculated, which may not happen unless specifically called for prior to execution. By opening and displaying the views will ensure that all content is refreshed. I am not checking the Reddit thread though (I see enough stuff here and other places - no need to pile on another back channel) so I cannot confirm the issue. There may be way to force a refresh without tiling the view, but I can’t confirm without the code base. Feel feee to post over the relevant info.

As far as “can Dynamo activate or interact with the UI mid way though a run?”, the short answer is ‘no’, and the longer answer is ‘not really because of the way Dynamo (and many similar applications) handle transactions, where effectively there is only one open transaction at a time, and the UI cannot switch views or take new input while a transaction is open, but…’

The trailing but there is because there are any possible ways to force things to update. I recently discovered on such issue around setting and then pulling the active view’s phase in that you can set the value, then roll back a sub-transaction which does nothing, and then when you query or interact with the view’s phase in a subsequent transaction the phase will report the value which was set.

I imagine there is a way to force the recalculation/refresh in your case which doesn’t require displaying the data (a similar calculation has to be performed to print multiple sheets to PDF). You could also try creating a sheet with laughing out loud the views on it, and have Revit check if that sheet is active prior to pulling the data, then returning a UI to tell the users to rerun the graph. Or you could set said sheet to the default view for the project, open the model in the background, edit the values, sync the background document, close the background document and then check the main document. Or have it loop over the list of views in the background process. Or call Forge to do the work there. Or break the graph into two separite graphs: one to set up and tile the views and one to execute the change. Or…

None of the above is tested, so they may or may not work, but they all may sidestep the transaction issue and force a refresh via other means. Or they may not and you would have to get creative and apply another alternative solution.

Where there is a strong enough will, there is (usually) a way.

If @jacob.small is right about refreshing the view, then you might be able to get by with setting the view as active before toggling the annotation crop.

uiapp = DocumentManager.Instance.CurrentUIApplication
uiapp.ActiveUIDocument.RequestViewChange(myView)
1 Like