Breaking nodes

For some reason I keep getting this.
If I replace the node it works again for a while.
Or if I run it unplugged and then run it again it usually works.

This is really irritating though. Any idea why/ how I can prevent it?

image

Maybe the active view is the project browser? This is an ongoing gripe I have with the Revit API… technically if you last clicked on the browser, it will be the active view.

5 Likes

That’s moose!
I’ll try to experiment and see if not clicking the project browser helps!
Thanks :slight_smile:

1 Like

Looks like it is this.
That’s super annoying!

1 Like

Yep it’s a bit… there are some workarounds in C# such as storing the last activated view and referencing that if the active view is a browser. Not as many options in Dynamo.

I’ve not encountered it in C# yet but good to know in case something weird does happen :smiley:

1 Like

You could ask for the active, and if it is the project browser you could get the UIDocument, then use that to get the UIViews, and then cycle through those (I think they are returned in sequential order based on last active status, but I could be wrong).

You could also try using the ActiveGraphicalView instead of the ActiveView as I think I recall that filter out the project browser (but also has bigger issues with some other stuff like sheets and schedules).

3 Likes

Almost feels like the activeview node should implement such an approach given most users wouldn’t understand browsers are views.

3 Likes

If I recall doing option 2 would break other stuff too, such as sheets, schedules, etc… Doing option 1 risks ‘getting it wrong’ as well due to ordered views.

IMO a popup stating ‘You’re a moose for trying to run something on the active view while in the project browser. Activate a real view and then try again.’ would work better.

1 Like

Great catch @GavinCrump ! It seems like the active view node could be modified to get the openUIView instead. Which would eliminate the project browser, I think.

3 Likes

Yeah - the issue with this if I recall is that some version of Revit doesn’t return them in the ‘active’ order, but in the ‘opened’ order… Really should be an easier way to do this, but the available APIs make this difficult to manage… perhaps a extension similar to element binding to track view change states so the last active view would always be known?

I know both Dynamo for Civil 3D and Dynamo for Revit do this for document changes, so tracking view changes and keeping a Reference to the last UI view seems doable. Not sure if it would be performant though…

FYI @solamour @achintya_bhat @emrullah.yildiz

3 Likes

Using UIDocument.ActiveGraphicalView works in this case (as suggested here). Looking into proposing a fix now.

For now, Rhythm has a node that does it.
20250115-activeViewFix

There would of course need to be some tests for if a linked document is fed into the node or something, but I believe LinkedDocuments have their own wrappers?
Actually, there is no such a thing as an active view from a linked document or background opened document. lol. :no_mouth:

2 Likes