Get Current dynamo file path

Hi I would like to get the current working dynamo dyn file path (via a native or python node). Is this possible? Thanks.

1 Like

I tried a few weeks ago and couldn’t find anything. Maybe someone else will have better luck.

Just checking…you want the current dyn thats being run? I may be able to do this using python…i will post it later

yes exactly! my main reason is i usually write python in a seperate file, and the dynamo is just literally a python node that reads an external file. so it will be easier for me to package up the dyn and py file for other users if dyn can know where it lives.

Hi just tried some of my python codes regarding this subject but unfortunately its only returning revit filepath as python cannot get the dynamo process running as its an add on to revit. Sorry…there are other ways though i just checked in the forum and apparently using dynamo logs can do it but its not the best solution but useful. Check it out

That’s right, I forgot about the log files. They do work for pulling the “current” file but like @4bimfercesp said they’re unreliable. It works in a pinch though.

The forum post in question:

I saw this post. Unfortunately, I do not want the need to save the dyn file before checking the log, defeats the purpose of me trying to externalize a script, and use the dyn script to read that path relatively.

Have a look at the dynamo API as there may be something there(i have not looked)?

Good idea @Brendan_Cassidy. Looks like this might do the trick:

Oh seems interesting, in ironpython how would one add this api?

Good find @Brendan_Cassidy and @jacob.small!
Any idea on how to add the necessary reference or library? I’m not sure how to call these members.

1 Like

I am not sure and maybe someone else could help with that as i have not tried it yet.

My gut feeling is that you just either import then usual dynamo services etc into dynamo but if they do not include the right things you could import the dll’s into the python script.

I am able to access these methods, but as their abstract classes. This is done as such

import clr

import Dynamo.Graph.Workspaces as dyn

OUT = dyn

Anyone know how to get the current Dynamo Workspace instance (WorkspaceModel Instance)

1 Like

Yeah, I tried this already out of curiosity but I only get a ReflectedProperty as I drill down. For instance…

import clr
from Dynamo import *

model = Graph.Workspaces.WorkspaceModel

name = model.Name

OUT = name


The same with the following code…

import clr
from Dynamo import *

wkSpace = Models.DynamoModel.CurrentWorkspace

OUT = wkSpace

Not sure if there is actually a way to do it in the Python IDE (and definitely not how I was trying), but I don’t fully understand the Dynamo API, a bit of a black box for me. Perhaps @Andreas_Dieckmann @Konrad_K_Sobon or @Thomas_Mahon might have inkling.


Hi @Daniel_Woodcock1 I’ve not looked at the DynamoCore library in any detail tbh, however WorkspaceModel is an abstract class that cant be instantiated. Instead WorkspaceInfo should be used and instatianted through its default constructor to avoid the runtime output from the Python node.

That said, this class appears to return null regardless of which properties are accessed. I’m not sure if these methods are only available in the CLI. @Michael_Kirschner2 @Aparajit_Pratap can maybe shed some more light on this?


Fwiw I posted a feature request for this on GitHub a couple of weeks ago:

The only way its possible right now is to save the graph and read the log as @Andreas_Dieckmann said in his post.


Hi @Kulkul,

I have replicated @Andreas_Dieckmann’s Python script but I am obtaining an error in line 22. As I do not know Python, I am unable to fix or understand the issue. Could you please help me with that?

I also wanted to add the full file path location to be extracted, but, again, my knowledge of Python is very limited. Could you please help me out modifying the attached file pointing out the changes to me?

I thank you beforehand for your help and attention.

Kind regards, Haley

GetCurrentDynamoFilePath.dyn (11.9 KB)

Hi Haley…

Hows things?

I think you have extra parenthesis on line 22

latest_file = max((all_log_files), key=os.path.getctime)

On @Kulkul screen shot its only

latest_file = max(all_log_files, key=os.path.getctime)

have you tried that already?