public void DrawCenterLine(DatabaseToAcad block, string cenlineString) { List<TxCurve> cenlines = this.GetReal_CenterAndBorderCurve(); TxCurve center2 = cenlines[0]; TxCurve borderDn2 = cenlines[1]; TxCurve borderUp2 = cenlines[2]; TxLine borderLeft = new TxLine(borderDn2.StartPoint, borderUp2.StartPoint); TxLine borderRight = new TxLine(borderDn2.EndPoint, borderUp2.EndPoint); //腹板中心线 //Curve centerLine = AcadAssist.TrimCurveGetFront(center2, AcadAssist.GetIntersectionPoint(center2, borderRight)); TxCurve centerLine = AcadAssist.CloneTxCurve(center2); //if (CommonSimbel.lineTypeCENT != Autodesk.AutoCAD.DatabaseServices.ObjectId.Null) centerLine.LinetypeId = CommonSimbel.lineTypeCENT; block.AddCurve(centerLine, CommonSimbel.centLineType, CommonLayer.gz1layer); //中心线长度 double Length = center2.GetDistAtPoint(center2.EndPoint); Point3d textPoint = center2.GetPointAtDist(Length * 0.5); Vector3d textVect = center2.GetFirstDerivative(textPoint); double textAngle = AcadAssist.AngleOnPlan(textVect, center2); if (cenlineString == "") { block.AddText(textPoint, String.Format("梁中心线 L={0}", CommonSimbel.ConvertToDimStr(Length)), block.style.RealTextHeigth * 1000, textAngle, CommonLayer.dimlayer, TxTextHorizontalMode.TextCenter, TxTextVerticalMode.TextBottom); } else { block.AddText(textPoint, String.Format(cenlineString, block.style.RealTextHeigth * 1000, textAngle, CommonLayer.dimlayer, TxTextHorizontalMode.TextCenter, TxTextVerticalMode.TextBottom); } ///中心线起点处角度标注 Point3d anglePoint1 = center2.StartPoint; Vector3d curVectx1 = center2.GetFirstDerivative(anglePoint1).GetNormal(); Vector3d vectHL = borderLeft.EndPoint.GetVectorTo(borderLeft.StartPoint).GetNormal(); block.AddDimAngularFix(anglePoint1, anglePoint1 + curVectx1 * block.style.DimFirstLayer * 1000, anglePoint1 + vectHL * block.style.DimFirstLayer * 1000, block.style.DimFirstLayer * 1000); ///中心线终点处角度标注 Point3d anglePoint2 = center2.EndPoint; Vector3d curVectx2 = center2.GetFirstDerivative(anglePoint2).GetNormal(); Vector3d vectHR = borderRight.EndPoint.GetVectorTo(borderRight.StartPoint).GetNormal(); block.AddDimAngularFix(anglePoint2, anglePoint2 - curVectx2 * block.style.DimFirstLayer * 1000, anglePoint2 + vectHR * block.style.DimFirstLayer * 1000, block.style.DimFirstLayer * 1000); }
public void DrawPM(DatabaseToAcad block) { // 1a 2a // /------------------/-/------------------------/ // / 3 / / 4 / // 1e/------------------/ /------------------------/ 2e // / / // / 3a __/---------/ /---------------\ 8a / // 1d/ /---/ 5a / / 6a \---/ /2d // / / 4a / / 7a / / // 1/--/---------------/ /---------------------/--/ // / / 4b / / 7b / / // 1c/ /---\_ 5b 1a / / 2a 6b_/----/ /2c // / 3b \-------/ /---------------/ 8b / // / / // 1f/------------------/ /------------------------/2f // / 1/ /2 / // /------------------/-/------------------------/ // 1b 2b TxCurve center2 = null; TxCurve borderDn2 = null; TxCurve borderUp2 = null; if (center == null) { center2 = new TxLine(new Point3d(0, 0, 0), new Point3d(L, 0, 0)); } else { center2 = AcadAssist.CloneTxCurve(center); } if (borderDn == null) { borderDn2 = new TxLine(new Point3d(0, 0, 0), new Point3d(L, 0, 0)); } else { borderDn2 = AcadAssist.CloneTxCurve(borderDn); } if (borderUp == null) { borderUp2 = new TxLine(new Point3d(0, 0, 0), new Point3d(L, 0, 0)); } else { borderUp2 = AcadAssist.CloneTxCurve(borderUp); } TxLine borderLeft = new TxLine(borderDn2.StartPoint, borderUp2.StartPoint); TxLine borderRight = new TxLine(borderDn2.EndPoint, borderUp2.EndPoint); Vector3d vectCenterLine = center2.StartPoint.GetVectorTo(center2.EndPoint).GetNormal(); Point3d ctPoint1 = center2.StartPoint; Point3d ctPoint1c = ctPoint1 + vectCenterLine.RotateBy(Math.PI * 0.5 + alf1, Vector3d.ZAxis) * (Wbox * 0.5 - WFbx) / Math.Cos(alf1); Point3d ctPoint1d = ctPoint1 - vectCenterLine.RotateBy(Math.PI * 0.5 + alf1, Vector3d.ZAxis) * (Wbox * 0.5 - WFbx) / Math.Cos(alf1); Point3d ctPoint1e = ctPoint1 + vectCenterLine.RotateBy(Math.PI * 0.5 + alf1, Vector3d.ZAxis) * (Wbox * 0.5) / Math.Cos(alf1); Point3d ctPoint1f = ctPoint1 - vectCenterLine.RotateBy(Math.PI * 0.5 + alf1, Vector3d.ZAxis) * (Wbox * 0.5) / Math.Cos(alf1); Point3d ctPoint2 = center2.EndPoint; Point3d ctPoint2c = ctPoint2 + vectCenterLine.RotateBy(Math.PI * 0.5 + alf2, Vector3d.ZAxis) * (Wbox * 0.5 - WFbx) / Math.Cos(alf2); Point3d ctPoint2d = ctPoint2 - vectCenterLine.RotateBy(Math.PI * 0.5 + alf2, Vector3d.ZAxis) * (Wbox * 0.5 - WFbx) / Math.Cos(alf2); Point3d ctPoint2e = ctPoint2 + vectCenterLine.RotateBy(Math.PI * 0.5 + alf2, Vector3d.ZAxis) * (Wbox * 0.5) / Math.Cos(alf2); Point3d ctPoint2f = ctPoint2 - vectCenterLine.RotateBy(Math.PI * 0.5 + alf2, Vector3d.ZAxis) * (Wbox * 0.5) / Math.Cos(alf2); Point3d ctPoint33 = center2.GetPointAtDist(Ln); Point3d ctPoint33a = ctPoint33 + vectCenterLine.RotateBy(Math.PI * 0.5 + alf1, Vector3d.ZAxis) * (Wbox * 0.5 - WFbx) / Math.Cos(alf1); Point3d ctPoint33b = ctPoint33 - vectCenterLine.RotateBy(Math.PI * 0.5 + alf1, Vector3d.ZAxis) * (Wbox * 0.5 - WFbx) / Math.Cos(alf1); Point3d ctPoint44 = center2.GetPointAtDist(Ln + Ld); Point3d ctPoint44a = ctPoint44 + vectCenterLine.RotateBy(Math.PI * 0.5 + alf1, Vector3d.ZAxis) * (Wbox * 0.5 - WFbx) / Math.Cos(alf1); Point3d ctPoint44b = ctPoint44 - vectCenterLine.RotateBy(Math.PI * 0.5 + alf1, Vector3d.ZAxis) * (Wbox * 0.5 - WFbx) / Math.Cos(alf1); Point3d ctPoint55 = center2.GetPointAtDist(Ln + Ld + Ldx); Point3d ctPoint55a = ctPoint55 + vectCenterLine.RotateBy(Math.PI * 0.5 + alf1, Vector3d.ZAxis) * (Wbox * 0.5 - WFb) / Math.Cos(alf1); Point3d ctPoint55b = ctPoint55 - vectCenterLine.RotateBy(Math.PI * 0.5 + alf1, Vector3d.ZAxis) * (Wbox * 0.5 - WFb) / Math.Cos(alf1); Point3d ctPoint8 = center2.GetPointAtDist(L - Ln); Point3d ctPoint8a = ctPoint8 + vectCenterLine.RotateBy(Math.PI * 0.5 + alf2, Vector3d.ZAxis) * (Wbox * 0.5 - WFbx) / Math.Cos(alf2); Point3d ctPoint8b = ctPoint8 - vectCenterLine.RotateBy(Math.PI * 0.5 + alf2, Vector3d.ZAxis) * (Wbox * 0.5 - WFbx) / Math.Cos(alf2); Point3d ctPoint7 = center2.GetPointAtDist(L - Ln - Ld); Point3d ctPoint7a = ctPoint7 + vectCenterLine.RotateBy(Math.PI * 0.5 + alf2, Vector3d.ZAxis) * (Wbox * 0.5 - WFbx) / Math.Cos(alf2); Point3d ctPoint7b = ctPoint7 - vectCenterLine.RotateBy(Math.PI * 0.5 + alf2, Vector3d.ZAxis) * (Wbox * 0.5 - WFbx) / Math.Cos(alf2); Point3d ctPoint6 = center2.GetPointAtDist(L - Ln - Ld - Ldx); Point3d ctPoint6a = ctPoint6 + vectCenterLine.RotateBy(Math.PI * 0.5 + alf2, Vector3d.ZAxis) * (Wbox * 0.5 - WFb) / Math.Cos(alf2); Point3d ctPoint6b = ctPoint6 - vectCenterLine.RotateBy(Math.PI * 0.5 + alf2, Vector3d.ZAxis) * (Wbox * 0.5 - WFb) / Math.Cos(alf2); //外轮廓 block.AddCurve(center2, CommonLayer.cenlayer); //block.AddLine(borderDn2, CommonLayer.cenlayer); //上下构造边线 //block.AddLine(borderUp2, CommonLayer.cenlayer); //上下构造边线 block.AddLine(borderLeft, CommonLayer.cenlayer); //左右构造边线 block.AddLine(borderRight, CommonLayer.cenlayer); //左右构造边线 TxLine boxLineUp = new TxLine(ctPoint1e, ctPoint2e); TxLine boxLineDn = new TxLine(ctPoint1f, ctPoint2f); //block.AddLine(boxLineUp, CommonLayer.gz2layer); //block.AddLine(boxLineDn, CommonLayer.gz2layer); //内轮廓 TxLine boxLineInBoxUp = new TxLine(ctPoint55a, ctPoint6a); TxLine boxLineInBoxDn = new TxLine(ctPoint55b, ctPoint6b); block.AddLine(ctPoint33a, ctPoint33b, CommonLayer.gz2layer); block.AddLine(ctPoint8a, ctPoint8b, CommonLayer.gz2layer); block.AddLine(ctPoint33a, ctPoint44a, CommonLayer.gz2layer); block.AddLine(ctPoint44a, ctPoint55a, CommonLayer.gz2layer); //block.AddLine(ctPoint55a, ctPoint6a, CommonLayer.gz2layer); block.AddLine(ctPoint6a, ctPoint7a, CommonLayer.gz2layer); block.AddLine(ctPoint7a, ctPoint8a, CommonLayer.gz2layer); block.AddLine(ctPoint33b, ctPoint44b, CommonLayer.gz2layer); block.AddLine(ctPoint44b, ctPoint55b, CommonLayer.gz2layer); //block.AddLine(ctPoint55b, ctPoint6b, CommonLayer.gz2layer); block.AddLine(ctPoint6b, ctPoint7b, CommonLayer.gz2layer); block.AddLine(ctPoint7b, ctPoint8b, CommonLayer.gz2layer); List<TxLine> hlCenters; List<TxLine> hlLinesL; List<TxLine> hlLinesR; this.GetHLLine(out hlCenters, out hlLinesL, out hlLinesR); //箱室外缘线 List<Point3d> breakPointsUp = new List<Point3d>(); List<Point3d> breakPointsDn = new List<Point3d>(); breakPointsUp.Add(boxLineUp.StartPoint); breakPointsUp.Add(boxLineUp.EndPoint); breakPointsDn.Add(boxLineDn.StartPoint); breakPointsDn.Add(boxLineDn.EndPoint); for (int i = 0; i < hlLinesL.Count; i++) { Point3d tempUpPoint1 = AcadAssist.GetIntersectionPoint(boxLineUp, hlLinesL[i]); Point3d tempUpPoint2 = AcadAssist.GetIntersectionPoint(boxLineUp, hlLinesR[i]); breakPointsUp.Add(tempUpPoint1); breakPointsUp.Add(tempUpPoint2); Point3d tempDnPoint1 = AcadAssist.GetIntersectionPoint(boxLineDn, hlLinesL[i]); Point3d tempDnPoint2 = AcadAssist.GetIntersectionPoint(boxLineDn, hlLinesR[i]); breakPointsDn.Add(tempDnPoint1); breakPointsDn.Add(tempDnPoint2); } breakPointsUp.Sort(new CompairPoint3dX()); breakPointsDn.Sort(new CompairPoint3dX()); if (type == BeamLocate.Mid) { for (int i = 0; i < breakPointsUp.Count / 2; i++) { block.AddLine(breakPointsUp[i * 2], breakPointsUp[i * 2 + 1], CommonLayer.gz2layer); } for (int i = 0; i < breakPointsDn.Count / 2; i++) { block.AddLine(breakPointsDn[i * 2], breakPointsDn[i * 2 + 1], CommonLayer.gz2layer); } } else if (type == BeamLocate.Right) { block.AddLine(boxLineDn, CommonLayer.gz2layer); for (int i = 0; i < breakPointsUp.Count / 2; i++) { block.AddLine(breakPointsUp[i * 2], breakPointsUp[i * 2 + 1], CommonLayer.gz2layer); } } else if (type == BeamLocate.Left) { block.AddLine(boxLineUp, CommonLayer.gz2layer); for (int i = 0; i < breakPointsDn.Count / 2; i++) { block.AddLine(breakPointsDn[i * 2], breakPointsDn[i * 2 + 1], CommonLayer.gz2layer); } } //箱室内缘线 List<Point3d> breakPointsInBoxUp = new List<Point3d>(); List<Point3d> breakPointsInBoxDn = new List<Point3d>(); breakPointsInBoxUp.Add(boxLineInBoxUp.StartPoint); breakPointsInBoxUp.Add(boxLineInBoxUp.EndPoint); breakPointsInBoxDn.Add(boxLineInBoxDn.StartPoint); breakPointsInBoxDn.Add(boxLineInBoxDn.EndPoint); for (int i = 1; i < hlLinesL.Count - 1; i++) { Point3d tempUpPoint1 = AcadAssist.GetIntersectionPoint(boxLineInBoxUp, hlLinesL[i]); Point3d tempUpPoint2 = AcadAssist.GetIntersectionPoint(boxLineInBoxUp, hlLinesR[i]); breakPointsInBoxUp.Add(tempUpPoint1); breakPointsInBoxUp.Add(tempUpPoint2); Point3d tempDnPoint1 = AcadAssist.GetIntersectionPoint(boxLineInBoxDn, hlLinesL[i]); Point3d tempDnPoint2 = AcadAssist.GetIntersectionPoint(boxLineInBoxDn, hlLinesR[i]); breakPointsInBoxDn.Add(tempDnPoint1); breakPointsInBoxDn.Add(tempDnPoint2); } breakPointsInBoxUp.Sort(new CompairPoint3dX()); breakPointsInBoxDn.Sort(new CompairPoint3dX()); for (int i = 0; i < breakPointsInBoxUp.Count / 2; i++) { block.AddLine(breakPointsInBoxUp[i * 2], breakPointsInBoxUp[i * 2 + 1], CommonLayer.gz2layer); } for (int i = 0; i < breakPointsInBoxDn.Count / 2; i++) { block.AddLine(breakPointsInBoxDn[i * 2], breakPointsInBoxDn[i * 2 + 1], CommonLayer.gz2layer); } //箱室内缘线 //横梁线--考虑打断 for (int i = 0; i < hlCenters.Count; i++) block.AddLine(hlCenters[i], CommonLayer.cenlayer); for (int i = 0; i < hlLinesL.Count; i++) { Point3d xPoint1 = AcadAssist.GetIntersectionPoint(boxLineDn, hlLinesL[i]); Point3d xPoint2 = AcadAssist.GetIntersectionPoint(boxLineDn, hlLinesR[i]); Point3d xPoint3 = AcadAssist.GetIntersectionPoint(boxLineUp, hlLinesL[i]); Point3d xPoint4 = AcadAssist.GetIntersectionPoint(boxLineUp, hlLinesR[i]); if (type == BeamLocate.Mid || type == BeamLocate.Left) { block.AddLine(xPoint1, hlLinesL[i].StartPoint, CommonLayer.gz2layer); block.AddLine(xPoint2, hlLinesR[i].StartPoint, CommonLayer.gz2layer); } if (type == BeamLocate.Mid || type == BeamLocate.Right) { block.AddLine(xPoint3, hlLinesL[i].EndPoint, CommonLayer.gz2layer); block.AddLine(xPoint4, hlLinesR[i].EndPoint, CommonLayer.gz2layer); } if (i != 0 && i != hlLinesL.Count - 1) { Point3d xPoint1a = AcadAssist.GetIntersectionPoint(boxLineInBoxDn, hlLinesL[i]); Point3d xPoint2a = AcadAssist.GetIntersectionPoint(boxLineInBoxDn, hlLinesR[i]); Point3d xPoint3a = AcadAssist.GetIntersectionPoint(boxLineInBoxUp, hlLinesL[i]); Point3d xPoint4a = AcadAssist.GetIntersectionPoint(boxLineInBoxUp, hlLinesR[i]); block.AddLine(xPoint1a, xPoint3a, CommonLayer.gz2layer); block.AddLine(xPoint2a, xPoint4a, CommonLayer.gz2layer); } } //腹板中心线 //Curve centerLine = AcadAssist.TrimCurveGetFront(center2, AcadAssist.GetIntersectionPoint(center2, borderRight)); TxCurve centerLine = AcadAssist.CloneTxCurve(center2); block.AddCurve(centerLine, CommonLayer.cenlayer); //中心线长度 double Length = center2.GetDistAtPoint(center2.EndPoint); Point3d textPoint = center2.GetPointAtDist(Length * 0.4); Vector3d textVect = center2.GetFirstDerivative(textPoint); //double textAngle = textVect.AngleOnPlane(center2.GetPlane()); double textAngle = AcadAssist.AngleOnPlan(textVect, center2); block.AddText(textPoint, String.Format("中心线长度{0:F0}", Length), block.style.RealTextHeigth * 1000, textAngle, CommonLayer.dimlayer, TxTextHorizontalMode.TextCenter, TxTextVerticalMode.TextBottom); //角度标注 for (int i = 0; i < hlCenters.Count; i++) { Point3d hlPointx = AcadAssist.GetIntersectionPoint(center2, hlCenters[i]); Vector3d curVectx = center2.GetFirstDerivative(hlPointx).GetNormal(); Vector3d vectHL = hlCenters[i].EndPoint.GetVectorTo(hlCenters[i].StartPoint).GetNormal(); if (i == hlCenters.Count - 1) block.AddDimAngularFix(hlPointx, hlPointx - curVectx * block.style.BlockScale * 2000, hlPointx + vectHL * block.style.BlockScale * 2000, block.style.DimFirstLayer * 1000); else block.AddDimAngularFix(hlPointx, hlPointx + curVectx * block.style.BlockScale * 2000, hlPointx + vectHL * block.style.BlockScale * 2000, block.style.DimFirstLayer * 1000); } }
public void DrawPM(DatabaseToAcad block) { // 1a 2a // /-----------------/-----------------------/ // / 3a / 5a / // 1c/----\_ 4a / 6a_/-------/2c // / \---------/--------------/ / // 1/-----------------/-----------------------/ // / __/--------/---------------\ / // 1d/ -----/ 4b / 6b \-----/2d // / 3b / 5b / // /-----------------/-----------------------/ //1b 2b if (center != null && center.StartPoint.X > center.EndPoint.X) { center = AcadAssist.ReverseTxLine(center); } if (borderDn != null && borderDn.StartPoint.X > borderDn.EndPoint.X) { borderDn = AcadAssist.ReverseCurve(borderDn); } if (borderUp != null && borderUp.StartPoint.X > borderUp.EndPoint.X) { borderUp = AcadAssist.ReverseCurve(borderUp); } TxLine center2 = null; TxCurve borderDn2 = null; TxCurve borderUp2 = null; if (center == null) { center2 = new TxLine(new Point3d(0, 0, 0), new Point3d(L, 0, 0)); } else { center2 = AcadAssist.CloneTxLine(center); } if (borderDn == null) { borderDn2 = new TxLine(new Point3d(0, 0, 0), new Point3d(L, 0, 0)); } else { borderDn2 = AcadAssist.CloneTxCurve(borderDn); } if (borderUp == null) { borderUp2 = new TxLine(new Point3d(0, 0, 0), new Point3d(L, 0, 0)); } else { borderUp2 = AcadAssist.CloneTxCurve(borderUp); } TxLine borderLeft = new TxLine(borderDn2.StartPoint, borderUp2.StartPoint); TxLine borderRight = new TxLine(borderDn2.EndPoint, borderUp2.EndPoint); Vector3d vectCenterLine = center2.StartPoint.GetVectorTo(center2.EndPoint).GetNormal(); Point3d ctPoint1 = center2.StartPoint; //Point3d ctPoint1a = new Point3d(ctPoint1.X + Math.Tan(alf1) * WTL1, ctPoint1.Y + WTL1, 0); //Point3d ctPoint1b = new Point3d(ctPoint1.X - Math.Tan(alf1) * WTL2, ctPoint1.Y - WTL2, 0); Point3d ctPoint1c = ctPoint1 + vectCenterLine.RotateBy(Math.PI * 0.5 + alf1, Vector3d.ZAxis) * (WD * 0.5) / Math.Cos(alf1); Point3d ctPoint1d = ctPoint1 - vectCenterLine.RotateBy(Math.PI * 0.5 + alf1, Vector3d.ZAxis) * (WD * 0.5) / Math.Cos(alf1); //Point3d ctPoint1c = new Point3d(ctPoint1.X + Math.Tan(alf1) * WD * 0.5, ctPoint1.Y + WD * 0.5, 0); //Point3d ctPoint1d = new Point3d(ctPoint1.X - Math.Tan(alf1) * WD * 0.5, ctPoint1.Y - WD * 0.5, 0); Point3d ctPoint2 = center2.EndPoint; //Point3d ctPoint2a = new Point3d(ctPoint2.X + Math.Tan(alf2) * WTR1, ctPoint1.Y + WTR1, 0); //Point3d ctPoint2b = new Point3d(ctPoint2.X - Math.Tan(alf2) * WTR2, ctPoint1.Y - WTR2, 0); Point3d ctPoint2c = ctPoint2 + vectCenterLine.RotateBy(Math.PI * 0.5 + alf2, Vector3d.ZAxis) * (WD * 0.5) / Math.Cos(alf2); Point3d ctPoint2d = ctPoint2 - vectCenterLine.RotateBy(Math.PI * 0.5 + alf2, Vector3d.ZAxis) * (WD * 0.5) / Math.Cos(alf2); //Point3d ctPoint2c = new Point3d(ctPoint2.X + Math.Tan(alf2) * WD * 0.5, ctPoint2.Y + WD * 0.5, 0); //Point3d ctPoint2d = new Point3d(ctPoint2.X - Math.Tan(alf2) * WD * 0.5, ctPoint2.Y - WD * 0.5, 0); Point3d ctPoint3 = center2.GetPointAtDist(Ld); Point3d ctPoint3a = new Point3d(ctPoint3.X + Math.Tan(alf1) * WD * 0.5, ctPoint3.Y + WD * 0.5, 0); Point3d ctPoint3b = new Point3d(ctPoint3.X - Math.Tan(alf1) * WD * 0.5, ctPoint3.Y - WD * 0.5, 0); Point3d ctPoint4 = center2.GetPointAtDist(Ld + Ldx); Point3d ctPoint4a = new Point3d(ctPoint4.X + Math.Tan(alf1) * WFb * 0.5, ctPoint3.Y + WFb * 0.5, 0); Point3d ctPoint4b = new Point3d(ctPoint4.X - Math.Tan(alf1) * WFb * 0.5, ctPoint3.Y - WFb * 0.5, 0); Point3d ctPoint5 = center2.GetPointAtDist(L - Ld); Point3d ctPoint5a = new Point3d(ctPoint5.X + Math.Tan(alf2) * WD * 0.5, ctPoint5.Y + WD * 0.5, 0); Point3d ctPoint5b = new Point3d(ctPoint5.X - Math.Tan(alf2) * WD * 0.5, ctPoint5.Y - WD * 0.5, 0); Point3d ctPoint6 = center2.GetPointAtDist(L - Ld - Ldx); Point3d ctPoint6a = new Point3d(ctPoint6.X + Math.Tan(alf2) * WFb * 0.5, ctPoint6.Y + WFb * 0.5, 0); Point3d ctPoint6b = new Point3d(ctPoint6.X - Math.Tan(alf2) * WFb * 0.5, ctPoint6.Y - WFb * 0.5, 0); //外轮廓 //TxLine sideLine1 = new TxLine(ctPoint1a, ctPoint2a); //TxLine sideLine2 = new TxLine(ctPoint1b, ctPoint2b); //block.AddLine(ctPoint1a, ctPoint1b, CommonLayer.gz1layer); //block.AddLine(ctPoint2a, ctPoint2b, CommonLayer.gz1layer); //block.AddLine(ctPoint1a, ctPoint2a, CommonLayer.gz1layer); //block.AddLine(ctPoint1b, ctPoint2b, CommonLayer.gz1layer); //内轮廓 TxPolyline plineUp = new TxPolyline(); plineUp.AddVertexAt(0, new Point2d(ctPoint1c.X, ctPoint1c.Y), 0, 0, 0); plineUp.AddVertexAt(1, new Point2d(ctPoint3a.X, ctPoint3a.Y), 0, 0, 0); plineUp.AddVertexAt(2, new Point2d(ctPoint4a.X, ctPoint4a.Y), 0, 0, 0); plineUp.AddVertexAt(3, new Point2d(ctPoint6a.X, ctPoint6a.Y), 0, 0, 0); plineUp.AddVertexAt(4, new Point2d(ctPoint5a.X, ctPoint5a.Y), 0, 0, 0); plineUp.AddVertexAt(5, new Point2d(ctPoint2c.X, ctPoint2c.Y), 0, 0, 0); //block.AddPolyline(plineUp, CommonLayer.gz2layer); TxPolyline plineDn = new TxPolyline(); plineDn.AddVertexAt(0, new Point2d(ctPoint1d.X, ctPoint1d.Y), 0, 0, 0); plineDn.AddVertexAt(1, new Point2d(ctPoint3b.X, ctPoint3b.Y), 0, 0, 0); plineDn.AddVertexAt(2, new Point2d(ctPoint4b.X, ctPoint4b.Y), 0, 0, 0); plineDn.AddVertexAt(3, new Point2d(ctPoint6b.X, ctPoint6b.Y), 0, 0, 0); plineDn.AddVertexAt(4, new Point2d(ctPoint5b.X, ctPoint5b.Y), 0, 0, 0); plineDn.AddVertexAt(5, new Point2d(ctPoint2d.X, ctPoint2d.Y), 0, 0, 0); //block.AddPolyline(plineDn, CommonLayer.gz2layer); //获取横梁线 List<TxLine> hlCenters; List<TxLine> hlLinesL; List<TxLine> hlLinesR; this.GetHLLine(out hlCenters, out hlLinesL, out hlLinesR); //绘制横梁线--考虑剪切断开 for (int i = 0; i < hlCenters.Count; i++) block.AddLine(hlCenters[i], CommonLayer.cenlayer); for (int i = 0; i < hlLinesL.Count; i++) { Point3d xPoint1 = AcadAssist.GetIntersectionPoint(plineDn, hlLinesL[i]); Point3d xPoint2 = AcadAssist.GetIntersectionPoint(plineDn, hlLinesR[i]); Point3d xPoint3 = AcadAssist.GetIntersectionPoint(plineUp, hlLinesL[i]); Point3d xPoint4 = AcadAssist.GetIntersectionPoint(plineUp, hlLinesR[i]); if (type == BeamLocate.Mid || type == BeamLocate.Left) { block.AddLine(xPoint1, hlLinesL[i].StartPoint, CommonLayer.gz2layer); block.AddLine(xPoint2, hlLinesR[i].StartPoint, CommonLayer.gz2layer); } if (type == BeamLocate.Mid || type == BeamLocate.Right) { block.AddLine(xPoint3, hlLinesL[i].EndPoint, CommonLayer.gz2layer); block.AddLine(xPoint4, hlLinesR[i].EndPoint, CommonLayer.gz2layer); } } //绘制腹板线--纵向 if (type == BeamLocate.Mid || type == BeamLocate.Right) { List<Point3d> xPointsUp = new List<Point3d>(); for (int i = 0; i < hlLinesL.Count; i++) { xPointsUp.AddRange(AcadAssist.GetIntersectionPoints(plineUp, hlLinesL[i])); //Point3dCollection curPointsL = new Point3dCollection(); //plineUp.IntersectWith(hlLinesL[i], Intersect.OnBothOperands, curPointsL, 0, 0); //for (int j = 0; j < curPointsL.Count; j++) // xPointsUp.Add(curPointsL[j]); xPointsUp.AddRange(AcadAssist.GetIntersectionPoints(plineUp, hlLinesR[i])); //Point3dCollection curPointsR = new Point3dCollection(); //plineUp.IntersectWith(hlLinesR[i], Intersect.OnBothOperands, curPointsR, 0, 0); //for (int j = 0; j < curPointsR.Count; j++) //xPointsUp.Add(curPointsR[j]); } xPointsUp.Sort(new CompairPoint3dX()); ////Point3dCollection xPointsUp2 = new Point3dCollection(); ////for (int i = 0; i < xPointsUp.Count; i++) ////{ //// xPointsUp2.Add(xPointsUp[i]); ////} ////DBObjectCollection objCurvesUp = plineUp.GetSplitCurves(xPointsUp2); List<TxCurve> objCurvesUp = AcadAssist.SplitCurveByPoints(plineUp, xPointsUp); //输出基数个数 int count1 = Convert.ToInt32((objCurvesUp.Count + 1) / 2); for (int i = 0; i < count1; i++) { block.AddCurve((TxCurve)objCurvesUp[i * 2], CommonLayer.gz2layer); } } if (type == BeamLocate.Mid || type == BeamLocate.Left) { //腹板线--右侧侧 List<Point3d> xPointsDn = new List<Point3d>(); for (int i = 0; i < hlLinesL.Count; i++) { xPointsDn.AddRange(AcadAssist.GetIntersectionPoints(plineUp, hlLinesL[i])); ////Point3dCollection curPointsL = new Point3dCollection(); ////plineDn.IntersectWith(hlLinesL[i], Intersect.OnBothOperands, curPointsL, 0, 0); ////for (int j = 0; j < curPointsL.Count; j++) //// xPointsDn.Add(curPointsL[j]); ////Point3dCollection curPointsR = new Point3dCollection(); ////plineDn.IntersectWith(hlLinesR[i], Intersect.OnBothOperands, curPointsR, 0, 0); ////for (int j = 0; j < curPointsR.Count; j++) //// xPointsDn.Add(curPointsR[j]); } xPointsDn.Sort(new CompairPoint3dX()); ////Point3dCollection xPointsDn2 = new Point3dCollection(); ////for (int i = 0; i < xPointsDn.Count; i++) ////{ //// xPointsDn2.Add(xPointsDn[i]); ////} List<TxCurve> objCurvesDn = AcadAssist.SplitCurveByPoints(plineDn, xPointsDn); //DBObjectCollection objCurvesDn = plineDn.GetSplitCurves(xPointsDn2); //输出基数个数 int count2 = Convert.ToInt32((objCurvesDn.Count + 1) / 2); for (int i = 0; i < count2; i++) { block.AddCurve((TxCurve)objCurvesDn[i * 2], CommonLayer.gz2layer); } } if (type == BeamLocate.Left) block.AddPolyline(plineUp, CommonLayer.gz2layer); if (type == BeamLocate.Right) block.AddPolyline(plineDn, CommonLayer.gz2layer); //腹板中心线 TxCurve centerLine = AcadAssist.OffsetLineToBoarder(center2, 0, borderLeft, borderRight); block.AddCurve(centerLine, CommonLayer.cenlayer); //中心线长度 Point3d textPoint = center2.GetPointAtDist(center2.Length * 0.4); Vector3d textVect = center2.GetFirstDerivative(textPoint); //double textAngle = textVect.AngleOnPlane(center2.GetPlane()); double textAngle = AcadAssist.AngleOnPlan(textVect, center2); block.AddText(textPoint, String.Format("中心线长度{0:F0}", center2.Length), block.style.RealTextHeigth * 1000, textAngle, CommonLayer.dimlayer, TxTextHorizontalMode.TextCenter, TxTextVerticalMode.TextBottom); //角度标注 for (int i = 0; i < hlCenters.Count; i++) { Point3d hlPointx = AcadAssist.GetIntersectionPoint(center2, hlCenters[i]); Vector3d curVectx = center2.GetFirstDerivative(hlPointx).GetNormal(); Vector3d vectHL = hlCenters[i].EndPoint.GetVectorTo(hlCenters[i].StartPoint).GetNormal(); if (i == hlCenters.Count - 1) block.AddDimAngularFix(hlPointx, hlPointx - curVectx * block.style.BlockScale * 2000, hlPointx + vectHL * block.style.BlockScale * 2000, block.style.DimFirstLayer * 1000); else block.AddDimAngularFix(hlPointx, hlPointx + curVectx * block.style.BlockScale * 2000, hlPointx + vectHL * block.style.BlockScale * 2000, block.style.DimFirstLayer * 1000); } }
/// <summary> /// 标注悬臂宽度 /// </summary> /// <param name="cv1"></param> /// <param name="line"></param> /// <returns></returns> internal void XuanBiWidth(DatabaseToAcad block, TxCurve cv1, TxLine line) { double lnLength = line.StartPoint.DistanceTo(line.EndPoint); int count = Convert.ToInt32(lnLength / shortLineDist); Vector3d vect = line.EndPoint.GetAsVector() - line.StartPoint.GetAsVector(); vect = vect.GetNormal(); Vector3d vectPer = vect.RotateBy(Math.PI * 0.5, Vector3d.ZAxis); double[] step = KXBMath.BJ4(lnLength, shortLineDist * m_drawScale, 0.5 * m_drawScale); double sumStep = 0; for (int i = 0; i < step.Length - 1; i++) { sumStep += step[i]; Point3d lnPoint = line.GetPointAtDist(sumStep); TxXline xline = new TxXline(); xline.BasePoint = lnPoint; xline.UnitDir = vectPer; List<Point3d> points = AcadAssist.GetIntersectionPoints(cv1, xline); if (points.Count == 0) continue; //Point3dCollection points = new Point3dCollection(); //cv1.IntersectWith(xline, Intersect.OnBothOperands, points, 0, 0); //if (points.Count == 0) continue; TxLine shortline = new TxLine(lnPoint, points[0]); block.AddCurve(shortline, CommonLayer.dimlayer); Vector3d vectNorm = shortline.EndPoint.GetAsVector() - shortline.StartPoint.GetAsVector(); double shortLineLength = shortline.StartPoint.DistanceTo(shortline.EndPoint); string textString = String.Format("{0}", CommonSimbel.ConvertToDimStr1(shortLineLength * 1000 / m_drawScale)); double rotation = AcadAssist.AngleOnPlan(vectNorm, line); block.AddText(shortline.EndPoint, textString, block.style.RealTextHeigth, rotation, CommonLayer.dimlayer, TxTextHorizontalMode.TextLeft, TxTextVerticalMode.TextVerticalMid); //DBText dbText = new DBText(); //dbText.Rotation = vectNorm.AngleOnPlane(line.GetPlane()); //dbText.TextString = String.Format("{0:0}", shortLineLength * 1000 / m_drawScale); //dbText.Height = block.style.RealTextHeigth; //dbText.WidthFactor = 0.75; //dbText.VerticalMode = TxTextVerticalMode.TextVerticalMid; //dbText.Position = shortline.EndPoint; //dbText.AlignmentPoint = shortline.EndPoint; //dbText.TextStyleId = CommonSimbel.textStyleId; //dbText.Layer = CommonLayer.dimlayer; ////block.AddEntity(shortline); ////block.AddEntity(dbText); } //标注悬臂 Point3d curvePoint = cv1.GetClosestPointTo(line.StartPoint, false); int upSideFlag = (curvePoint.Y < line.StartPoint.Y) ? 1 : -1; Point3d dimPoint1 = line.StartPoint + upSideFlag * vectPer * block.style.DimSecondLayer; Point3d dimPoint2 = line.EndPoint + upSideFlag * vectPer * block.style.DimSecondLayer; List<double> tempStep = new List<double>(); tempStep.AddRange(step); block.AddDimToPointsAlignedCombine(dimPoint1, dimPoint2, upSideFlag * block.style.DimFirstLayer, tempStep, 1000 / m_drawScale); }
public override void Draw(DatabaseToAcad block) { // ======================== 基本几何操作 ==================================== /// 点和向量的计算 Point3d structPt1 = new Point3d(0, -5000, 0); Vector3d vect = new Vector3d(3, 9, 0); /// Vector3d vectUnit = vect.GetNormal(); ///取单位向量 Vector3d vectPer = vectUnit.RotateBy(Math.PI * 0.5, Vector3d.ZAxis); ///向量的垂直,顺时针方向转90度 Point3d structPt2 = structPt1 + vectUnit.MultiplyBy(2000); ///点可以是点和向量相加 Point3d structPt3 = structPt1 + vectPer.MultiplyBy(2000); /// 直线 TxLine line1 = new TxLine(new Point3d(0, 0, 0), new Point3d(500, 500, 0)); TxLine line2 = AcadAssist.GetOffsetLineToLeft(line1, 200); //线的偏移 TxLine line3 = new TxLine(new Point3d(100, -500, 0), new Point3d(100, 5000, 0)); TxLine line4 = new TxLine(new Point3d(1000, -500, 0), new Point3d(1000, 5000, 0)); List<Point3d> xpnt = AcadAssist.GetIntersectionPoints(line1, line3); /// 两条线求交 /// 圆弧 TxArc arc = new TxArc(new Point3d(), new Point3d(100, 100, 0), new Point3d(200, 0, 0));///三点确定圆弧 /// 圆弧转化为多义线 TxPolyline pl2 = AcadAssist.ConvertToTxPolyline(arc); /// 多义线 TxPolyline pl1 = new TxPolyline(); pl1.AddVertexAt(0, new Point2d(0, 0), 0, 0, 0); pl1.AddVertexAt(1, new Point2d(0, 500), 0, 0, 0); pl1.AddVertexAt(2, new Point2d(500, 500), 0, 0, 0); pl1.AddVertexAt(3, new Point2d(300, 100), 0.5, 0, 0); /// 这个参数不是0,则是曲线 pl1.AddVertexAt(4, new Point2d(0, 0), 0, 0, 0); // ======================== 基本图形的运算 AcadAssist.() ==================================== /// 多义线裁剪和对称 TxPolyline pl3 = AcadAssist.TrimPolylineGetFront(pl2, new Point3d(500, 500, 0)); /// 裁剪,求线的前面部分 pl3 = AcadAssist.MillarTxPolyline(pl3, 0); // ======================== 绘制图形 ==================================== /// -------- 绘制线 ----------- block.AddLine(new Point3d(0, 0, 0), new Point3d(500, 500, 0), CommonLayer.zerolayer); /// --------绘制线 ----------------------- 图层说明 -- 构造有四个图层, 加入的对象颜色和线型都是随层的 block.AddLine(line1, CommonLayer.gz1layer); ///粗实线 block.AddLine(line2, CommonLayer.gz2layer); ///细实线 block.AddLine(line3, CommonLayer.gz3layer); ///粗虚线 block.AddLine(line4, CommonLayer.gz4layer); ///细虚线 /// --------- 绘制其它基本图形 block.AddCircle(new Point3d(0, 0, 0), 500, CommonLayer.zerolayer); block.AddCurve(arc, CommonLayer.dimlayer); //public void AddSectionLineHori(Point3d midPoint, string name, bool isTextUp, bool isArrowLeft); /// 剖断线 //public void AddSectionLineVert(Point3d midPoint, string name, bool isTextLeft, bool isArrowUpside); /// 剖断线 /// --------绘制线 ----------------------- 图层说明 -- 构造有四个图层, 加入的对象颜色和线型都是随层的 block.AddCurve(pl1); block.AddCurve(pl2); block.AddCurve(pl3); ///标注文字和线 [带指引线的文字] block.AddTextDim(new Point3d(0, 500, 0), CommonSimbel.ConvertToDimStr(1000) + CommonSimbel.multipliSymbol + CommonSimbel.ConvertToDimStr(500), 2); /// 最后一个参数表示是哪个象限[1,2,3,4] block.AddTextDimAngle(new Point3d(0, 1500, 0), "sss", new Point3d(2500, 5000, 0), 250); ///加阴影部分 TxPolyline plx = AcadAssist.CloneTxPolyline(pl1); block.AddHatch(plx, 1, CommonLayer.gz1layer); // -------- 绘制文字 ------ block.AddText(new Point3d(800, 800, 0), "Hello1"); block.AddText(new Point3d(900, 900, 0), "Hello2", block.style.RealTextHeigth, Math.PI * 0.25, CommonLayer.dimlayer, TxTextHorizontalMode.TextRight, TxTextVerticalMode.TextTop); ///加标题 block.AddTitle(new Point3d(500, 500, 0), "图块标题"); /// 应该考虑图块放在上面还是下面 /// CommonSimbel.IsDownTitle ///加折断线 ,有三种,单折断线,双折断线,圆柱折断线 //block.AddBreakLine() // ======================== 标注 ==================================== //block.AddDimContinueAlign_AutoAdjust( ,);/// 自动向外调整位置 //block.AddDimension_UserTextPoint()/// 一般情况下文字位置自定处理的,但是也可以设定 // ======================== 绘制钢筋 ==================================== /// ------ 绘制点钢筋 --------- double BHC = 30; ISteelBar ist_dot = new ISteelBar("1", 12, SteelBarType.HRB400, "水平钢筋", 101); SteelDotByLine st_dot = SteelFactory.CreateSteelDots(ist_dot, structPt1, structPt2, BHC); block.AddSteelEntity(st_dot); /// ------ 绘制线钢筋 --------- ISteelBar ist_line = new ISteelBar("1", 12, SteelBarType.HRB400, "水平钢筋", 101); SteelLines st_line = SteelFactory.CreateSteelParalLine(ist_line, structPt1, structPt3, BHC, 45, 2000); block.AddSteelEntity(st_line); }