Dynamo API in python node?

I’m trying to acces Dynamo API from a dynamo python node but I can’t find any solid documentation on how to import the library and use the classes?

More specifically I would like to retrieve the name and version of the current dynamo file from from Dynamo.Graph.Workspaces.WorkspaceModel (see: http://dynamods.github.io/DynamoAPI/Dynamo_Graph_Workspaces/WorkspaceInfo/#workspaceinfo)

Very thankful for any help on the matter, the name of the library to import would be a great start!



1 Like

Hi @jakob.lilliemarck

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.

Any thoughts?

Hey again,
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?

Dynamo API I would like to use in my Python node:

from DSCore import *

This will give you access to Dynamo nodes in Python. Try using SpringsUI.Graph.FilePath to get the name and Get This Dynamo Version from Bakery to get the current version.

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…

1 Like



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.

I looked into it a while ago. Unfortunately I didn’t have any luck.
Are the nodes I mentioned above what you’re looking for?

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 :confused:

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:

import Dynamo
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.

@jakob.lilliemarck, Like this? (Example is showing the node auto running when a new node is placed. I am outputting current time to show the change.)


How did you do this?

I found out about accessing the Dynamo API in Python thanks to the Open-Source code provided by the great folks at DesignTech.

Here is the thread with the python: