UIDocument uidoc =commandData.Application.ActiveUIDocument;
Document doc = uidoc.Document;
Selection sel = uidoc.Selection;
Element selectEle =doc.GetElement(sel.PickObject(ObjectType.Element,"选择构件"));
//几何选项
Options opt = newOptions();
opt.ComputeReferences = true;
opt.View = doc.ActiveView;
//获取几何
GeometryElement geom1 =selectEle.get_Geometry(opt);
foreach(GeometryObject obj in geom1)
{
if(obj is Solid)
{
//未被剪切的实体
Solid solid = obj asSolid;
if (solid!= null)
{
FaceArray faceArray =solid.Faces;
TaskDialog.Show("获取面的个数",faceArray.Size.ToString());
}
}
else
{
//被剪切的实体
GeometryInstancegeometryInstance = obj as GeometryInstance;
GeometryElement geom2 =geometryInstance.SymbolGeometry as GeometryElement;
foreach(GeometryObject obj2 in geom2)
{
Solid solid = obj2 asSolid;
if(solid != null)
{
FaceArray faceArray= solid.Faces;
TaskDialog.Show("获取面的个数", faceArray.Size.ToString());
}
}
}
}
return Result.Succeeded;
Revit二次开发——Geometry
最新推荐文章于 2023-03-28 11:00:50 发布