Last active
April 14, 2022 16:26
-
-
Save chuongmep/aec31589838dc023038b2fc5744df98c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void Action() | |
{ | |
StringBuilder sb = new StringBuilder(); | |
IList<Element> elements = new FilteredElementCollector(DB.Doc).OfClass(typeof(RevitLinkType)).ToElements(); | |
foreach (Element element in elements) | |
{ | |
sb.AppendLine(GetExtFileRefPath(element)); | |
} | |
MessageBox.Show(sb.ToString()); | |
} | |
string GetExtFileRefPath(Element item) | |
{ | |
IDictionary<ExternalResourceType,ExternalResourceReference> resourceReferences = item.GetExternalResourceReferences(); | |
foreach (KeyValuePair<ExternalResourceType,ExternalResourceReference> valuePair in resourceReferences) | |
{ | |
var path = valuePair.Value.InSessionPath; | |
return path; | |
} | |
return string.Empty; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Load the Python Standard and DesignScript Libraries | |
import clr | |
clr.AddReference('RevitAPI') | |
from Autodesk.Revit.DB import * | |
# Import DocumentManager and TransactionManager | |
clr.AddReference("RevitServices") | |
import RevitServices | |
from RevitServices.Persistence import DocumentManager | |
paths = [] | |
def GetExtFileRefPath(item): | |
try : | |
dirRefs = item.GetExternalResourceReferences() | |
for i,v in enumerate(dirRefs): | |
return v.Value.InSessionPath | |
except Exception as e: return e.ToString() | |
doc = DocumentManager.Instance.CurrentDBDocument | |
items = FilteredElementCollector(doc).OfClass(RevitLinkType).ToElements() | |
OUT = [GetExtFileRefPath(x) for x in items] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import clr | |
clr.AddReference('RevitAPI') | |
from Autodesk.Revit.DB import * | |
def GetExtFileRefPath(item): | |
try: return ModelPathUtils.ConvertModelPathToUserVisiblePath(item.GetExternalFileReference().GetAbsolutePath()) | |
except: return None | |
items = UnwrapElement(IN[0]) | |
if isinstance(IN[0], list): OUT = [GetExtFileRefPath(x) for x in items] | |
else: OUT = GetExtFileRefPath(items) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment