//method to compute rod heights private static void ComputeRodHeights() { try { ReferPoints points = new ReferPoints(); points = Points.FindRodPoints(instancePoint, hostElement); rodLeft = Intersectors.StructureHeight(points.left, doc); rodRight = Intersectors.StructureHeight(points.right, doc); } catch { throw new Exception(); } }
//method to get points on bothsides of the placement points public static ReferPoints FindRodPoints(XYZ instPoint, Element elem) { try { ReferPoints twoPoints = new ReferPoints(); twoPoints.left = null; twoPoints.right = null; Curve eleCurve = ((LocationCurve)elem.Location).Curve; XYZ start = eleCurve.GetEndPoint(0), end = eleCurve.GetEndPoint(1); double eleWidth = 0, eleHeight = 0; if (eleCurve is Line) { Line eleLine = (Line)eleCurve; if (elem is CableTray) { eleWidth = ((CableTray)elem).Width; eleHeight = ((CableTray)elem).Height; } else if (elem is Duct) { eleWidth = ((Duct)elem).Width; eleHeight = ((Duct)elem).Height; } double yAngle = XYZ.BasisY.AngleTo(eleLine.Direction); double x = (eleWidth + 0.00328084 * 25) * Math.Cos(yAngle), y = (eleWidth + 0.00328084 * 25) * Math.Sin(yAngle); if (end.Y > start.Y && end.X > start.X || start.Y > end.Y && start.X > end.X) { twoPoints.left = new XYZ(instPoint.X - x, instPoint.Y + y, instPoint.Z - eleHeight / 2); twoPoints.right = new XYZ(instPoint.X + x, instPoint.Y - y, instPoint.Z - eleHeight / 2); } else if (end.Y < start.Y && end.X > start.X || start.Y < end.Y && start.X > end.X) { twoPoints.right = new XYZ(instPoint.X - x, instPoint.Y + y, instPoint.Z - eleHeight / 2); twoPoints.left = new XYZ(instPoint.X + x, instPoint.Y - y, instPoint.Z - eleHeight / 2); } else if (start.X == end.X) { twoPoints.left = new XYZ(instPoint.X, instPoint.Y + y, instPoint.Z - eleHeight / 2); twoPoints.right = new XYZ(instPoint.X, instPoint.Y - y, instPoint.Z - eleHeight / 2); } else if (start.Y == end.Y) { twoPoints.left = new XYZ(instPoint.X - x, instPoint.Y, instPoint.Z - eleHeight / 2); twoPoints.right = new XYZ(instPoint.X + x, instPoint.Y, instPoint.Z - eleHeight / 2); } } if (twoPoints.left != null && twoPoints.right != null) { return(twoPoints); } return(twoPoints); } catch { throw new Exception(); } }