Thanks @Kulkul, that node indeed works and I’ll use it as a temporary solution.
The node is however closed and the source cannot be viewed.I’m interested in finding out how to do this in a python node using the dynamo API.
The question remains the same. Is it possible to import and use the Dynamo API (link below) in a Dynamo Python node? Im trying “import Dynamo” but the module is not recognized, and I have a really hard time finding any examples of people using the API in a Python node?
I have not tried - you should look at the dynamo source in c# to see how the constructor for WorkspaceModel is used. It should be possible to essentially build a whole new workspaceModel inside your graph. (using python or zero touch)
It would be a fun project to wrap dynamo core into a set of nodes…
Thanks for the tip.
Altough i’m not really looking to access predefined nodes, I would be very interested in where to find the documentation on the import names? More specifically I would like to access DynamoModel to listen in on “RunCompleted”-event among others. Since you know how to import the nodes, do you know where to find information on other possible imports?
If there’s any Dynamo dev listening in on this - Intellisense in the python node would be a really great addition, even in its simplest form.
it will be much easier to do this with a c# zero touch node as you can just reference the dynamo core dlls and get intellisense / inspect them, you can use our nuget packages (search for dynamo visual programming on nuget)
Not really, but I might be able to use them to work around my problem. Thanks for mentioning them!
Thanks for the tip, I’ll try and see if we got any pooled visual studio licences around, and look into it. Unfortunatly I think we’ve outgrown the community version
Just to clarify what I really want to do, I would like to get some metadata about the dynamo-script ‘run’ to pack up in a json-bundle and send to server to track some user data on our scripts internally. I would like to do this using Python in Dynamo (Im not a C# whiz). For instance, I’m interested in logging how long the ‘run’ took and any warnings, errors or crash messages that occured, etc.
I’ve been looking into the dynamo-log file, and while some of the data i’m interested in is in there, there is also so much data there that we don’t want. I figured there should be an easier way to just get the values we’re after using the API rather than parsing the log file.
Alright, so I’ve started looking into the DynamoCore.dll to see how to access the meta data that I want to log to server using Python and some commands Im interesting in using. As stated previously, I’m not a C# whiz…
Im stuck trying to get the CurrentWorkspace and WorkspaceInfo so that I’ll be able to get FileName, HasRunWithoutCrash, RunPeriod etc but also be able to ForceRun() and maybe even listen in on events.
I’m trying this now:
test = Dynamo.Models.DynamoModel.CurrentWorkspace.__get__(???)
But CurrentWorkspace wants a DynamoModel as argument, and I thought that was what I was trying to get by calling it? Feels like I’m running in circles here, very thankful for any pointers!
hmm, take a look at the DynamoServices.dll that might be the most useful.
You won’t be able to use DynamoCore from a python node to look at the current instance of Dynamo - you’d need to basically create a new DynamoModel inside the python engine and invoke it - but that won’t help you monitor your graph.
I think DynamoServices.dll will let you monitor current events, like workspace added, or evaluation complete.
I found a rather lenghty workaround scraping the data of the dynamo logfiles using a python regex.
Anyway, forcing a reevaluation of the script every time the graph is run is still a challange. I’ve been seeing requests for this funcitonality dating back to 2013 but no evidence it’s been fixed yet? Do you (or anyone else) know how to force a python node or a custom node to run every time the the ‘Run’ is pressed?
I’d like to do this without any other third party package dependencies since that would make the script very error-prone as it’s supposed to be distributed.