Detect if running inside Dynamo Player

Our Speckle Dynamo plugin requires the user to click a button to work, but some folks are asking to be able to run it from Dynamo Player as well.

Is there a way we can detect from our C# node if the node is running from Dynamo Player or from the Dynamo UI?

If so we’d be able to automatically “Receive” without user input.
Note: the auto receive option is only triggered when changes are detected in the Speckle stream, so not valid for this use case.

4 Likes

Hi @teocomi, long time no chat! @Michael_Kirschner2 is asking the Player team now and will get back to you :raised_hands:

1 Like

I’m actually the one who most recently brought this up on the Speckle forums. I don’t know if it would be the same fix, but we’d also want this to work when running in GD as well. Potentially with the use of the Gate node if possible. This goes for both sending and receiving.

3 Likes

FYI @craig.long @LilliSmith

1 Like

Thanks @solamour !
Grat to be hanging here again :smiley:

1 Like

I’m not sure there is a great solution - but I can think of funny brittle workarounds, so I’ll share them down with the disclaimer that they are not suggestions from the player team, just my rambling.

  1. walk the stack to see who called run - is it the player? "Stack Walking" in the .NET Runtime · Performance is a Feature!
  2. check if a particular module is loaded, if it is maybe GD or Player is active - this will probably not work.
  3. check if the DynamoView is visible, if it is, you’re probably not in Player or GD.
  4. check the current executing application location -

combining all of these you could probably make a pretty good guess, though it seems like a useful API and should be added to core.

4 Likes

@teocomi it is possible to identify the fact that the graph is running in headless mode.
We added some new API some time ago DynamoModel.DynamoModelState so you can check for StartedUiless.
In theory that could be some other Revit add-in that is executing the graph not necessarily DynamoPlayer. But maybe that’s even better ? If that’s not good enough “Stack Walking” should do it as Mike described above.

7 Likes

Sweet, StartedUiless is exactly what we need :slight_smile:
Thanks for the help!

Unfortunately it’s only available from Dynamo 2.13 onwards which I believe is only supported by Revit 2022 and up… So we might have to create a dedicated node just for this use case.

PS
Is there an updated compatibility table like this?

1 Like

@teocomi the Dynamo Primer has been updated here: The Revit Connection - Dynamo!

@teocomi FYI: Revit 2022.1.3 uses Dynamo 2.12.1. You need to use Revit 2023 to use Dynamo 2.13

1 Like