diff --git a/OpenMEPRevit/Element/ImportInstance.cs b/OpenMEPRevit/Element/ImportInstance.cs new file mode 100644 index 00000000..b2acb43e --- /dev/null +++ b/OpenMEPRevit/Element/ImportInstance.cs @@ -0,0 +1,52 @@ +using Autodesk.DesignScript.Runtime; +using Autodesk.Revit.DB; + +namespace OpenMEPRevit.Element; + +public class ImportInstance +{ + private ImportInstance() + { + } + /// + /// Retrieves information about external resources associated with a Revit element. + /// + /// The Revit element for which external resource information is retrieved. + /// + /// A dictionary containing information about external resources with keys: + /// - "ModelIdentity": Identity information of the model. + /// - "Path": The path of the external resource. + /// - "PathType": The type of path for the external resource. + /// + /// + /// ![](../OpenMEPPage/element/dyn/pic/ImportInstance.GetPath.png) + /// + [MultiReturn("ModelIdentity","Path","PathType")] + public static Dictionary GetPath(global::Revit.Elements.Element importInstance) + { + Autodesk.Revit.DB.Element internalElement = importInstance.InternalElement; + Dictionary result = new Dictionary(); + if (internalElement is Autodesk.Revit.DB.ImportInstance import) + { + ElementId elementId = import.GetTypeId(); + ElementType? elementType = import.Document.GetElement(elementId) as Autodesk.Revit.DB.ElementType; + IDictionary externalResourceReferences = elementType.GetExternalResourceReferences(); + foreach (KeyValuePair externalResourceReference in externalResourceReferences) + { + IDictionary information = externalResourceReference.Value.GetReferenceInformation(); + foreach (KeyValuePair keyValuePair in information) + { + result.Add(keyValuePair.Key,keyValuePair.Value); + } + } + } + else + { + result.Add("ModelIdentity",null); + result.Add("Path",null); + result.Add("PathType",null); + } + return result; + } + +} \ No newline at end of file diff --git a/docs/OpenMEPPage/element/dyn/pic/ImportInstance.GetPath.png b/docs/OpenMEPPage/element/dyn/pic/ImportInstance.GetPath.png new file mode 100644 index 00000000..eb543eb1 Binary files /dev/null and b/docs/OpenMEPPage/element/dyn/pic/ImportInstance.GetPath.png differ