Pyrevit: Customize .dyn execution system to allow GUI from Dynamo scripts

Created on 4 Apr 2019  路  26Comments  路  Source: eirannejad/pyRevit

script.zip

When I place a .dyn File in pyRevit Folder it does work with "little scripts", but when I add some nodes of specific packages it doesn麓t work anymore. For example one of my large scripts uses the following packages:

GeniusLoci v.2019.1.28
Orchid v. 202.3.10.6959
Data-Shapes v.2018.12.1
SteamNodes v.1.2.4
archilab v.2018.0.2
LunchBox v.2018.7.6
Clockwork v.2.1.2
spring nodes v.202.1.1

When starting the script something seems to work, but nothing happens. No popup (Data-Shapes-Package) is showing up. When I try to start the script again it stops directly.

My script connects much local stuff, but the attached little script with some Data-Shapes Nodes does not work, too.

Desktop

  • OS: Windows 8
Benign Bug Misc Compatibility

All 26 comments

@jannisle please upload the file here and not on services that require third-party exe downloaders. Just drag and drop the file in here.

So you are opening a windows form on this dynamo script. The problem is that when pyRevit is requesting Dynamo to run the bundled script, it enables Dynamo Automation mode ("dynAutomation"="True"). This means that Dynamo will end at the end of the script execution therfore no windows.

If the Automation mode is disabled ("dynAutomation"="False"), the script runs normally and the pop up window shows up, but then Dynamo will constantly execute all other dynamo scripts without user request because it is basically still open in memory.

Workaround

Hold CTRL when clicking on the Dynamo bundle button. This opens the dynamo ui and you can hit the run button from there

Solution (Sort of)

  • Go to this c-sharp file: pyrevitlib\pyrevit\loader\basetypes\baseclasses_dyno.cs
  • Edit lines 50 to { "dynAutomation", "False" } and line 52 to { "dynModelShutDown", "True" }

Restart your Revit and test your dynamo scripts again.

(Sort of)

Hey @eirannejad ! What could be the consequences of changing those options?

It had helped to run script with UI. I didn't notice that opened scripts are being executed in background (at least there were no unexpected popups).

But it seems to be slower than using Dynamo player (~3 times slower) and it almost the same time as running it with Ctrl.

But thank you!

pyRevit and Dynamo Player both use the same mechanism to run the Dynamo script. Not sure why it is slower for you but for me the first run is a bit slower and all other runs are very fast.

all other runs are very fast.

Even with "dynModelShutDown", "True" ?

I don't sure, but I can feel the difference - when it's set to True it is slow each run.

But when it's False I do not have the issue with running all the opened scripts in background, I can continue to work with Dynamo as usual and I don't have any issues until now, should I?

First I've changed it like you wrote there:

  • Edit lines 50 to { "dynAutomation", "False" } and line 52 to { "dynModelShutDown", "True" }

But { "dynAutomation", "False" } and { "dynModelShutDown", "False" } also seems to be working, right?

So as I mentioned above this is a "Sort of" solution for now until I properly implement a solution. I have not pushed this change to the code yet since it is not tested.
When I ran a few tests and responded to this thread, I had to set it to True otherwise the window would only pop the first time and not on the later executions. I'll dig deeper into this later when I start working on this issue.

Hi,
Got the same error. Following your method to open the graph with cntrl in dynamo and run it manually it returns the following errror:

Warnung:ElementQueries.OfCategory fehlgeschlagen.
Starting a transaction from an external application running outside of API context is not allowed.

You've certainly already seen that? File (which requires Clockwork for Dynamo 2.x 2.1.0) is attached.
Thank you so much for your precious work.
script.zip

Has this been implemented?

Is this a yes or a no?! ;.) I麓m still very interested in this feature and my user rights don麓t allow any changes for all of my colleagues :(

Hi,
The possibility to combine the data shapes GUI to pyRevit is very interesting and useful. Is there any news about this or have you given up on it?

I have never tested the DataShapes GUI with pyRevit. I typically use WPF and XAML directly for pyRevit tools.

Could you please implement this feature. It would be super-awesome if we could integrate our Dynamo-Scripts into the taskbar. This way we could work with C#, Python and for Quick Test we could use Dynamo to test a workflow first :)

Recent changes in Dynamo engine provides a solution to his. See conversation on #732

Still cannot run Scripts with Custom packages.

Still cannot run Scripts with Custom packages.

For me it did work after:

  • creating bundle.yaml with content:
engine:
  clean: false
  • setting run mode to "Automatic" in Dynamo for the script

So you mean I should create a file named bundle.yaml with the content being just what you had up there and set the script to Automatic in Dynamo?

Done and it worked.. But the script keeps executing for long

@XTDHub How long does it take for Dynamo to run normally by itself? Does it check for updates when starting?

It sure takes a very short time to execute scripts after the first run, but the script keeps executing on its own even after the first run.

Hello,

So I give it a try yesterday. I updated my PyRevit. Set up the PyRevit-master like this:

{"dynAutomation", "False"}
{"dynaModelShutDown", "False"}

I didn't use any "bundle.yaml"

And it worked like a charm! I succeed to run dynamo codes with Datashapes. Only the first run is a bit longer. I don't think the codes excute on their own after since I didn't notice any GUI window (DataShapes) popping up.

Indeed, if I set up {"dynaModelShutDown", "True"}, everything is slower.

Great. Do I need to make anymore adjustments?

Well, just to add the possiblity to have tooltip even with .dyn files :)

You can already do that using the bundle.yaml file. See the pyRevit Bundles on the Wiki

Hello,

So I give it a try yesterday. I updated my PyRevit. Set up the PyRevit-master like this:

{"dynAutomation", "False"}
{"dynaModelShutDown", "False"}

I didn't use any "bundle.yaml"

And it worked like a charm! I succeed to run dynamo codes with Datashapes. Only the first run is a bit longer. I don't think the codes excute on their own after since I didn't notice any GUI window (DataShapes) popping up.

Indeed, if I set up {"dynaModelShutDown", "True"}, everything is slower.

How do I do this? What files do I need to modify?

Also, do I need to set the scripts to Automatic?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kuldeep3618x picture kuldeep3618x  路  4Comments

pihglez picture pihglez  路  4Comments

kuldeep3618x picture kuldeep3618x  路  4Comments

Robbo1234 picture Robbo1234  路  4Comments

TheBIMsider picture TheBIMsider  路  5Comments