Current directory of Dynamo file

Hi all,

I’m trying to figure out a way to get the directory of my currently open Dynamo file as a node output. The reason is, that I want to create a general method for saving Dynamo data outputs in the same folder as my Dynamo files. Does anyone have a suggestion on how to do this?

Thanks in advance!

I think @john_pierson made a node for this and there is one in the springs package… Here is another thread that asks the same question…

1 Like

If your scripts are generally run from dynamo in revit then you could use a modified version of this python code.

Updated Code to get full file path:
“”"
DYNAMOAPI: GET CURRENT File Path
“”"
author = ‘Brendan Cassidy’
twitter = ‘@Brencass86
github = ‘@brencass
version = ‘1.0.0’
“”"
Using reflection we are able to obtain the current Dynamo instance from the Revit instance.
“”"
# we need to import the common language runtime to be able to interact with Dynamo & Revit

# Importing Reference Modules
# CLR ( Common Language Runtime Module )
import clr
# Adding the DynamoRevitDS.dll module to work with the Dynamo API
clr.AddReference('DynamoRevitDS')
import Dynamo 

# access to the current Dynamo instance and workspace
dynamoRevit = Dynamo.Applications.DynamoRevit()
currentWorkspace = dynamoRevit.RevitDynamoModel.CurrentWorkspace

OUT=currentWorkspace.FileName
6 Likes

Thanks!

Thanks! I’ll try it out :slight_smile: