/// <summary> /// 处理逻辑: /// 首先获取板的分层嵌套轮廓 /// 然后检测线是否与上诉轮廓集合有相交 /// 如果相交则进行线的裁剪处理 /// ( /// 获取所有交点 /// 检测是否包含线的端点 /// 结合交点和端点进行梁的分段处理 /// 返回镂空区间的梁 /// ) /// 没有相交则返回完整的线,交于其他板进行裁剪处理 /// </summary> internal List <Line> Deal(Element beam, Line beamLineZ0, LevelFloor levelFloor) { List <Line> undealedZ0 = new List <Line>(); LevelOutLines leveledOutLines = GetLeveledOutLines(levelFloor); return(undealedZ0); }
/// <summary> /// 添加板 /// </summary> /// <param name="floor"></param> public void Add(Floor floor) { var geometry = floor.get_Geometry(new Options() { View = Document.ActiveView }); var geometryElements = geometry as GeometryElement; LevelOutLines leveledOutLines = new LevelOutLines(); foreach (Solid geometryElement in geometryElements) { var faces = geometryElement.Faces; List <Face> addFaces = new List <Face>(); foreach (Face face in faces) { //矩形面 var planarFace = face as PlanarFace; if (planarFace != null) { if (Model.AlignType == AlignType.BeamTopToFloorTop && planarFace.FaceNormal.Z > 0) { addFaces.Add(face); } else if (Model.AlignType == AlignType.BeamTopToFloorBottom && planarFace.FaceNormal.Z < 0) { addFaces.Add(face); } } //圆面 var cylindricalFace = face as CylindricalFace; if (cylindricalFace != null) { //最外的轮廓面必为矩形 //即如有其他原型作为最外轮廓面的...需重写逻辑,要判断最外轮廓面 //矩形面的最外轮廓可以通过XYZ(0,0,1)取得 } } foreach (var addFace in addFaces.OrderByDescending(c => c.Area)) { leveledOutLines.Add(addFace, Model); } } if (!leveledOutLines.IsValid) { throw new NotImplementedException("添加的板无效,无子轮廓"); } else { LeveledOutLines.Add(leveledOutLines); } }
/// <summary> /// 处理逻辑: /// 首先获取板的分层嵌套轮廓 /// 然后检测线是否与上诉轮廓集合有相交 /// 如果相交则进行线的裁剪处理 /// ( /// 获取所有交点 /// 检测是否包含线的端点 /// 结合交点和端点进行梁的分段处理 /// 返回镂空区间的梁 /// ) /// 没有相交则返回完整的线,交于其他板进行裁剪处理 /// </summary> internal List <Line> Deal(Element beam, Line beamLineZ0, LevelFloor levelFloor) { var beamLine = (beam.Location as LocationCurve).Curve as Line; List <Line> undealedZ0 = new List <Line>(); LevelOutLines leveledOutLines = GetLeveledOutLines(levelFloor); if (leveledOutLines.IsCover(beamLineZ0)) { var seperatePoints = leveledOutLines.GetFitLines(beamLineZ0); var pBeamZ0 = beamLineZ0.GetEndPoint(0); var pBeamZ1 = beamLineZ0.GetEndPoint(1); if (seperatePoints.AdvancedPoints.FirstOrDefault(c => c.Point.VL_XYEqualTo(pBeamZ0)) == null) { seperatePoints.AdvancedPoints.Add(new AdvancedPoint(pBeamZ0, beamLine.Direction, false)); } if (seperatePoints.AdvancedPoints.FirstOrDefault(c => c.Point.VL_XYEqualTo(pBeamZ1)) == null) { seperatePoints.AdvancedPoints.Add(new AdvancedPoint(pBeamZ1, beamLine.Direction, false)); } seperatePoints.AdvancedPoints = new AdvancedPoints(seperatePoints.AdvancedPoints.OrderByDescending(c => c.Point.X).ThenBy(c => c.Point.Y).ToList()); bool isSolid = seperatePoints.AdvancedPoints.First().IsSolid;//点的IsSolid可能是其他分层的记录,需更新为当前分层的最新值 var beamSymbol = (beam as FamilyInstance).Symbol; var beamLevel = Document.GetElement(beam.LevelId) as Level; for (int i = 0; i < seperatePoints.AdvancedPoints.Count - 1; i++) { var sp0 = seperatePoints.AdvancedPoints[i].Point; var sp1 = seperatePoints.AdvancedPoints[i + 1].Point; if (isSolid) { var triangle = leveledOutLines.GetContainer(sp0); if (triangle == null) { throw new NotImplementedException("Container Not Found"); } var fixedSP0 = VLGeometryHelper.GetIntersection(triangle, sp0, new XYZ(0, 0, 1)); triangle = leveledOutLines.GetContainer(sp1); if (triangle == null) { throw new NotImplementedException("Container Not Found"); } var fixedSP1 = VLGeometryHelper.GetIntersection(triangle, sp1, new XYZ(0, 0, 1)); var sectionBeam = Document.Create.NewFamilyInstance(Line.CreateBound(fixedSP0, fixedSP1), beamSymbol, beamLevel, Autodesk.Revit.DB.Structure.StructuralType.Beam); CreatedBeams.Add(sectionBeam); } else { var fixedSP0 = VLGeometryHelper.VL_GetIntersectionOnLine(sp0, pBeamZ0, beamLineZ0.Direction); var fixedSP1 = VLGeometryHelper.VL_GetIntersectionOnLine(sp1, pBeamZ0, beamLineZ0.Direction); undealedZ0.Add(Line.CreateBound(fixedSP0, fixedSP1)); } isSolid = !isSolid; } //CARE23415 GraphicsDisplayerManager.Display(seperatePoints); } else { undealedZ0.Add(beamLineZ0); } return(undealedZ0); }
/// <summary> /// 轮廓嵌套分层 /// </summary> /// <param name="levelFloor"></param> /// <returns></returns> public LevelOutLines GetLeveledOutLines(LevelFloor levelFloor) { var leveledOutLines = new LevelOutLines(); var option = new Options() { View = Document.ActiveView }; var geometry = levelFloor.Floor.get_Geometry(option); var geometryElements = geometry as GeometryElement; foreach (Solid geometryElement in geometryElements) { var faces = geometryElement.Faces; List <Face> addFaces = new List <Face>(); foreach (Face face in faces) { //矩形面 var planarFace = face as PlanarFace; if (planarFace != null) { if (Model.AlignType == AlignType.BeamTopToFloorTop && planarFace.FaceNormal.Z > 0) { addFaces.Add(face); } else if (Model.AlignType == AlignType.BeamTopToFloorBottom && planarFace.FaceNormal.Z < 0) { addFaces.Add(face); } } ////圆面 //var cylindricalFace = face as CylindricalFace; //if (cylindricalFace != null) //{ // if (cylindricalFace.Axis.Z > 0) // { // addFaces.Add(cylindricalFace); // } //} } if (addFaces.Count == 0) { double area = -1; RuledFace currentFace = null; foreach (Face face in faces) { //定制面 var ruledFace = face as RuledFace; if (ruledFace != null) { if (area < ruledFace.Area) { area = ruledFace.Area; currentFace = ruledFace; } } } if (currentFace != null) { addFaces.Add(currentFace); } } foreach (var addFace in addFaces.OrderByDescending(c => c.Area)) { leveledOutLines.Add(addFace, Model); } } return(leveledOutLines); }