添加项目文件。
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Autodesk.Revit.DB;
|
||||
using KGdev.BI3D.Revit.Common;
|
||||
using KGdev.BI3D.Revit.Common.Models;
|
||||
|
||||
namespace KGdev.BI3D.Revit.Implementations
|
||||
{
|
||||
internal class DefaultLinkedDocumentUtilities : ILinkedDocumentsUtilities
|
||||
{
|
||||
public Element GetElement(Document rootDocument, LinkedElementIdPath path)
|
||||
{
|
||||
Document document = rootDocument;
|
||||
Queue<ElementId> queue = new Queue<ElementId>(path.ElementIds);
|
||||
Element element = null;
|
||||
while (queue.Count > 0)
|
||||
{
|
||||
ElementId elementId = queue.Dequeue();
|
||||
bool flag = queue.Count == 0;
|
||||
if (flag)
|
||||
{
|
||||
element = document.GetElement(elementId);
|
||||
}
|
||||
else
|
||||
{
|
||||
RevitLinkInstance revitLinkInstance =
|
||||
document.GetElement(elementId) as RevitLinkInstance;
|
||||
document = revitLinkInstance.GetLinkDocument();
|
||||
}
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
public IList<LinkedDocumentInformation> GetLinkedDocuments(
|
||||
Document rootDocument,
|
||||
Transform baseTransform,
|
||||
bool includeThis,
|
||||
List<ElementId> passedLinkInstanceIds
|
||||
)
|
||||
{
|
||||
List<LinkedDocumentInformation> list = new List<LinkedDocumentInformation>();
|
||||
if (includeThis)
|
||||
{
|
||||
list.Add(
|
||||
new LinkedDocumentInformation
|
||||
{
|
||||
Document = rootDocument,
|
||||
TransformToRoot = baseTransform,
|
||||
PassedLinkInstanceIds = passedLinkInstanceIds
|
||||
}
|
||||
);
|
||||
}
|
||||
IEnumerable<RevitLinkInstance> enumerable = new FilteredElementCollector(rootDocument)
|
||||
.OfCategory(BuiltInCategory.OST_RvtLinks)
|
||||
.OfClass(typeof(RevitLinkInstance))
|
||||
.Cast<RevitLinkInstance>();
|
||||
foreach (RevitLinkInstance revitLinkInstance in enumerable)
|
||||
{
|
||||
bool flag = !revitLinkInstance.IsValidObject;
|
||||
if (!flag)
|
||||
{
|
||||
Document linkDocument = revitLinkInstance.GetLinkDocument();
|
||||
bool flag2 = linkDocument == null || !linkDocument.IsValidObject;
|
||||
if (!flag2)
|
||||
{
|
||||
Transform transform = baseTransform.Multiply(
|
||||
revitLinkInstance.GetTransform()
|
||||
);
|
||||
List<ElementId> list2 = new List<ElementId>();
|
||||
list2.AddRange(passedLinkInstanceIds);
|
||||
list2.Add(revitLinkInstance.Id);
|
||||
IList<LinkedDocumentInformation> linkedDocuments = this.GetLinkedDocuments(
|
||||
linkDocument,
|
||||
transform,
|
||||
true,
|
||||
list2
|
||||
);
|
||||
list.AddRange(linkedDocuments);
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user