Skip to content

Commit f319bf9

Browse files
committed
1 parent 455232c commit f319bf9

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
using Autodesk.DesignScript.Runtime;
2+
using Autodesk.Revit.DB;
3+
4+
namespace OpenMEPRevit.Element;
5+
6+
public class ImportInstance
7+
{
8+
private ImportInstance()
9+
{
10+
}
11+
/// <summary>
12+
/// Retrieves information about external resources associated with a Revit element.
13+
/// </summary>
14+
/// <param name="importInstance">The Revit element for which external resource information is retrieved.</param>
15+
/// <returns>
16+
/// A dictionary containing information about external resources with keys:
17+
/// - "ModelIdentity": Identity information of the model.
18+
/// - "Path": The path of the external resource.
19+
/// - "PathType": The type of path for the external resource.
20+
/// </returns>
21+
/// <example>
22+
/// ![](../OpenMEPPage/element/dyn/pic/ImportInstance.GetPath.png)
23+
/// </example>
24+
[MultiReturn("ModelIdentity","Path","PathType")]
25+
public static Dictionary<string, object?> GetPath(global::Revit.Elements.Element importInstance)
26+
{
27+
Autodesk.Revit.DB.Element internalElement = importInstance.InternalElement;
28+
Dictionary<string,object?> result = new Dictionary<string, object?>();
29+
if (internalElement is Autodesk.Revit.DB.ImportInstance import)
30+
{
31+
ElementId elementId = import.GetTypeId();
32+
ElementType? elementType = import.Document.GetElement(elementId) as Autodesk.Revit.DB.ElementType;
33+
IDictionary<ExternalResourceType,ExternalResourceReference> externalResourceReferences = elementType.GetExternalResourceReferences();
34+
foreach (KeyValuePair<ExternalResourceType, ExternalResourceReference> externalResourceReference in externalResourceReferences)
35+
{
36+
IDictionary<string,string> information = externalResourceReference.Value.GetReferenceInformation();
37+
foreach (KeyValuePair<string, string> keyValuePair in information)
38+
{
39+
result.Add(keyValuePair.Key,keyValuePair.Value);
40+
}
41+
}
42+
}
43+
else
44+
{
45+
result.Add("ModelIdentity",null);
46+
result.Add("Path",null);
47+
result.Add("PathType",null);
48+
}
49+
return result;
50+
}
51+
52+
}
26.7 KB
Loading

0 commit comments

Comments
 (0)