【Revit API】梁的净高分析
程序员文章站
2022-04-28 09:52:17
原理就是,先从梁的LocationCurve上取点,然后向板的上表面投影。如果有投影点,再从投影点(板上)向梁的底面投影,这时候如果有投影点的话就能得到距离了。 运用该分析的第一条件是梁是在板的上方,勿忘哈! LocationCurve的延伸: 在Curve上按PointRange选取点位: 获取距 ......
原理就是,先从梁的LocationCurve上取点,然后向板的上表面投影。如果有投影点,再从投影点(板上)向梁的底面投影,这时候如果有投影点的话就能得到距离了。
运用该分析的第一条件是梁是在板的上方,勿忘哈!
var beamBottomFaces = FaceUtils.GetBottomFaces(beam); //这个方法是自己封装的 if (null != beamBottomFaces && beamBottomFaces.Any()) { var beamLocationCurve = beam.Location as LocationCurve; var beamCurve = beamLocationCurve.Curve; if (beamCurve != null) { if (beamCurve is Line) { beamCurve = GetExtLocationCurve(beamCurve); //如果LocationCurve是Line,最好做个延伸算法来延长,不然有些梁因为扣减的话,locationCurve容易缺少一部分 } var beamPoints = GetPoints(beamCurve, pointRange); //pointRange是取点间隔 if (beamPoints != null && beamPoints.Any()) { var floorDataList = GetBeamFloorsPairCore(beamBottomFaces, beamPoints, floors); //floors为建筑板 } } }
LocationCurve的延伸:
private Curve GetExtLocationCurve(Curve curve) { XYZ dir0 = XYZ.Zero; XYZ dir1 = XYZ.Zero; if (curve is Line) { dir0 = (curve as Line).Direction.Negate(); dir1 = (curve as Line).Direction; } Curve extCurve = Line.CreateBound(curve.GetEndPoint(0) + 1E3 * dir0, curve.GetEndPoint(1) + 1E3 * dir1); return extCurve; }
在Curve上按PointRange选取点位:
private List<XYZ> GetPoints(Curve curve, double pointRange) { var points = new List<XYZ>(); var beamLength = curve.Length; var pointsNumber = beamLength % pointRange == 0 ? ((beamLength / pointRange) - 1) : Math.Floor((beamLength / pointRange)); for(var i = 1; i <= pointsNumber; i++) { var point = curve.Evaluate(pointRange * i, false); points.Add(point); } return points; }
获取距离:
private List<KeyValuePair<Element, List<KeyValuePair<XYZ, double>>>> GetBeamFloorsPairCore(List<PlanarFace> beamBottomFaces, IEnumerable<XYZ> beamPoints, List<Element> floors) { var floorDataList = new List<KeyValuePair<Element, List<KeyValuePair<XYZ, double>>>>(); //寻找每一块结构梁下的板 foreach (var floor in constructionFloors) { //获取该板的最上点坐标 var floorTopFaces = FaceUtils.GetTopFaces(floor); if (null != floorTopFaces && floorTopFaces.Any()) { var defaultFloorOriginZ = floorTopFaces.FirstOrDefault().Origin.Z; foreach (var tf in floorTopFaces) { var originZ = tf.Origin.Z; if (defaultFloorOriginZ <= originZ) { defaultFloorOriginZ = originZ; } } var defaultBeamOriginZ = beamBottomFaces.FirstOrDefault().Origin.Z; foreach (var bf in beamBottomFaces) { var originZ = bf.Origin.Z; if (defaultBeamOriginZ >= originZ) { defaultBeamOriginZ = originZ; } } //板在梁下面 var isLower = defaultFloorOriginZ < defaultBeamOriginZ; if (isLower) { var datalist = new List<KeyValuePair<XYZ, double>>(); //梁上一点能投影到板上 foreach (var point in beamPoints) { foreach (var tf in floorTopFaces) { var isProject = tf.Project(point); if (null != isProject) { //投影到板上点的坐标 var projectPoint = isProject.XYZPoint; //投影点到梁上点的距离 foreach (var bf in beamBottomFaces) { var bp = bf.Project(projectPoint); if (null != bp) { var distance = bp.Distance; distance = UnitUtils.ConvertFromInternalUnits(distance, DisplayUnitType.DUT_MILLIMETERS); distance = Math.Floor(distance); var pointAndDistance = new KeyValuePair<XYZ, double>(projectPoint, distance); datalist.Add(pointAndDistance); break; } } } } } if (datalist != null && datalist.Any()) { var floorAndData = new KeyValuePair<Element, List<KeyValuePair<XYZ, double>>>(floor, datalist); floorDataList.Add(floorAndData); } } } } return floorDataList; }
上一篇: linux总结及常用命令
推荐阅读
-
Java日期时间API系列8-----Jdk8中java.time包中的新的日期时间API类的LocalDate源码分析
-
【Revit API】FamilyInstance、FamilySymbol、Family的寻找关系
-
荐 Java中常见的数据结构API的特点及分析
-
【Revit API】改变填充区域的填充样式
-
在禅道项目管理软件v9.8.3的一个API调用bug的排错中使用到的一些工具和分析方法
-
Revit API之BoundingBoxXYZ的用法和剖面框(Section Box)
-
【Revit API】梁的净高分析
-
.NetCore使用Swagger+API多版本控制的流程分析
-
具体介绍thinkPHP5.0框架API优化后的友好性分析
-
慕课网项目:Java高并发秒杀API的学习笔记(三)Web层分析