/// <summary> /// 1.布板线的长度标注和角度标注,2.板宽和湿接缝的宽度标注 /// </summary> internal void DimBuban(DatabaseToAcad block, TxLine endLine1, TxLine endLine2, List<TxLine> kxbLine, TxLine m_startLine2) { for (int i = 0; i < kxbLine.Count; i++) { double dist = kxbLine[i].StartPoint.DistanceTo(kxbLine[i].EndPoint); double rotate = AcadAssist.AngleOnPlan(kxbLine[i].StartPoint.GetVectorTo(kxbLine[i].EndPoint), kxbLine[i]); //double rotate = kxbLine[i].StartPoint.GetVectorTo(kxbLine[i].EndPoint).AngleOnPlane(kxbLine[i].GetPlane()); //空心板边线长度 //string preString = (m_drawScale == 1) ? "3" : "0"; //string text2String = String.Format("L={0:F" + preString + "}", dist * 1000 / m_drawScale);判断保留几位小数 string text2String = String.Format("L={0}", CommonSimbel.ConvertToDimStr(dist * 1000 / m_drawScale)); Point3d text2Point = kxbLine[i].GetPointAtDist(dist * 0.5); if (i % 2 == 0) { block.AddText(text2Point, text2String, block.style.RealTextHeigth, rotate, CommonLayer.dimlayer, TxTextHorizontalMode.TextCenter, TxTextVerticalMode.TextTop); //DBText dbText = (DBText)block.GetLastEntity(); //dbText.VerticalMode = TxTextVerticalMode.TextTop; //dbText.AlignmentPoint = dbText.Position; } else { block.AddText(text2Point, text2String, block.style.RealTextHeigth, rotate, CommonLayer.dimlayer, TxTextHorizontalMode.TextCenter, TxTextVerticalMode.TextBottom); } } if (isDimItalia == false) { #region 正向标注板梁宽度 //最好再偏移一个斜交角度造成的影响 TxLine startLine2 = AcadAssist.OffsetLineToBoarder(m_startLine2, 0, endLine1, endLine2); Point3d pt1 = AcadAssist.ExtendLine(startLine2.EndPoint, startLine2.StartPoint, (m_glWidth2 * this.m_drawScale) + dimSideOffset * block.style.BlockScale + block.style.DimFirstLayer); Point3d pt2 = AcadAssist.ExtendLine(startLine2.StartPoint, startLine2.EndPoint, (m_glWidth1 * this.m_drawScale) + dimSideOffset * block.style.BlockScale + block.style.DimFirstLayer); startLine2 = new TxLine(pt1, pt2); Vector3d vectLine = startLine2.StartPoint.GetVectorTo(startLine2.EndPoint); Vector3d vectPer = vectLine.RotateBy(Math.PI * 0.5, Vector3d.ZAxis).GetNormal(); //平移板宽尺寸后点(即标注点) List<Point3d> points1 = new List<Point3d>();//划板线左侧点 List<Point3d> points2 = new List<Point3d>();//划板线右侧点 //包括边线的线集合 List<TxLine> tempLines = new List<TxLine>(); tempLines.AddRange(kxbLine); tempLines.Add(new TxLine(endLine1.StartPoint, endLine2.StartPoint)); tempLines.Add(new TxLine(endLine1.EndPoint, endLine2.EndPoint)); for (int i = 0; i < tempLines.Count; i++) { Point3d tempPoint1 = startLine2.GetClosestPointTo(tempLines[i].StartPoint, true);//求出垂足 double dist1 = tempPoint1.DistanceTo(tempLines[i].StartPoint); Vector3d vect1 = tempPoint1.GetVectorTo(tempLines[i].StartPoint).GetNormal(); int flag1 = vectPer.IsEqualTo(vect1, new Tolerance(0.01, 0.01)) ? 1 : -1; Point3d tempPoint2 = startLine2.GetClosestPointTo(tempLines[i].EndPoint, true); double dist2 = tempPoint2.DistanceTo(tempLines[i].EndPoint); Vector3d vect2 = tempPoint2.GetVectorTo(tempLines[i].EndPoint).GetNormal(); int flag2 = vectPer.IsEqualTo(vect2, new Tolerance(0.01, 0.01)) ? 1 : -1; points1.Add(startLine2.StartPoint + flag1 * dist1 * vectPer); points2.Add(startLine2.EndPoint + flag2 * dist2 * vectPer); } CompairPoint3dY compairY = new CompairPoint3dY(); points1.Sort(compairY); points2.Sort(compairY); List<Point3d> breakPoint = new List<Point3d>(); block.AddDimToPointsAlignedCombine(points1, +block.style.DimFirstLayer, breakPoint, 1000 / m_drawScale); block.AddDimToPointsAlignedCombine(points2, -block.style.DimFirstLayer, breakPoint, 1000 / m_drawScale); //左右侧竖向标注 -- 总尺寸标注 block.AddDimRotated(points1[0], points1[points1.Count - 1], +2.5 * block.style.DimFirstLayer, 0, CommonSimbel.ConvertToDimStr(points1[0].DistanceTo(points1[points1.Count - 1]) * 1000 / m_drawScale)); block.AddDimRotated(points2[0], points2[points2.Count - 1], -2.5 * block.style.DimFirstLayer, 0, CommonSimbel.ConvertToDimStr(points2[0].DistanceTo(points2[points2.Count - 1]) * 1000 / m_drawScale)); //block.AddDimAligned(points1[0], points1[points1.Count - 1], +block.style.DimSecondLayer); //block.AddDimAligned(points2[0], points2[points2.Count - 1], -block.style.DimSecondLayer); #endregion } else { #region 斜向标注板梁宽度 TxLine dimLineLeft = AcadAssist.GetOffsetLineToLeft(endLine1, +(IsDrawSupport ? 2.0 : 0.5) * block.style.DimFirstLayer); TxLine dimLineRight = AcadAssist.GetOffsetLineToLeft(endLine2, -(IsDrawSupport ? 2.0 : 0.5) * block.style.DimFirstLayer); //平移板宽尺寸后点(即标注点) List<Point3d> points1 = new List<Point3d>();//划板线左侧点 List<Point3d> points2 = new List<Point3d>();//划板线右侧点 //包括边线的线集合 List<TxLine> tempLines = new List<TxLine>(); tempLines.AddRange(kxbLine); tempLines.Add(new TxLine(endLine1.StartPoint, endLine2.StartPoint)); tempLines.Add(new TxLine(endLine1.EndPoint, endLine2.EndPoint)); for (int i = 0; i < tempLines.Count; i++) { Point3d tempPoint1 = dimLineLeft.GetClosestPointTo(tempLines[i].StartPoint, true);//求出垂足 Point3d tempPoint2 = dimLineRight.GetClosestPointTo(tempLines[i].EndPoint, true); points1.Add(tempPoint1); points2.Add(tempPoint2); } CompairPoint3dY compairY = new CompairPoint3dY(); points1.Sort(compairY); points2.Sort(compairY); List<Point3d> breakPoint = new List<Point3d>(); block.AddDimToPointsAlignedCombine(points1, +block.style.DimFirstLayer, breakPoint, 1000 / m_drawScale); block.AddDimToPointsAlignedCombine(points2, -block.style.DimFirstLayer, breakPoint, 1000 / m_drawScale); //左右侧竖向标注 -- 总尺寸标注 block.AddDimRotated(points1[0], points1[points1.Count - 1], +block.style.DimSecondLayer, 0, CommonSimbel.ConvertToDimStr(points1[0].DistanceTo(points1[points1.Count - 1]) * 1000 / m_drawScale)); block.AddDimRotated(points2[0], points2[points2.Count - 1], -block.style.DimSecondLayer, 0, CommonSimbel.ConvertToDimStr(points2[0].DistanceTo(points2[points2.Count - 1]) * 1000 / m_drawScale)); //block.AddDimAligned(points1[0], points1[points1.Count - 1], +block.style.DimSecondLayer); //block.AddDimAligned(points2[0], points2[points2.Count - 1], -block.style.DimSecondLayer); #endregion } }
/// <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); }