//单击楼梯面可获取楼梯踢面的类型为Stairs,尝试从Stairs的Geometry中取出 var stairsGeo = stairs.get_Geometry(option); foreach (GeometryObject o in stairsGeo) { if(o is GeometryInstance instance) { //至多两个Solid,如果有一个则代表只有结构或只有建筑,表示此为单一专业文件 if (instance.Symbol.GetType() == typeof(StairsLanding)) { Solid fakeSolid = null; foreach (GeometryObject geometryObject in instance.GetInstanceGeometry()) { if (geometryObject is Solid solid) { if (fakeSolid == null) { fakeSolid = solid; } else { //体积大的为结构部分体积小的为面层部分,此处可随意取用 if (fakeSolid.Volume > solid.Volume) { fakeSolid = solid; } } } }
PlanarFace planarFace = null; foreach (var face in fakeSolid.Faces) { if (face is PlanarFace pf) { var faceNormal = pf.FaceNormal; //踏步的向量必为0,0,±1 if (Math.Abs(faceNormal.X - 0) < 0.01 && Math.Abs(faceNormal.Y - 0) < 0.01 && Math.Abs(faceNormal.Z - 1) < 0.01) { planarFace = pf;
}
} }
map.Add((doc.GetElement(planarFace.Reference) as StairsLanding).BaseElevation, planarFace); } elseif (instance.Symbol.GetType() == typeof(StairsRun)) { Solid fakeSolid = null; foreach (GeometryObject geometryObject in instance.GetInstanceGeometry()) { if (geometryObject is Solid solid) { if (fakeSolid == null) { fakeSolid = solid; } else { if (fakeSolid.Volume > solid.Volume) { fakeSolid = solid; } } } }
var run = doc.GetElement(fakeSolid.Faces.get_Item(0).Reference) as StairsRun; var runTopElevation = run.TopElevation; var runPathLoop = run.GetStairsPath(); //梯段路径一般为一个线段,向量为踢面的方向 Line runPathDir = null; foreach (var curve in runPathLoop) { runPathDir = curve as Line; } var runGeo = run.get_Geometry(option);
var faces = fakeSolid.Faces; //Get All Faces //此处筛选出所有的横向面与纵向面,但是横向面无需使用,暂时留用 //如果梯段的踏步数量无法准确提取可以通过标高判定单个梯段内的踏步数量与高度 PlanarFace referFace1 = null, referFace2 = null, referFace3 = null, referFace4 = null; SelectTargetFaces(faces, runPathDir, out referFace1, out referFace2); SelectTargetFaces(faces, runPathDir, out referFace3, out referFace4, 0);