forked from pyrevitlabs/pyRevit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.py
More file actions
50 lines (41 loc) · 1.64 KB
/
Copy pathscript.py
File metadata and controls
50 lines (41 loc) · 1.64 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
41
42
43
44
45
46
47
48
49
50
"""Print the full path to the central model (workshared) or the local model path.
Shift+Click:
Open model file in Explorer, or open BIM360/ACC/Forma Docs project page for cloud models.
"""
#pylint: disable=E0401,invalid-name
from pyrevit import revit, DB, HOST_APP, EXEC_PARAMS
from pyrevit import forms
from pyrevit import script
def _is_cloud_path(model_path):
return bool(getattr(model_path, "CloudPath", None))
def _get_acc_url(model_path):
if HOST_APP.is_newer_than(2026):
regions = list(DB.ModelPathUtils.GetAllCloudRegions())
emea = next((r for r in regions if "EMEA" in str(r)), None)
is_emea = emea is not None and model_path.Region == emea
else:
is_emea = model_path.Region == DB.ModelPathUtils.CloudRegionEMEA
domain = "eu" if is_emea else "com"
if HOST_APP.is_newer_than(2021):
project_id = revit.doc.GetProjectId()
if project_id.startswith("b."):
project_id = project_id[2:]
else:
project_id = str(model_path.GetProjectGUID()).lower()
return "https://acc.autodesk.{}/docs/files/projects/{}".format(domain, project_id)
if revit.doc.IsWorkshared:
model_path = revit.doc.GetWorksharingCentralModelPath()
path_str = DB.ModelPathUtils.ConvertModelPathToUserVisiblePath(model_path)
else:
model_path = None
path_str = revit.doc.PathName
if not path_str:
forms.alert("Project has not been saved.", warn_icon=True)
script.exit()
if EXEC_PARAMS.config_mode:
if model_path and _is_cloud_path(model_path):
script.open_url(_get_acc_url(model_path))
else:
script.show_file_in_explorer(path_str)
else:
print(path_str)