-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathdynamoAPICurrentGraphName.py
More file actions
40 lines (32 loc) · 1.2 KB
/
Copy pathdynamoAPICurrentGraphName.py
File metadata and controls
40 lines (32 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""
DYNAMOAPI: GET CURRENT WORKSPACE NAME
"""
__author__ = 'John Pierson - sixtysecondrevit@gmail.com'
__twitter__ = '@60secondrevit'
__github__ = '@sixtysecondrevit'
__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
# Access current version of dynamo
version=dynamoRevit.RevitDynamoModel.Version
# checks version of dynamo and adjusts output according to version
if version.StartsWith("1."):
# Gets file name which includes full path
filename=currentWorkspace.FileName
# Splits out file path to just file name
OUT=filename.Split("\\")[-1].Replace(".dyn","")
elif version.StartsWith("2."):
OUT=currentWorkspace.Name
else:
OUT="Not supported"