Autodesk.Revit.DB.ReferenceArrayArrayIterator是Revit API中的一个类,用于遍历ReferenceArrayArray对象,即由多个ReferenceArray组成的数组。
Autodesk.Revit.DB.ReferenceArrayArrayIterator主要有以下属性:
Autodesk.Revit.DB.ReferenceArrayArrayIterator主要有以下方法:
以下示例演示了如何使用Autodesk.Revit.DB.ReferenceArrayArrayIterator遍历ReferenceArrayArray对象。
//获取所有房间的边界线
List<ReferenceArray> roomBorders = new List<ReferenceArray>();
FilteredElementCollector collector = new FilteredElementCollector(doc);
ICollection<Element> rooms = collector.OfClass(typeof(SpatialElement)).ToElements();
foreach (Element e in rooms)
{
SpatialElement room = e as SpatialElement;
if (room != null && room.Location != null)
{
Options opt = new Options();
opt.ComputeReferences = true;
GeometryElement geo = room.get_Geometry(opt);
if (geo != null)
{
foreach (GeometryObject obj in geo)
{
Solid solid = obj as Solid;
if (solid != null)
{
FaceArray faces = solid.Faces;
foreach (Face face in faces)
{
if (face != null)
{
EdgeArrayArray edgesArrayArray = face.EdgeLoops;
foreach (EdgeArray edgesArray in edgesArrayArray)
{
ReferenceArray refs = new ReferenceArray();
foreach (Edge edge in edgesArray)
{
refs.Append(edge.Reference);
}
roomBorders.Add(refs);
}
}
}
}
}
}
}
}
//使用Autodesk.Revit.DB.ReferenceArrayArrayIterator遍历ReferenceArrayArray对象
if (roomBorders.Count > 0)
{
Autodesk.Revit.DB.ReferenceArrayArrayIterator it = new Autodesk.Revit.DB.ReferenceArrayArrayIterator(roomBorders);
while (it.MoveNext())
{
Autodesk.Revit.DB.ReferenceArray item = it.Current;
if (item != null)
{
foreach (Autodesk.Revit.DB.Reference r in item)
{
//操作每一个Reference
}
}
}
}
Autodesk.Revit.DB.ReferenceArrayArrayIterator是一个方便遍历ReferenceArrayArray对象的工具,可以使我们更加高效地处理Revit API中的大量数据。