// 由尺寸线旋转角度、两条尺寸界线原点、尺寸文本位置、尺寸文本和标注样式创建转角标注的函数. public static ObjectId AddDimRotated(double angle, Point3d pt1, Point3d pt2, Point3d ptText, string text, ObjectId style) { RotatedDimension ent = new RotatedDimension(angle, pt1, pt2, ptText, text, style); ObjectId entId = AppendEntity(ent); return(entId); }
protected RotatedDimension CreateDim(Point3d ptPrev, Point3d ptNext, Point3d ptDimLine, bool doTrans, Matrix3d trans, int rangeSize = 0, double rotation = 0, bool interlineText = false) { if (doTrans) { ptPrev = ptPrev.TransformBy(trans); ptNext = ptNext.TransformBy(trans); ptDimLine = ptDimLine.TransformBy(trans); } var dim = new RotatedDimension(rotation.ToRadians(), ptPrev, ptNext, ptDimLine, "", panelBase.Service.Env.IdDimStyle); if (rangeSize > 0) { dim.Suffix = getTextRange(dim.Measurement, rangeSize); } if (interlineText) { dim.Dimtmove = 0; dim.Dimtix = true; } dim.Dimscale = Settings.Default.SheetScale; btrDim.AppendEntity(dim); t.AddNewlyCreatedDBObject(dim, true); return(dim); }
/// <summary> /// 由尺寸线旋转角度、两条尺寸界线原点、尺寸文本位置、尺寸文本和标注样式创建转角标注 /// </summary> /// <param name="pt1">标注点1</param> /// <param name="pt2">标注点2</param> /// <param name="ptText">标注文本定位点</param> /// <param name="text">标注替换文本</param> /// <returns></returns> public static RotatedDimension CreateRotatedDimension(Point3d pt1, Point3d pt2, Point3d ptText, string text) { double angle = new Line(pt1, pt2).Angle; Database db = HostApplicationServices.WorkingDatabase; ObjectId style = db.Dimstyle; RotatedDimension ent = new RotatedDimension(angle, pt1, pt2, ptText, text, style); return(ent); }
/// <summary> /// 转角标注 /// </summary> /// <param name="worker">工作数据库</param> /// <param name="direction">方向</param> /// <param name="start">起始点</param> /// <param name="end">终止点</param> /// <param name="dimDistance">偏移距离</param> /// <param name="textReplace">文字替代</param> /// <returns></returns> public static RotatedDimension RotatedDimension(this DatabaseWorker worker, RotateDirection direction, Point3d start, Point3d end, double dimDistance, string textReplace = "") { //根据位置计算参照其中一点移动指定距离 var x = Math.Abs(start.X - end.X); //水平差值 var y = Math.Abs(start.Y - end.Y); //竖直差值 var radian = 0.0; var dimLinePoint = new Point3d(); switch (direction) { case RotateDirection.PX: radian = -GRadian.Radians90; dimLinePoint = start.X > end.X ? start + new Vector3d(dimDistance, y, 0) : end + new Vector3d(dimDistance, y, 0); break; case RotateDirection.NY: radian = GRadian.Radians270; dimLinePoint = start.X > end.X ? start + new Vector3d(x, -dimDistance, 0) : end + new Vector3d(x, -dimDistance, 0); break; case RotateDirection.NX: radian = GRadian.Radians180; dimLinePoint = start.X > end.X ? start + new Vector3d(-dimDistance, y, 0) : end + new Vector3d(-dimDistance, y, 0); break; case RotateDirection.PY: radian = GRadian.Radians90; dimLinePoint = start.X > end.X ? start + new Vector3d(x, dimDistance, 0) : end + new Vector3d(x, dimDistance, 0); break; } var result = new RotatedDimension(); if (textReplace == string.Empty) { textReplace = result.Measurement.ToString(); } result.Rotation = radian; result.XLine1Point = start; result.XLine2Point = end; result.DimLinePoint = dimLinePoint; result.DimensionText = textReplace; //result.DimensionStyle=worker. return(result); }
public void Dimtest() { //创建要标注的图形 Line line1 = new Line(new Point3d(30, 20, 0), new Point3d(120, 20, 0)); Line line2 = new Line(new Point3d(120, 20, 0), new Point3d(120, 40, 0)); Line line3 = new Line(new Point3d(120, 40, 0), new Point3d(90, 80, 0)); Line line4 = new Line(new Point3d(90, 80, 0), new Point3d(30, 80, 0)); Arc arc = new Arc(new Point3d(30, 50, 0), 30, Math.PI / 2, Math.PI * 3 / 2); Circle cir1 = new Circle(new Point3d(30, 50, 0), Vector3d.ZAxis, 15); Circle cir2 = new Circle(new Point3d(70, 50, 0), Vector3d.ZAxis, 10); Entity[] entities = new Entity[] { line1, line2, line3, line4, arc, cir1, cir2 }; List <Dimension> dims = new List <Dimension>(); RotatedDimension dimRotated1 = new RotatedDimension(); dimRotated1.XLine1Point = line1.StartPoint; dimRotated1.XLine2Point = line1.EndPoint; dimRotated1.DimLinePoint = GeTools.MidPoint(line1.StartPoint, line1.EndPoint) .PolarPoint(-Math.PI / 2, 10); dimRotated1.DimensionText = "<>mm"; dims.Add(dimRotated1); //转角标注(垂直) RotatedDimension dimRotated2 = new RotatedDimension(); dimRotated2.Rotation = Math.PI / 2; dimRotated2.XLine1Point = line2.StartPoint; dimRotated2.XLine2Point = line2.EndPoint; dimRotated2.DimLinePoint = GeTools.MidPoint( line2.StartPoint, line2.EndPoint) .PolarPoint(0, 10); dims.Add(dimRotated2); //转角标注(尺寸公差标注) RotatedDimension dimRotated3 = new RotatedDimension(); dimRotated3.XLine1Point = line4.StartPoint; dimRotated3.XLine2Point = line4.EndPoint; dimRotated3.DimLinePoint = GeTools.MidPoint( line4.StartPoint, line4.EndPoint).PolarPoint( Math.PI / 2, 10); dimRotated3.DimensionText = TextTools.StackText( "<>", "+0.026", "-0.025", StackType.Tolerance, 0.7); dims.Add(dimRotated3); entities.ToSpace(); }
// 由尺寸线旋转角度、两条尺寸界线原点和尺寸文本位置创建转角标注的函数. public static ObjectId AddDimRotated(double angle, Point3d pt1, Point3d pt2, Point3d ptText) { Database db = HostApplicationServices.WorkingDatabase; ObjectId style = db.Dimstyle; Point2d p2dt1 = new Point2d(pt1.X, pt1.Y); Point2d p2dt2 = new Point2d(pt2.X, pt2.Y); Vector2d vec = p2dt2 - p2dt1; string text = Math.Round(Math.Abs(vec.Length * Math.Cos(vec.Angle - angle)), db.Dimdec).ToString(); RotatedDimension ent = new RotatedDimension(angle, pt1, pt2, ptText, text, style); ObjectId entId = AppendEntity(ent); return(entId); }
public static ObjectId AddDimRotated(double angle, Point3d pt1, Point3d pt2, Point3d ptText) { Database workingDatabase = HostApplicationServices.WorkingDatabase; ObjectId dimstyle = workingDatabase.Dimstyle; Point2d point2d; point2d..ctor(pt1.X, pt1.Y); Point2d point2d2; point2d2..ctor(pt2.X, pt2.Y); Vector2d vector2d = point2d2 - point2d; string text = Math.Round(Math.Abs(vector2d.Length * Math.Cos(vector2d.Angle - angle)), workingDatabase.Dimdec).ToString(); RotatedDimension ent = new RotatedDimension(angle, pt1, pt2, ptText, text, dimstyle); return(ModelSpace.AddEnt(ent)); }
private static void AlignDimsToLine(DocumentModifier docMdf, RotatedDimension dim, Curve c) { // 找到标注的两个顶点 var pt2 = FindIntersect(c, dim.DimLinePoint, dim.XLine2Point); // DimLinePoint 是 XLine2Point 所对应的点 var pt1 = FindIntersect(c, dim.DimLinePoint + (dim.XLine1Point - dim.XLine2Point), dim.XLine1Point); if (pt1 != null) { dim.XLine1Point = pt1.Value; } if (pt2 != null) { dim.XLine2Point = pt2.Value; } // }
addDims(Point3d varPntLower, double dblStaStart, double dblElevStart, List <POI> varpoi, string nameLayer, double dblScaleProfileView, string txt = "") { Point3d dblPnt1 = Pub.pnt3dO, dblPnt2 = Pub.pnt3dO, dblPntX = Pub.pnt3dO; double dblMaxY = 0; ObjectId idDim = ObjectId.Null; ObjectId idDimStyle = ObjectId.Null; for (int i = 1; i < varpoi.Count; i++) { dblPnt1 = new Point3d(varPntLower.X + (varpoi[i - 1].Station - dblStaStart), varPntLower.Y + (varpoi[i - 1].Elevation - dblElevStart) * dblScaleProfileView, 0); dblPnt2 = new Point3d(varPntLower.X + (varpoi[i - 0].Station - dblStaStart), varPntLower.Y + (varpoi[i - 0].Elevation - dblElevStart) * dblScaleProfileView, 0); if ((txt == "")) { dblPntX = new Point3d(dblPnt1.X + (dblPnt2.X - dblPnt1.X) / 2, dblPnt1.Y + (dblPnt2.Y - dblPnt1.Y) / 2 + 10, 0); } else { if (dblPnt1.Y > dblPnt2.Y) { dblMaxY = dblPnt1.Y; } else { dblMaxY = dblPnt2.Y; } dblPntX = new Point3d(dblPnt1.X + (dblPnt2.X - dblPnt1.X) / 2, dblMaxY + 10, 0); } idDimStyle = Dim.getDimStyleTableRecord("Annotative"); idDim = Dim.addDimRotated(dblPnt1, dblPnt2, dblPntX, 0.0, idDimStyle, nameLayer, .09, 3); } if (txt != "") { using (Transaction tr = BaseObjs.startTransactionDb()) { RotatedDimension rotDim = (RotatedDimension)tr.GetObject(idDim, OpenMode.ForWrite); rotDim.DimensionText = txt; rotDim.Dimexo = 1.0; rotDim.Dimgap = 0.1; tr.Commit(); } } }
/// <summary> /// 水平标注 /// </summary> /// <param name="db"></param> /// <param name="P1">起点</param> /// <param name="P2">终点</param> /// <param name="Pref">标注位置</param> /// <param name="dimID">标注样式id</param> /// <param name="ang">转角,弧度</param> /// <returns></returns> public static RotatedDimension Dim0(Database db, Point3d P1, Point3d P2, Point3d Pref , ObjectId dimID, double ang = 0) { RotatedDimension D1; using (Transaction tr = db.TransactionManager.StartTransaction()) { BlockTable blockTbl = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable; BlockTableRecord modelSpace = tr.GetObject(blockTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord; D1 = new RotatedDimension(ang, P1, P2, Pref, "", dimID); D1.Layer = "标注"; modelSpace.AppendEntity(D1); tr.AddNewlyCreatedDBObject(D1, true); tr.Commit(); } return(D1); }
public static void addHorizonRotatedDimension(Database db, Point3d pt1, Point3d pt2, double distance, ObjectId dimid) { using (Transaction trans = db.TransactionManager.StartOpenCloseTransaction()) { BlockTable blockTable = trans.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable; BlockTableRecord space = trans.GetObject(blockTable[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord; RotatedDimension dimRotated = new RotatedDimension(); dimRotated.XLine1Point = pt1; dimRotated.XLine2Point = pt2; // dimRotated.DimLinePoint = new Point3d((pt1.X + pt2.X), (pt1.Y + pt2.Y), (pt1.Z + pt2.Z)).TransformBy(Matrix3d.Displacement(Vector3d.YAxis * distance)); ; //dimRotated.DimensionText = text;//<>代表標注的主尺寸,此處在標注線上插入文字 dimRotated.DimensionStyle = dimid; dimRotated.Layer = "Dim_Layer"; dimRotated.TextPosition = new Point3d((pt1.X + pt2.X) / 2, (pt1.Y + pt2.Y) / 2, (pt1.Z + pt2.Z) / 2).TransformBy(Matrix3d.Displacement(Vector3d.YAxis * distance));; space.AppendEntity(dimRotated); trans.AddNewlyCreatedDBObject(dimRotated, true); trans.Commit(); } }
public crawlAcDbRotatedDimension(RotatedDimension dim) { Entity ent = (Entity)dim; this.ObjectId = ent.ObjectId.ToString(); this.XLine1Point = new crawlPoint3d(dim.XLine1Point.X, dim.XLine1Point.Y, dim.XLine1Point.Z); this.XLine2Point = new crawlPoint3d(dim.XLine2Point.X, dim.XLine2Point.Y, dim.XLine2Point.Z); this.DimLinePoint = new crawlPoint3d(dim.DimLinePoint.X, dim.DimLinePoint.Y, dim.DimLinePoint.Z); this.TextPosition = new crawlPoint3d(dim.TextPosition.X, dim.TextPosition.Y, dim.TextPosition.Z); this.Layer = dim.Layer; this.Linetype = dim.Linetype; this.LineWeight = dim.LineWeight.ToString(); this.Color = dim.Color.ToString(); this.DimensionText = dim.DimensionText; this.DimensionStyleName = dim.DimensionStyleName; }
addDimRotated(Point3d pnt3d1, Point3d pnt3d2, Point3d pnt3dX, double rotation, ObjectId idStyle, string nameLayer, double dblTxtHeight, int precision) { ObjectId idDim = ObjectId.Null; Layer.manageLayers(nameLayer); try { using (Transaction tr = BaseObjs.startTransactionDb()) { BlockTableRecord MS = Blocks.getBlockTableRecordMS(); RotatedDimension rotDim = new RotatedDimension(); rotDim.XLine1Point = pnt3d1; rotDim.XLine2Point = pnt3d2; rotDim.DimLinePoint = pnt3dX; rotDim.DimensionStyle = idStyle; rotDim.Annotative = AnnotativeStates.True; rotDim.Dimasz = rotation; try { rotDim.Layer = nameLayer; } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Dim.cs: line: 38"); } rotDim.Dimtxt = dblTxtHeight; rotDim.Dimdec = precision; idDim = MS.AppendEntity(rotDim); tr.AddNewlyCreatedDBObject(rotDim, true); tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Dim.cs: line: 51"); } return(idDim); }
public static void Dim(LineSegment2d segment) { Document acDoc = Application.DocumentManager.MdiActiveDocument; Database acCurDb = acDoc.Database; Point2d p1 = segment.StartPoint; Point2d p2 = segment.EndPoint; //SetDimStyle(); TODO Fix Styles using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction()) { BlockTable acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) as BlockTable; BlockTableRecord acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord; using (RotatedDimension acRotDim = new RotatedDimension()) { const int n = 800; acRotDim.XLine1Point = new Point3d(p1.X, p1.Y, 0); acRotDim.XLine2Point = new Point3d(p2.X, p2.Y, 0); acRotDim.Rotation = p1.GetVectorTo(p2).Angle; Vector3d vector = acRotDim.XLine2Point.GetVectorTo(acRotDim.XLine1Point).GetNormal().MultiplyBy(n); acRotDim.DimLinePoint = acRotDim.XLine2Point.Add(vector.RotateBy(Math.PI / 2, new Vector3d(0, 0, 1))); if (acBlkTblRec != null) { acBlkTblRec.AppendEntity(acRotDim); } acTrans.AddNewlyCreatedDBObject(acRotDim, true); } acTrans.Commit(); } }
public void TestDimension() { Document acDoc = Application.DocumentManager.MdiActiveDocument; Database acCurDb = acDoc.Database; using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction()) { BlockTable acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) as BlockTable; BlockTableRecord acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord; Polyline poly0 = new Polyline(); poly0.AddVertexAt(poly0.NumberOfVertices, Point2d.Origin + Vector2d.XAxis, 0, 0, 0); poly0.AddVertexAt(poly0.NumberOfVertices, Point2d.Origin + Vector2d.XAxis + Vector2d.YAxis * 0.8, 0, 0, 0); poly0.AddVertexAt(poly0.NumberOfVertices, Point2d.Origin + Vector2d.XAxis * 0.8 + Vector2d.YAxis, 0, 0, 0); poly0.AddVertexAt(poly0.NumberOfVertices, Point2d.Origin + Vector2d.XAxis * 0.5 + Vector2d.YAxis, Math.Tan(0.25 * -1 * Math.PI), 0, 0); poly0.AddVertexAt(poly0.NumberOfVertices, Point2d.Origin + Vector2d.XAxis * -0.5 + Vector2d.YAxis, 0, 0, 0); poly0.AddVertexAt(poly0.NumberOfVertices, Point2d.Origin + Vector2d.XAxis * -1 + Vector2d.YAxis, 0, 0, 0); poly0.AddVertexAt(poly0.NumberOfVertices, Point2d.Origin + Vector2d.XAxis * -1, 0, 0, 0); poly0.Closed = true; ObjectId poly0Id = acBlkTblRec.AppendEntity(poly0); acTrans.AddNewlyCreatedDBObject(poly0, true); Polyline poly1 = new Polyline(); poly1.AddVertexAt(poly1.NumberOfVertices, Point2d.Origin + Vector2d.XAxis * 0.4 + Vector2d.YAxis * 0.25, Math.Tan(0.25 * Math.PI), 0, 0); poly1.AddVertexAt(poly1.NumberOfVertices, Point2d.Origin + Vector2d.XAxis * 0.6 + Vector2d.YAxis * 0.25, Math.Tan(0.25 * Math.PI), 0, 0); poly1.Closed = true; ObjectId poly1Id = acBlkTblRec.AppendEntity(poly1); acTrans.AddNewlyCreatedDBObject(poly1, true); Polyline poly2 = new Polyline(); poly2.AddVertexAt(poly2.NumberOfVertices, Point2d.Origin + Vector2d.XAxis * -0.4 + Vector2d.YAxis * 0.25, Math.Tan(0.25 * Math.PI), 0, 0); poly2.AddVertexAt(poly2.NumberOfVertices, Point2d.Origin + Vector2d.XAxis * -0.6 + Vector2d.YAxis * 0.25, Math.Tan(0.25 * Math.PI), 0, 0); poly2.Closed = true; ObjectId poly2Id = acBlkTblRec.AppendEntity(poly2); acTrans.AddNewlyCreatedDBObject(poly2, true); Hatch acHatch = new Hatch(); acBlkTblRec.AppendEntity(acHatch); acTrans.AddNewlyCreatedDBObject(acHatch, true); acHatch.PatternScale = 0.01; acHatch.SetHatchPattern(HatchPatternType.PreDefined, "BOX"); acHatch.Associative = true; acHatch.AppendLoop(HatchLoopTypes.Default, new ObjectIdCollection() { poly0Id }); acHatch.AppendLoop(HatchLoopTypes.Default, new ObjectIdCollection() { poly1Id }); acHatch.AppendLoop(HatchLoopTypes.Default, new ObjectIdCollection() { poly2Id }); //对齐(框线)标注 AlignedDimension acAligDimens = new AlignedDimension( Point3d.Origin - Vector3d.XAxis, Point3d.Origin + Vector3d.XAxis, Point3d.Origin + Vector3d.YAxis * -0.25, null, ObjectId.Null ); acBlkTblRec.AppendEntity(acAligDimens); acTrans.AddNewlyCreatedDBObject(acAligDimens, true); RotatedDimension acRoDimens = new RotatedDimension( 0.0, Point3d.Origin + Vector3d.XAxis * 0.8 + Vector3d.YAxis, Point3d.Origin + Vector3d.XAxis + Vector3d.YAxis * 0.8, Point3d.Origin + Vector3d.XAxis * 0.8 + Vector3d.YAxis * 1.5, null, ObjectId.Null ); acBlkTblRec.AppendEntity(acRoDimens); acTrans.AddNewlyCreatedDBObject(acRoDimens, true); acTrans.Commit(); } }
private static RotatedDimension addDim(BlockTableRecord btr, Transaction t, Point3d ptPrev, Point3d ptNext, Point3d ptDimLine, double rotation = 0) { var dim = new RotatedDimension(rotation.ToRadians(), ptPrev, ptNext, ptDimLine, "", RollUpService.IdDimStylePik); dim.Dimscale = 100; btr.AppendEntity(dim); t.AddNewlyCreatedDBObject(dim, true); return dim; }
public void TendonAnnotation() { Document doc = Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; Editor ed = doc.Editor; using (Transaction trans = db.TransactionManager.StartTransaction()) { //1.选择梁顶缘线 PromptEntityOptions tpLineOpt = new PromptEntityOptions("\n选择梁顶缘线"); tpLineOpt.SetRejectMessage("\n顶缘线应为直线、圆弧或多段线"); tpLineOpt.AddAllowedClass(typeof(Line), true); //可以选择直线 tpLineOpt.AddAllowedClass(typeof(Polyline), true); //可以选择多段线 tpLineOpt.AddAllowedClass(typeof(Arc), true); //可以选择圆弧线 PromptEntityResult tpLineRes = ed.GetEntity(tpLineOpt); if (tpLineRes.Status != PromptStatus.OK) { return; } ObjectId tpLineId = tpLineRes.ObjectId; Curve tpLine = trans.GetObject(tpLineId, OpenMode.ForRead) as Curve; //2.选择钢束线 PromptEntityOptions tdLineOpt = new PromptEntityOptions("\n选择钢束"); tdLineOpt.SetRejectMessage("\n钢束应为多段线"); tdLineOpt.AddAllowedClass(typeof(Polyline), true);//仅能选择多段线 PromptEntityResult tdLineRes = ed.GetEntity(tdLineOpt); if (tdLineRes.Status != PromptStatus.OK) { return; } ObjectId tdLineId = tdLineRes.ObjectId; Polyline tdLine = trans.GetObject(tdLineId, OpenMode.ForRead) as Polyline; //判断钢束线是否在顶缘线以内,否则报错返回 if (tdLine.StartPoint.X < tpLine.StartPoint.X || tdLine.EndPoint.X > tpLine.EndPoint.X) { Application.ShowAlertDialog("钢束线超出顶缘线,请检查!"); return; } //3.设置绘图参数 //3.1 绘图比例 PromptDoubleOptions scaleOpt = new PromptDoubleOptions($"\n设置绘图比例<{scale}>"); scaleOpt.AllowNone = true; //允许回车,则采用前次比例 scaleOpt.AllowNegative = false; //不允许负值 scaleOpt.AllowZero = false; //不允许零值 PromptDoubleResult scaleRes = ed.GetDouble(scaleOpt); //获取比例 if (scaleRes.Status != PromptStatus.OK && scaleRes.Status != PromptStatus.None) { return; } else if (scaleRes.Status == PromptStatus.OK) { scale = scaleRes.Value; } //3.2 尺寸标注绘图位置 PromptPointOptions posOpt = new PromptPointOptions("\n设置标注线位置"); PromptPointResult posRes = ed.GetPoint(posOpt); if (posRes.Status != PromptStatus.OK) { return; } Point3d pos = posRes.Value; //4.开始建立标注 List <Point3d> ptsH = new List <Point3d>(); //创建水平标注点集 List <Dimension> dims = new List <Dimension>(); //创建标注集,存放各类标注 for (int i = 0; i < tdLine.NumberOfVertices - 1; i++) { //4.1 水平点集 ptsH.Add(tdLine.GetPoint3dAt(i)); //4.2 每段钢束线的长度 //4.3 直线标注角度 //4.4 圆弧线标注半径 if (tdLine.GetSegmentType(i) == SegmentType.Line) { LineSegment3d lineSeg = tdLine.GetLineSegmentAt(i); //4.2 每段钢束线的长度 db.LineLengthDim(lineSeg, scale); //4.3 直线标注角度 if (tdLine.StartPoint.X < tdLine.EndPoint.X) { db.LineAngelDim(lineSeg, !(i == tdLine.NumberOfVertices - 2), scale); } else { db.LineAngelDim(lineSeg, (i == tdLine.NumberOfVertices - 2), scale); } } else if (tdLine.GetSegmentType(i) == SegmentType.Arc) { CircularArc3d arcSeg = tdLine.GetArcSegmentAt(i); //4.2 每段钢束线的长度 db.ArcLengthDim(arcSeg, scale); //4.3 圆弧标注半径 db.ArrowRadiusDim(arcSeg, scale); } //4.5 竖直距离标注 Ray vRay = new Ray();//建立竖直射线 vRay.BasePoint = tdLine.GetPoint3dAt(i); vRay.UnitDir = new Vector3d(0, 1, 0); Point3dCollection ptIntersects = new Point3dCollection(); tpLine.IntersectWith(vRay, Intersect.OnBothOperands, ptIntersects, IntPtr.Zero, IntPtr.Zero); Point3d ptIntersect = ptIntersects[0]; RotatedDimension dimV = new RotatedDimension(); dimV.XLine1Point = tdLine.GetPoint3dAt(i); //第一条尺寸边线 dimV.XLine2Point = ptIntersect; //第二条尺寸边线 dimV.DimLinePoint = tdLine.GetPoint3dAt(i); //尺寸线位置 dimV.Rotation = Math.PI / 2; //标注旋转90度 dimV.DimensionStyle = db.Dimstyle; //尺寸样式为当前样式 dimV.Dimscale = scale; //设置尺寸全局比例 dims.Add(dimV); } //4.1 节点间距点集缺钢束最后一个点、梁顶缘线端点 ptsH.Add(tdLine.EndPoint); ptsH.Add(tpLine.StartPoint); ptsH.Add(tpLine.EndPoint); db.ContinuedHorizontalDims(ptsH, pos, scale);//建立水平连续标注 //4.5 竖直距离标注缺最后一个点 Ray vRayLast = new Ray();//建立竖直射线 vRayLast.BasePoint = tdLine.GetPoint3dAt(tdLine.NumberOfVertices - 1); vRayLast.UnitDir = new Vector3d(0, 1, 0); Point3dCollection ptIntersectsLast = new Point3dCollection(); tpLine.IntersectWith(vRayLast, Intersect.OnBothOperands, ptIntersectsLast, IntPtr.Zero, IntPtr.Zero); Point3d ptIntersectLast = ptIntersectsLast[0]; RotatedDimension dimVLast = new RotatedDimension(); dimVLast.XLine1Point = tdLine.GetPoint3dAt(tdLine.NumberOfVertices - 1); //第一条尺寸边线 dimVLast.XLine2Point = ptIntersectLast; //第二条尺寸边线 dimVLast.DimLinePoint = tdLine.GetPoint3dAt(tdLine.NumberOfVertices - 1); //尺寸线位置 dimVLast.Rotation = Math.PI / 2; //标注旋转90度 dimVLast.DimensionStyle = db.Dimstyle; //尺寸样式为当前样式 dimVLast.Dimscale = scale; //设置尺寸全局比例 dims.Add(dimVLast); //4.6 绘制张拉端 //4.6.1 绘制两侧张拉段 //获取钢束线真实的起点和终点 Point3d tdStart = (tdLine.StartPoint.X < tdLine.EndPoint.X) ? tdLine.StartPoint : tdLine.EndPoint; Point3d tdEnd = (tdLine.StartPoint.X < tdLine.EndPoint.X) ? tdLine.EndPoint : tdLine.StartPoint; //获取钢束线真实的起终点角度 double iclStart = (tdLine.StartPoint.X < tdLine.EndPoint.X) ? GetAngleOfLineSeg(tdLine.GetLineSegmentAt(0)) : GetAngleOfLineSeg(tdLine.GetLineSegmentAt(tdLine.NumberOfVertices - 2)); double iclEnd = (tdLine.StartPoint.X < tdLine.EndPoint.X) ? GetAngleOfLineSeg(tdLine.GetLineSegmentAt(tdLine.NumberOfVertices - 2)) : GetAngleOfLineSeg(tdLine.GetLineSegmentAt(0)); //创建张拉端几何点 Point3d tdDrawL = GeTools.PolarPoint(tdStart, iclStart, -800); Point3d tdDrawR = GeTools.PolarPoint(tdEnd, iclEnd, 800); //创建张拉段 Line leftDraw = new Line(tdDrawL, tdStart); leftDraw.Layer = tdLine.Layer; //张拉段与钢束线应该在同一层 Line rightDraw = new Line(tdDrawR, tdEnd); rightDraw.Layer = tdLine.Layer; //张拉段与钢束线应该在同一层 //4.6.2 标注张拉段的长度 //左侧张拉段 MText lengthL = new MText(); //长度 lengthL.Contents = "工作长度800"; //文字高度 lengthL.TextHeight = 3 * scale; //样式为当前样式 lengthL.TextStyleId = db.Textstyle; //旋转角度同直线段倾角 lengthL.Rotation = iclStart; //对齐位置为右上 lengthL.Attachment = AttachmentPoint.TopRight; //位置为中点垂线以下0.5个单位 lengthL.Location = GeTools.PolarPoint(GeTools.MidPoint(leftDraw.StartPoint, leftDraw.EndPoint), iclStart - Math.PI / 2, 0.5 * scale); //右侧张拉段 MText lengthR = new MText(); //长度 lengthR.Contents = "工作长度800"; //文字高度 lengthR.TextHeight = 3 * scale; //样式为当前样式 lengthR.TextStyleId = db.Textstyle; //旋转角度同直线段倾角 lengthR.Rotation = iclEnd; //对齐位置为左上 lengthR.Attachment = AttachmentPoint.TopLeft; //位置为中点垂线以下0.5个单位 lengthR.Location = GeTools.PolarPoint(GeTools.MidPoint(rightDraw.StartPoint, rightDraw.EndPoint), iclEnd - Math.PI / 2, 0.5 * scale); //4.7 在截面顶缘标识“梁顶缘线” Point3d midPt = GeTools.MidPoint(tpLine.StartPoint, tpLine.EndPoint); //顶缘线起终点中点 Point3d midPtInTp = tpLine.GetClosestPointTo(midPt, Vector3d.YAxis, true); //顶缘线上靠近中点的点 MText tpAnno = new MText(); tpAnno.Contents = "梁顶缘线"; //文字高度 tpAnno.TextHeight = 3 * scale; //样式为当前样式 tpAnno.TextStyleId = db.Textstyle; //对齐位置为右上 tpAnno.Attachment = AttachmentPoint.BottomLeft; //位置为中点以上0.5个单位 tpAnno.Location = GeTools.PolarPoint(midPtInTp, Math.PI / 2, 0.5 * scale); db.AddToModelSpace(dims.ToArray()); //添加各类标注 db.AddToModelSpace(leftDraw, rightDraw, lengthL, lengthR); //添加张拉段线 db.AddToModelSpace(tpAnno); //添加梁顶缘线标识 trans.Commit(); } }
public void Cmd_GenDims() { var acCurDoc = Application.DocumentManager.MdiActiveDocument; var acCurDb = acCurDoc.Database; var acCurEd = acCurDoc.Editor; var objIds = acCurEd.GetAllSelection(false); if (objIds.Length <= 0) { return; } using (var pWorker = new ProgressAgent("Generating Dimension: ", objIds.Length)) { using (var acTrans = acCurDb.TransactionManager.StartTransaction()) { foreach (var obj in objIds) { if (!pWorker.Progress()) { acTrans.Abort(); return; } var acEnt = acTrans.GetObject(obj, OpenMode.ForRead) as Entity; if (acEnt == null) { continue; } var extents = acEnt.GeometricExtents; var minPt = extents.MinPoint; var maxPt = extents.MaxPoint; // Create the rotated dimension using (var acXDim = new RotatedDimension()) { acXDim.XLine1Point = new Point3d(minPt.X, minPt.Y, 0); acXDim.XLine2Point = new Point3d(maxPt.X, minPt.Y, 0); acXDim.DimLinePoint = new Point3d(minPt.X, minPt.Y - SettingsUser.AnnoSpacing, 0); acXDim.DimensionStyle = acCurDb.Dimstyle; // Add the new object to Model space and the transaction acCurDb.AppendEntity(acXDim); } // Create the rotated dimension using (var acYDim = new RotatedDimension()) { acYDim.XLine1Point = new Point3d(minPt.X, minPt.Y, 0); acYDim.XLine2Point = new Point3d(minPt.X, maxPt.Y, 0); acYDim.Rotation = CalcUnit.ConvertToRadians(90); acYDim.DimLinePoint = new Point3d(minPt.X - SettingsUser.AnnoSpacing, minPt.Y, 0); acYDim.DimensionStyle = acCurDb.Dimstyle; // Add the new object to Model space and the transaction acCurDb.AppendEntity(acYDim); } } acTrans.Commit(); } } }
private static void CreateDimension(Point3d CommonDimPos, Point3d[] dimPos, Direction dimDir) { Document doc = Application.DocumentManager.MdiActiveDocument; Database dBase = doc.Database; using (Transaction acTrans = doc.TransactionManager.StartTransaction()) { BlockTable blockTable1; blockTable1 = acTrans.GetObject(dBase.BlockTableId, OpenMode.ForRead) as BlockTable; BlockTableRecord recBT; recBT = acTrans.GetObject(blockTable1[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord; for (int i = 0; i < +dimPos.Length; i++) { Point3d dimOrigin = new Point3d( ); double rotationAng = 0; double offsetFactor = i + 1.5; if (dimDir == Direction.Horizontal) { dimOrigin = new Point3d((CommonDimPos.X + dimPos[i].X) / 2, dimPos[i].Y + offsetFactor * pipeRadius, 0); if (bendAngle == 90) { rotationAng = System.Math.PI; } else { rotationAng = 1.25 * System.Math.PI; } } else { dimOrigin = new Point3d(CommonDimPos.X - offsetFactor * pipeRadius, (dimPos[i].Y + dimPos[i].Y) / 2, 0); rotationAng = 0.5 * System.Math.PI; } RotatedDimension rotatedDim = new RotatedDimension(); rotatedDim.SetDatabaseDefaults(); rotatedDim.XLine1Point = CommonDimPos; rotatedDim.XLine2Point = dimPos[i]; rotatedDim.DimLinePoint = dimOrigin; rotatedDim.DimensionStyle = dBase.Dimstyle; rotatedDim.Rotation = rotationAng; rotatedDim.Layer = "IE_Object_Layer"; recBT.AppendEntity(rotatedDim); acTrans.AddNewlyCreatedDBObject(rotatedDim, true); } acTrans.Commit(); } }
private string jsonGetObjectData(ObjectId id_platf) { string result = ""; try {//Всякое может случиться //Открываем переданный в функцию объект на чтение, преобразуем его к Entity Entity ent = (Entity)id_platf.GetObject(OpenMode.ForRead); //Далее последовательно проверяем класс объекта на соответствие классам основных примитивов if (id_platf.ObjectClass.Name == "AcDbLine") { //Если объект - отрезок (line) crawlAcDbLine kline = new crawlAcDbLine((Line)ent); //Преобразуем к типу линия result = jsonHelper.To <crawlAcDbLine>(kline); } else if (id_platf.ObjectClass.Name == "AcDbPolyline") {//Если объект - полилиния Polyline kpLine = (Polyline)ent; crawlAcDbPolyline jpline = new crawlAcDbPolyline(kpLine); result = jsonHelper.To <crawlAcDbPolyline>(jpline); } else if (id_platf.ObjectClass.Name == "AcDb2dPolyline") {//2D полилиния - такие тоже попадаются Polyline2d kpLine = (Polyline2d)ent; crawlAcDbPolyline jpline = new crawlAcDbPolyline(kpLine); result = jsonHelper.To <crawlAcDbPolyline>(jpline); } else if (id_platf.ObjectClass.Name == "AcDb3dPolyline") {//2D полилиния - такие тоже попадаются Polyline3d kpLine = (Polyline3d)ent; crawlAcDbPolyline jpline = new crawlAcDbPolyline(kpLine); result = jsonHelper.To <crawlAcDbPolyline>(jpline); } else if (id_platf.ObjectClass.Name == "AcDbText") { //Текст DBText dbtxt = (DBText)ent; crawlAcDbText jtext = new crawlAcDbText(dbtxt); result = jsonHelper.To <crawlAcDbText>(jtext); } else if (id_platf.ObjectClass.Name == "AcDbMText") {//Мтекст MText mtxt = (MText)ent; crawlAcDbMText jtext = new crawlAcDbMText(mtxt); result = jsonHelper.To <crawlAcDbMText>(jtext); } else if (id_platf.ObjectClass.Name == "AcDbArc") {//Дуга Arc arc = (Arc)ent; crawlAcDbArc cArc = new crawlAcDbArc(arc); result = jsonHelper.To <crawlAcDbArc>(cArc); } else if (id_platf.ObjectClass.Name == "AcDbCircle") {//Окружность Circle circle = (Circle)ent; crawlAcDbCircle cCircle = new crawlAcDbCircle(circle); result = jsonHelper.To <crawlAcDbCircle>(cCircle); } else if (id_platf.ObjectClass.Name == "AcDbEllipse") { //Эллипс Ellipse el = (Ellipse)ent; crawlAcDbEllipse cEll = new crawlAcDbEllipse(el); result = jsonHelper.To <crawlAcDbEllipse>(cEll); } else if (id_platf.ObjectClass.Name == "AcDbAlignedDimension") {//Размер повернутый AlignedDimension dim = (AlignedDimension)ent; crawlAcDbAlignedDimension rDim = new crawlAcDbAlignedDimension(dim); result = jsonHelper.To <crawlAcDbAlignedDimension>(rDim); } else if (id_platf.ObjectClass.Name == "AcDbRotatedDimension") {//Размер повернутый RotatedDimension dim = (RotatedDimension)ent; crawlAcDbRotatedDimension rDim = new crawlAcDbRotatedDimension(dim); result = jsonHelper.To <crawlAcDbRotatedDimension>(rDim); } else if (id_platf.ObjectClass.Name == "AcDbPoint3AngularDimension") {//Угловой размер по 3 точкам Point3AngularDimension dim = (Point3AngularDimension)ent; crawlAcDbPoint3AngularDimension rDim = new crawlAcDbPoint3AngularDimension(dim); result = jsonHelper.To <crawlAcDbPoint3AngularDimension>(rDim); } else if (id_platf.ObjectClass.Name == "AcDbLineAngularDimension2") {//Еще угловой размер по точкам LineAngularDimension2 dim = (LineAngularDimension2)ent; crawlAcDbLineAngularDimension2 rDim = new crawlAcDbLineAngularDimension2(dim); result = jsonHelper.To <crawlAcDbLineAngularDimension2>(rDim); } else if (id_platf.ObjectClass.Name == "AcDbDiametricDimension") { //Размер диаметра окружности DiametricDimension dim = (DiametricDimension)ent; crawlAcDbDiametricDimension rDim = new crawlAcDbDiametricDimension(dim); result = jsonHelper.To <crawlAcDbDiametricDimension>(rDim); } else if (id_platf.ObjectClass.Name == "AcDbArcDimension") { //Дуговой размер ArcDimension dim = (ArcDimension)ent; crawlAcDbArcDimension rDim = new crawlAcDbArcDimension(dim); result = jsonHelper.To <crawlAcDbArcDimension>(rDim); } else if (id_platf.ObjectClass.Name == "AcDbRadialDimension") { //Радиальный размер RadialDimension dim = (RadialDimension)ent; crawlAcDbRadialDimension rDim = new crawlAcDbRadialDimension(dim); result = jsonHelper.To <crawlAcDbRadialDimension>(rDim); } else if (id_platf.ObjectClass.Name == "AcDbAttributeDefinition") { //Атрибут блока AttributeDefinition ad = (AttributeDefinition)ent; crawlAcDbAttributeDefinition atd = new crawlAcDbAttributeDefinition(ad); result = jsonHelper.To <crawlAcDbAttributeDefinition>(atd); } else if (id_platf.ObjectClass.Name == "AcDbHatch") {//Штриховка Teigha.DatabaseServices.Hatch htch = ent as Teigha.DatabaseServices.Hatch; crawlAcDbHatch cHtch = new crawlAcDbHatch(htch); result = jsonHelper.To <crawlAcDbHatch>(cHtch); } else if (id_platf.ObjectClass.Name == "AcDbSpline") {//Сплайн Spline spl = ent as Spline; crawlAcDbSpline cScpline = new crawlAcDbSpline(spl); result = jsonHelper.To <crawlAcDbSpline>(cScpline); } else if (id_platf.ObjectClass.Name == "AcDbPoint") {//Точка DBPoint Pnt = ent as DBPoint; crawlAcDbPoint pt = new crawlAcDbPoint(Pnt); result = jsonHelper.To <crawlAcDbPoint>(pt); } else if (id_platf.ObjectClass.Name == "AcDbBlockReference") {//Блок BlockReference blk = ent as BlockReference; crawlAcDbBlockReference cBlk = new crawlAcDbBlockReference(blk); result = jsonHelper.To <crawlAcDbBlockReference>(cBlk); //newDocument(id_platf, result); } else if (id_platf.ObjectClass.Name == "AcDbProxyEntity") {//Прокси ProxyEntity pxy = ent as ProxyEntity; crawlAcDbProxyEntity cBlk = new crawlAcDbProxyEntity(pxy); result = jsonHelper.To <crawlAcDbProxyEntity>(cBlk); DocumentFromBlockOrProxy(id_platf, result); } else if (id_platf.ObjectClass.Name == "AcDbSolid") {//Солид 2Д Solid solid = (Solid)ent; crawlAcDbSolid cSld = new crawlAcDbSolid(solid); result = jsonHelper.To <crawlAcDbSolid>(cSld); } /* * * * else if (id_platf.ObjectClass.Name == "AcDbLeader") * { //Выноска Autocad * Leader ld = (Leader)ent; * * if (ld.EndPoint.Z != 0 || ld.StartPoint.Z != 0) * { * //ed.WriteMessage("DEBUG: Преобразован объект: Выноска Autocad"); * * ld.EndPoint = new Point3d(ld.EndPoint.X, ld.EndPoint.Y, 0); * ld.StartPoint = new Point3d(ld.StartPoint.X, ld.StartPoint.Y, 0); * * result = true; * }; * * } * /* * else if (id_platf.ObjectClass.Name == "AcDbPolygonMesh") * { * BUG: В платформе нет API для доступа к вершинам сетей AcDbPolygonMesh и AcDbPolygonMesh и AcDbSurface * * } * else if (id_platf.ObjectClass.Name == "AcDbSolid") * { * BUG: Чтобы плющить Solid-ы нужны API функции 3d * } * else if (id_platf.ObjectClass.Name == "AcDbRegion") * { * Region rgn = ent as Region; * BUG: нет свойств у региона * } * */ else { //Если объект не входит в число перечисленных типов, //то выводим в командную строку класс этого необработанного объекта cDebug.WriteLine("Не могу обработать тип объекта: " + id_platf.ObjectClass.Name); } } catch (System.Exception ex) { //Если что-то сломалось, то в командную строку выводится ошибка cDebug.WriteLine("Не могу преобразовать - ошибка: " + ex.Message); }; //Возвращаем значение функции return(result); }
/// <summary> /// 读取dwg中entities信息 /// </summary> public static void GetDwgGeometry(string layerName) { Database db = HostApplicationServices.WorkingDatabase; using (Transaction trans = db.TransactionManager.StartTransaction()) { LayerTable lt = (LayerTable)trans.GetObject(db.LayerTableId, OpenMode.ForRead); if (lt.Has(layerName)) { BlockTableRecord ltr = (BlockTableRecord)trans.GetObject(db.CurrentSpaceId, OpenMode.ForRead); int a, r, g, b = 0; foreach (ObjectId objId in ltr) { Entity ent = (Entity)trans.GetObject(objId, OpenMode.ForRead); #region 遍历entities if (ent.Layer == layerName) { string type = ent.GetType().ToString().Replace("Autodesk.AutoCAD.DatabaseServices.", ""); if (type == "Line") { Line line = (Line)ent; //EntityLayer.Add(line.Layer); //EntityType.Add(type); //LineType.Add(line.Linetype); a = line.Color.ColorValue.A; r = line.Color.ColorValue.R; g = line.Color.ColorValue.G; b = line.Color.ColorValue.B; EntityColor.Add(RgbToHex(a, r, g, b)); EntityHandle.Add(line.Handle); TextRotation.Add("null"); //Coordinate.Add(line.StartPoint + "," + line.EndPoint); //Text.Add("null"); //Height.Add("null"); //LineWidth.Add(line.LineWeight); //CRadius.Add("null"); //ExtenedEntity.Add("null"); } else if (type == "AttributeDefinition") { AttributeDefinition attribute = (AttributeDefinition)ent; //EntityLayer.Add(attribute.Layer); //EntityType.Add(type); EntityHandle.Add(attribute.Handle); //LineType.Add("null"); a = attribute.Color.ColorValue.A; r = attribute.Color.ColorValue.R; g = attribute.Color.ColorValue.G; b = attribute.Color.ColorValue.B; EntityColor.Add(RgbToHex(a, r, g, b)); TextRotation.Add("null"); //Coordinate.Add(attribute.Position); //Text.Add("null"); //Height.Add("null"); //LineWidth.Add("null"); //CRadius.Add("null"); //ExtenedEntity.Add(attribute.ExtensionDictionary); } else if (type == "DBPoint") { DBPoint dbpoint = (DBPoint)ent; //EntityLayer.Add(dbpoint.Layer); //EntityType.Add(type); EntityHandle.Add(dbpoint.Handle); //LineType.Add(dbpoint.Linetype); a = dbpoint.Color.ColorValue.A; r = dbpoint.Color.ColorValue.R; g = dbpoint.Color.ColorValue.G; b = dbpoint.Color.ColorValue.B; EntityColor.Add(RgbToHex(a, r, g, b)); TextRotation.Add("null"); //Coordinate.Add(dbpoint.Position); //Text.Add("null"); //Height.Add("null"); //LineWidth.Add("null"); //CRadius.Add("null"); //ExtenedEntity.Add("null"); } else if (type == "Ellipse") { Ellipse ellipse = (Ellipse)ent; //EntityLayer.Add(ellipse.Layer); //EntityType.Add(type); EntityHandle.Add(ellipse.Handle); //LineType.Add("null"); a = ellipse.Color.ColorValue.A; r = ellipse.Color.ColorValue.R; g = ellipse.Color.ColorValue.G; b = ellipse.Color.ColorValue.B; EntityColor.Add(RgbToHex(a, r, g, b)); TextRotation.Add("null"); //Coordinate.Add(ellipse.GetPlane().GetCoordinateSystem()); //Text.Add("null"); //Height.Add("null"); //LineWidth.Add("null"); //CRadius.Add("null"); //ExtenedEntity.Add("null"); } else if (type == "DBText") { DBText dbtext = (DBText)ent; //EntityLayer.Add(dbtext.Layer); //EntityType.Add(type); EntityHandle.Add(dbtext.Handle); TextRotation.Add(dbtext.Rotation); //LineType.Add("null"); a = dbtext.Color.ColorValue.A; r = dbtext.Color.ColorValue.R; g = dbtext.Color.ColorValue.G; b = dbtext.Color.ColorValue.B; EntityColor.Add(RgbToHex(a, r, g, b)); //Coordinate.Add(dbtext.Position); Text.Add(dbtext.TextString); //Height.Add(dbtext.Height); //LineWidth.Add("null"); //CRadius.Add("null"); //ExtenedEntity.Add("null"); if (dbtext.TextString.Contains("说明")) { _position = dbtext.Position.ToString(); } } else if (type == "RadialDimension") { RadialDimension radial = (RadialDimension)ent; //EntityLayer.Add(radial.Layer); //EntityType.Add(type); EntityHandle.Add(radial.Handle); //LineType.Add("null"); a = radial.Color.ColorValue.A; r = radial.Color.ColorValue.R; g = radial.Color.ColorValue.G; b = radial.Color.ColorValue.B; EntityColor.Add(RgbToHex(a, r, g, b)); TextRotation.Add("null"); //Coordinate.Add(radial.GetPlane().GetCoordinateSystem()); //Text.Add("null"); //Height.Add("null"); //LineWidth.Add("null"); //CRadius.Add("null"); //ExtenedEntity.Add(radial.ExtensionDictionary); } else if (type == "AlignedDimension") { AlignedDimension aligned = (AlignedDimension)ent; //EntityLayer.Add(aligned.Layer); //EntityType.Add(type); EntityHandle.Add(aligned.Handle); //LineType.Add("null"); a = aligned.Color.ColorValue.A; r = aligned.Color.ColorValue.R; g = aligned.Color.ColorValue.G; b = aligned.Color.ColorValue.B; EntityColor.Add(RgbToHex(a, r, g, b)); TextRotation.Add("null"); //Coordinate.Add(aligned.GeometricExtents); //Text.Add(aligned.TextAttachment); //Height.Add("null"); //LineWidth.Add("null"); //CRadius.Add("null"); //ExtenedEntity.Add("null"); } else if (type == "Spline") { Spline spline = (Spline)ent; //EntityLayer.Add(spline.Layer); //EntityType.Add(type); EntityHandle.Add(spline.Handle); //LineType.Add(spline.Linetype); a = spline.Color.ColorValue.A; r = spline.Color.ColorValue.R; g = spline.Color.ColorValue.G; b = spline.Color.ColorValue.B; EntityColor.Add(RgbToHex(a, r, g, b)); TextRotation.Add("null"); //List<Point3d> points_spline = new List<Point3d>(); //for(int i = 0; i < spline.NumControlPoints; i++) //{ // points_spline.Add(spline.GetControlPointAt(i)); //} //Coordinate.Add(points_spline); //Text.Add("null"); //Height.Add("null"); //LineWidth.Add(spline.LineWeight); //CRadius.Add("null"); //ExtenedEntity.Add("null"); } else if (type == "RotatedDimension") { RotatedDimension rotate = (RotatedDimension)ent; //EntityLayer.Add(rotate.Layer); //EntityType.Add(type); EntityHandle.Add(rotate.Handle); //LineType.Add("null"); a = rotate.Color.ColorValue.A; r = rotate.Color.ColorValue.R; g = rotate.Color.ColorValue.G; b = rotate.Color.ColorValue.B; EntityColor.Add(RgbToHex(a, r, g, b)); TextRotation.Add("null"); //Coordinate.Add(rotate.GeometricExtents); //Text.Add("null"); //Height.Add("null"); //LineWidth.Add("null"); //CRadius.Add("null"); //ExtenedEntity.Add(rotate.ExtensionDictionary); } else if (type == "Polyline") { Polyline pline = (Polyline)ent; //EntityLayer.Add(pline.Layer); //EntityType.Add(type); EntityHandle.Add(pline.Handle); //LineType.Add(pline.Linetype); a = pline.Color.ColorValue.A; r = pline.Color.ColorValue.R; g = pline.Color.ColorValue.G; b = pline.Color.ColorValue.B; EntityColor.Add(RgbToHex(a, r, g, b)); TextRotation.Add("null"); //CRadius.Add("null"); //List<Point3d> points_polyline = new List<Point3d>(); //for(int i = 0; i < pline.NumberOfVertices; i++) //{ // points_polyline.Add(pline.GetPoint3dAt(i)); //} //Coordinate.Add(points_polyline); //Text.Add("null"); //Height.Add("null"); //LineWidth.Add(pline.LineWeight); //ExtenedEntity.Add("null"); } else if (type == "MText") { MText mtext = (MText)ent; //EntityLayer.Add(mtext.Layer); //EntityType.Add(type); EntityHandle.Add(mtext.Handle); TextRotation.Add(mtext.Rotation); //LineType.Add("null"); a = mtext.Color.ColorValue.A; r = mtext.Color.ColorValue.R; g = mtext.Color.ColorValue.G; b = mtext.Color.ColorValue.B; EntityColor.Add(RgbToHex(a, r, g, b)); //Coordinate.Add(mtext.Location); //Text.Add(mtext.Contents); //Height.Add(mtext.Height); //LineWidth.Add("null"); //CRadius.Add("null"); //ExtenedEntity.Add("null"); if (mtext.Text.Contains("说明")) { _position = mtext.Location.ToString(); } } else if (type == "Arc") { Arc arc = (Arc)ent; //EntityLayer.Add(arc.Layer); //EntityType.Add(type); EntityHandle.Add(arc.Handle); //LineType.Add("null"); a = arc.Color.ColorValue.A; r = arc.Color.ColorValue.R; g = arc.Color.ColorValue.G; b = arc.Color.ColorValue.B; EntityColor.Add(RgbToHex(a, r, g, b)); TextRotation.Add("null"); //Coordinate.Add(arc.Center); //Text.Add("null"); //Height.Add("null"); //LineWidth.Add("null"); //CRadius.Add(arc.Radius); //ExtenedEntity.Add("null"); } else if (type == "Hatch") { Hatch hatch = (Hatch)ent; //EntityLayer.Add(hatch.Layer); //EntityType.Add(type); EntityHandle.Add(hatch.Handle); //LineType.Add("null"); a = hatch.Color.ColorValue.A; r = hatch.Color.ColorValue.R; g = hatch.Color.ColorValue.G; b = hatch.Color.ColorValue.B; EntityColor.Add(RgbToHex(a, r, g, b)); TextRotation.Add("null"); //Coordinate.Add(hatch.GeometricExtents); //Text.Add("null"); //Height.Add("null"); //LineWidth.Add("null"); //CRadius.Add("null"); //ExtenedEntity.Add(hatch.ExtensionDictionary); } else if (type == "Dimension") { Dimension dim = (Dimension)ent; //EntityLayer.Add(dim.Layer); //EntityType.Add(type); EntityHandle.Add(dim.Handle); //LineType.Add("null"); a = dim.Color.ColorValue.A; r = dim.Color.ColorValue.R; g = dim.Color.ColorValue.G; b = dim.Color.ColorValue.B; EntityColor.Add(RgbToHex(a, r, g, b)); TextRotation.Add("null"); //Coordinate.Add(dim.TextPosition); //Text.Add("null"); //Height.Add("null"); //LineWidth.Add("null"); //CRadius.Add("null"); //ExtenedEntity.Add(dim.ExtensionDictionary); } else if (type == "Circle") { Circle circle = (Circle)ent; //EntityLayer.Add(circle.Layer); //EntityType.Add(type); EntityHandle.Add(circle.Handle); //LineType.Add("null"); a = circle.Color.ColorValue.A; r = circle.Color.ColorValue.R; g = circle.Color.ColorValue.G; b = circle.Color.ColorValue.B; EntityColor.Add(RgbToHex(a, r, g, b)); TextRotation.Add("null"); //Coordinate.Add(circle.Center); //Text.Add("null"); //Height.Add("null"); //LineWidth.Add("null"); //CRadius.Add(circle.Radius); //ExtenedEntity.Add("null"); } else if (type == "BlockReference") { BlockReference block = (BlockReference)ent; //EntityLayer.Add(block.Layer); //EntityType.Add(type); EntityHandle.Add(block.Handle); //LineType.Add("null"); a = block.Color.ColorValue.A; r = block.Color.ColorValue.R; g = block.Color.ColorValue.G; b = block.Color.ColorValue.B; EntityColor.Add(RgbToHex(a, r, g, b)); TextRotation.Add("null"); //Coordinate.Add(block.GeometricExtents); //Text.Add("null"); //Height.Add("null"); //LineWidth.Add("null"); //CRadius.Add("null"); //ExtenedEntity.Add(block.ExtensionDictionary); } else { //EntityLayer.Add("null"); //EntityType.Add("null"); //EntityHandle.Add("null"); //LineType.Add("null"); //EntityColor.Add("null"); //Coordinate.Add("null"); //Text.Add("null"); //Height.Add("null"); //LineWidth.Add("null"); //CRadius.Add("null"); //ExtenedEntity.Add("null"); } #endregion } } } trans.Commit(); } }
public static void GetInfoDirectas() { bool? oked = false; Document acDoc = Application.DocumentManager.MdiActiveDocument; Database acCurDb = acDoc.Database; System.Windows.Window win = new Directas(); oked = Application.ShowModalWindow(win); oked = true; if (oked.HasValue && oked.Value) { Directas instance = (Directas)win; List <Directas.Apoyo> apoyos; if (instance.finalizo) { apoyos = instance.apoyos; using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction()) { BlockTable acBlkTbl; acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) as BlockTable; BlockTableRecord acBlkTblRec; acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord; Polyline[] acPoly = new Polyline[apoyos.Count]; Polyline[] columna = new Polyline[apoyos.Count]; Point3d[] points = new Point3d[apoyos.Count]; for (int i = 0; i < apoyos.Count; i++) { if (apoyos[i].Dimensionar) { using (acPoly[i] = new Polyline()) { acPoly[i].AddVertexAt(0, new Point2d(apoyos[i].Vertice1X, apoyos[i].Vertice1Y), 0, 0, 0); acPoly[i].AddVertexAt(1, new Point2d(apoyos[i].Vertice2X, apoyos[i].Vertice2Y), 0, 0, 0); acPoly[i].AddVertexAt(2, new Point2d(apoyos[i].Vertice4X, apoyos[i].Vertice4Y), 0, 0, 0); acPoly[i].AddVertexAt(3, new Point2d(apoyos[i].Vertice3X, apoyos[i].Vertice3Y), 0, 0, 0); acPoly[i].AddVertexAt(4, new Point2d(apoyos[i].Vertice1X, apoyos[i].Vertice1Y), 0, 0, 0); acBlkTblRec.AppendEntity(acPoly[i]); acTrans.AddNewlyCreatedDBObject(acPoly[i], true); } } using (MText acMText = new MText()) { if (apoyos[i].ZapataConjuntaX)//vertical { acMText.Location = new Point3d(((apoyos[i].CoordEjeX - apoyos[i].B / 2) - 0.3), apoyos[i].CoordEjeY, 0); acMText.Width = apoyos[i].Vertice2X - apoyos[i].Vertice1X; acMText.Contents = ("-Carga Actuante " + apoyos[i].Carga + "Ton \n-Qadmisible " + Math.Round((apoyos[i].Qadmisible * 0.1), 2) + "kg/cm² \n-B " + Math.Round(apoyos[i].B, 2) + "mts \n-L " + apoyos[i].Ltotal + "mts"); } else if (apoyos[i].ZapataConjuntaY) //horizontal { acMText.Location = new Point3d(apoyos[i].CoordEjeX, ((apoyos[i].CoordEjeY - apoyos[i].B / 2) - 0.2), 0); acMText.Width = apoyos[i].Vertice2X - apoyos[i].Vertice1X; acMText.Contents = ("-Carga Actuante " + apoyos[i].Carga + "Ton \n-Qadmisible " + Math.Round((apoyos[i].Qadmisible * 0.1), 2) + "kg/cm² \n-B " + Math.Round(apoyos[i].B, 2) + "mts \n-L " + apoyos[i].Ltotal + "mts"); } else { acMText.Location = new Point3d(apoyos[i].Vertice3X, apoyos[i].Vertice3Y - 0.3, 0); acMText.Width = apoyos[i].Vertice2X - apoyos[i].Vertice1X; acMText.Contents = ("-Carga Actuante " + apoyos[i].Carga + "Ton \n-Qadmisible " + Math.Round((apoyos[i].Qadmisible * 0.1), 2) + "kg/cm² \n-B " + Math.Round(apoyos[i].B, 2) + "mts"); } acBlkTblRec.AppendEntity(acMText); acTrans.AddNewlyCreatedDBObject(acMText, true); } using (columna[i] = new Polyline()) { columna[i].AddVertexAt(0, new Point2d(apoyos[i].ColumnaV1X, apoyos[i].ColumnaV1Y), 0, 0, 0); Point3d punto1 = new Point3d(apoyos[i].ColumnaV1X, apoyos[i].ColumnaV1Y, 0); columna[i].AddVertexAt(1, new Point2d(apoyos[i].ColumnaV2X, apoyos[i].ColumnaV2Y), 0, 0, 0); Point3d punto2 = new Point3d(apoyos[i].ColumnaV2X, apoyos[i].ColumnaV2Y, 0); columna[i].AddVertexAt(2, new Point2d(apoyos[i].ColumnaV4X, apoyos[i].ColumnaV4Y), 0, 0, 0); columna[i].AddVertexAt(3, new Point2d(apoyos[i].ColumnaV3X, apoyos[i].ColumnaV3Y), 0, 0, 0); Point3d punto3 = new Point3d(apoyos[i].ColumnaV3X, apoyos[i].ColumnaV3Y, 0); columna[i].AddVertexAt(4, new Point2d(apoyos[i].ColumnaV1X, apoyos[i].ColumnaV1Y), 0, 0, 0); Point3d punto4 = new Point3d(apoyos[i].ColumnaV1X, apoyos[i].ColumnaV1Y, 0); acBlkTblRec.AppendEntity(columna[i]); acTrans.AddNewlyCreatedDBObject(columna[i], true); using (RotatedDimension dimc1 = new RotatedDimension()) { dimc1.XLine1Point = punto1; dimc1.XLine2Point = punto2; dimc1.DimLinePoint = new Point3d(0, apoyos[i].ColumnaV1Y + 0.5, 0); dimc1.DimensionStyle = acCurDb.Dimstyle; acBlkTblRec.AppendEntity(dimc1); acTrans.AddNewlyCreatedDBObject(dimc1, true); } using (RotatedDimension dimc2 = new RotatedDimension()) { dimc2.XLine1Point = punto3; dimc2.XLine2Point = punto4; dimc2.DimLinePoint = new Point3d(apoyos[i].ColumnaV1X - 0.5, 0, 0); dimc2.Rotation = Math.PI / 2.0; dimc2.DimensionStyle = acCurDb.Dimstyle; acBlkTblRec.AppendEntity(dimc2); acTrans.AddNewlyCreatedDBObject(dimc2, true); } } } double[] xCoords = points.Select(p => p.X).Distinct().OrderBy(x => x).ToArray(); double[] yCoords = points.Select(p => p.Y).Distinct().OrderBy(y => y).ToArray(); for (int i = 0; i < yCoords.Length - 1; i++) { var dim = new RotatedDimension(); dim.XLine1Point = new Point3d(xCoords[0], yCoords[i], 0.0); dim.XLine2Point = new Point3d(xCoords[0], yCoords[i + 1], 0.0); dim.DimLinePoint = new Point3d(xCoords[0] - 1.5, 0.0, 0.0); dim.Rotation = Math.PI / 2.0; acBlkTblRec.AppendEntity(dim); acTrans.AddNewlyCreatedDBObject(dim, true); } for (int i = 0; i < xCoords.Length - 1; i++) { var dim = new RotatedDimension(); dim.XLine1Point = new Point3d(xCoords[i], yCoords[0], 0.0); dim.XLine2Point = new Point3d(xCoords[i + 1], yCoords[0], 0.0); dim.DimLinePoint = new Point3d(0.0, yCoords[0] - 1.5, 0.0); //ojo, -1.5 porque usualmente esta cota va la ultima fila dim.Rotation = 0.0; acBlkTblRec.AppendEntity(dim); acTrans.AddNewlyCreatedDBObject(dim, true); } acTrans.Commit(); } } } }
private void MyMirror(List <Entity> listEnt, Line line, string xY) { if (listEnt == null || line == null) { return; } Line3d line3d = new Line3d(line.StartPoint, line.EndPoint); for (int i = 0; i < listEnt.Count; i++) { var entity = listEnt[i]; Entity ent = entity; //if((ent as Dimension) != null) //{ // continue; //} if (ent is DBText || ent is MText) { listOId.Add(ent.ToSpace(blkRef.Database)); } else { ent = entity.GetTransformedCopy(Matrix3d.Mirroring(line3d)); if ((ent as Dimension) == null) { list.Add(ent); } //continue; } /* var ptMin = ent.Bounds.Value.MinPoint; * * var ptMax = ent.Bounds.Value.MaxPoint; * * var w = Math.Abs(ptMax.X - ptMin.X); * var h = Math.Abs(ptMax.Y - ptMin.Y); * * var ptCenter = new Point3d((ptMin.X + ptMax.X) / 2, (ptMin.Y + ptMax.Y) / 2, 0);*/ if (ent is DBText) { var a = ent as DBText; MirrorText(a, line3d); } else if (ent is MText) { var a = ent as MText; MirrorText(a, line3d); } else if ((ent as Dimension) != null) { var dim = ent as Dimension; Plane p = null; if (xY == "X") { p = new Plane(dim.TextPosition, dim.Normal); ent = dim.GetTransformedCopy(Matrix3d.Mirroring(p)); } else if (xY == "Y") { p = new Plane(dim.TextPosition, dim.Normal); ent = dim.GetTransformedCopy(Matrix3d.Mirroring(p)); } if (ent is RotatedDimension) { var rDim = ent as RotatedDimension; var rDim1 = new RotatedDimension(rDim.Rotation, rDim.XLine1Point, rDim.XLine2Point, rDim.DimLinePoint, rDim.DimensionText, rDim.DimensionStyle); Dim2Dim(rDim1, rDim); list.Add(rDim1); } else if (ent is AlignedDimension) { var rDim = ent as AlignedDimension; var rDim1 = new AlignedDimension(rDim.XLine1Point, rDim.XLine2Point, rDim.DimLinePoint, rDim.DimensionText, rDim.DimensionStyle); Dim2Dim(rDim1, rDim); list.Add(rDim1); } else if (ent is ArcDimension) { var rDim = ent as ArcDimension; var rDim1 = new ArcDimension(rDim.CenterPoint, rDim.XLine1Point, rDim.XLine2Point, rDim.ArcPoint, rDim.DimensionText, rDim.DimensionStyle); Dim2Dim(rDim1, rDim); list.Add(rDim1); } else if (ent is DiametricDimension) { var rDim = ent as DiametricDimension; var rDim1 = new DiametricDimension(rDim.ChordPoint, rDim.FarChordPoint, rDim.LeaderLength, rDim.DimensionText, rDim.DimensionStyle); Dim2Dim(rDim1, rDim); list.Add(rDim1); } else if (ent is LineAngularDimension2) { var rDim = ent as LineAngularDimension2; var rDim1 = new LineAngularDimension2(rDim.XLine1Start, rDim.XLine1End, rDim.XLine2Start, rDim.XLine2End, rDim.ArcPoint, rDim.DimensionText, rDim.DimensionStyle); Dim2Dim(rDim1, rDim); list.Add(rDim1); } else if (ent is Point3AngularDimension) { var rDim = ent as Point3AngularDimension; var rDim1 = new Point3AngularDimension(rDim.CenterPoint, rDim.XLine1Point, rDim.XLine2Point, rDim.ArcPoint, rDim.DimensionText, rDim.DimensionStyle); Dim2Dim(rDim1, rDim); list.Add(rDim1); } else if (ent is RadialDimension) { var rDim = ent as RadialDimension; var rDim1 = new RadialDimension(rDim.Center, rDim.ChordPoint, rDim.LeaderLength, rDim.DimensionText, rDim.DimensionStyle); Dim2Dim(rDim1, rDim); list.Add(rDim1); } else if (ent is RadialDimensionLarge) { var rDim = ent as RadialDimensionLarge; var rDim1 = new RadialDimensionLarge(rDim.Center, rDim.ChordPoint, rDim.OverrideCenter, rDim.JogPoint, rDim.JogAngle, rDim.DimensionText, rDim.DimensionStyle); Dim2Dim(rDim1, rDim); list.Add(rDim1); } } } listEnt.ForEach(ent => ent.Dispose()); }
public static bool Clear(this Dimension obj) { bool myFlag = false; if (Math.Abs(obj.Elevation) >= TOLERANCE) { obj.Elevation = 0.0; myFlag = true; } if (obj is AlignedDimension) { AlignedDimension myDimension = obj as AlignedDimension; if (Math.Abs(myDimension.XLine1Point.Z) >= TOLERANCE) { myDimension.XLine1Point = myDimension.XLine1Point.ClearZ(); myFlag = true; } if (Math.Abs(myDimension.XLine2Point.Z) >= TOLERANCE) { myDimension.XLine2Point = myDimension.XLine2Point.ClearZ(); myFlag = true; } if (Math.Abs(myDimension.DimLinePoint.Z) >= TOLERANCE) { myDimension.DimLinePoint = myDimension.DimLinePoint.ClearZ(); myFlag = true; } } else if (obj is ArcDimension) { ArcDimension myDimension = obj as ArcDimension; if (Math.Abs(myDimension.XLine1Point.Z) >= TOLERANCE) { myDimension.XLine1Point = myDimension.XLine1Point.ClearZ(); myFlag = true; } if (Math.Abs(myDimension.XLine2Point.Z) >= TOLERANCE) { myDimension.XLine2Point = myDimension.XLine2Point.ClearZ(); myFlag = true; } if (Math.Abs(myDimension.Leader1Point.Z) >= TOLERANCE) { myDimension.Leader1Point = myDimension.Leader1Point.ClearZ(); myFlag = true; } if (Math.Abs(myDimension.Leader2Point.Z) >= TOLERANCE) { myDimension.Leader2Point = myDimension.Leader2Point.ClearZ(); myFlag = true; } if (Math.Abs(myDimension.ArcPoint.Z) >= TOLERANCE) { myDimension.ArcPoint = myDimension.ArcPoint.ClearZ(); myFlag = true; } } else if (obj is DiametricDimension) { DiametricDimension myDimension = obj as DiametricDimension; if (Math.Abs(myDimension.ChordPoint.Z) >= TOLERANCE) { myDimension.ChordPoint = myDimension.ChordPoint.ClearZ(); myFlag = true; } if (Math.Abs(myDimension.FarChordPoint.Z) >= TOLERANCE) { myDimension.FarChordPoint = myDimension.FarChordPoint.ClearZ(); myFlag = true; } } else if (obj is LineAngularDimension2) { LineAngularDimension2 myDimension = obj as LineAngularDimension2; if (Math.Abs(myDimension.ArcPoint.Z) >= TOLERANCE) { myDimension.ArcPoint = myDimension.ArcPoint.ClearZ(); myFlag = true; } if (Math.Abs(myDimension.XLine1End.Z) >= TOLERANCE) { myDimension.XLine1End = myDimension.XLine1End.ClearZ(); myFlag = true; } if (Math.Abs(myDimension.XLine1Start.Z) >= TOLERANCE) { myDimension.XLine1Start = myDimension.XLine1Start.ClearZ(); myFlag = true; } if (Math.Abs(myDimension.XLine2End.Z) >= TOLERANCE) { myDimension.XLine2End = myDimension.XLine2End.ClearZ(); myFlag = true; } if (Math.Abs(myDimension.XLine2Start.Z) >= TOLERANCE) { myDimension.XLine2Start = myDimension.XLine2Start.ClearZ(); myFlag = true; } } else if (obj is Point3AngularDimension) { Point3AngularDimension myDimension = obj as Point3AngularDimension; if (Math.Abs(myDimension.ArcPoint.Z) >= TOLERANCE) { myDimension.ArcPoint = myDimension.ArcPoint.ClearZ(); myFlag = true; } if (Math.Abs(myDimension.CenterPoint.Z) >= TOLERANCE) { myDimension.CenterPoint = myDimension.CenterPoint.ClearZ(); myFlag = true; } if (Math.Abs(myDimension.XLine1Point.Z) >= TOLERANCE) { myDimension.XLine1Point = myDimension.XLine1Point.ClearZ(); myFlag = true; } if (Math.Abs(myDimension.XLine2Point.Z) >= TOLERANCE) { myDimension.XLine2Point = myDimension.XLine2Point.ClearZ(); myFlag = true; } } else if (obj is RadialDimension) { RadialDimension myDimension = obj as RadialDimension; if (Math.Abs(myDimension.Center.Z) >= TOLERANCE) { myDimension.Center = myDimension.Center.ClearZ(); myFlag = true; } if (Math.Abs(myDimension.ChordPoint.Z) >= TOLERANCE) { myDimension.ChordPoint = myDimension.ChordPoint.ClearZ(); myFlag = true; } } else if (obj is RadialDimensionLarge) { RadialDimensionLarge myDimension = obj as RadialDimensionLarge; if (Math.Abs(myDimension.Center.Z) >= TOLERANCE) { myDimension.Center = myDimension.Center.ClearZ(); myFlag = true; } if (Math.Abs(myDimension.ChordPoint.Z) >= TOLERANCE) { myDimension.ChordPoint = myDimension.ChordPoint.ClearZ(); myFlag = true; } if (Math.Abs(myDimension.JogPoint.Z) >= TOLERANCE) { myDimension.JogPoint = myDimension.JogPoint.ClearZ(); myFlag = true; } if (Math.Abs(myDimension.OverrideCenter.Z) >= TOLERANCE) { myDimension.OverrideCenter = myDimension.OverrideCenter.ClearZ(); myFlag = true; } } else if (obj is RotatedDimension) { RotatedDimension myDimension = obj as RotatedDimension; if (Math.Abs(myDimension.DimLinePoint.Z) >= TOLERANCE) { myDimension.DimLinePoint = myDimension.DimLinePoint.ClearZ(); myFlag = true; } if (Math.Abs(myDimension.XLine1Point.Z) >= TOLERANCE) { myDimension.XLine1Point = myDimension.XLine1Point.ClearZ(); myFlag = true; } if (Math.Abs(myDimension.XLine2Point.Z) >= TOLERANCE) { myDimension.XLine2Point = myDimension.XLine2Point.ClearZ(); myFlag = true; } } return(myFlag); }
public void TendonAnnotation() { Document doc = Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; Editor ed = doc.Editor; db.SyncDwgToTdGenParas();//设置默认总体参数,已有总体参数字典项则无动作 using (Transaction trans = db.TransactionManager.StartTransaction()) { #region 1.选择梁顶缘线 PromptEntityOptions tpLineOpt = new PromptEntityOptions("\n选择梁顶缘线"); tpLineOpt.SetRejectMessage("\n顶缘线应为直线、圆弧或多段线"); tpLineOpt.AddAllowedClass(typeof(Line), true); //可以选择直线 tpLineOpt.AddAllowedClass(typeof(Polyline), true); //可以选择多段线 tpLineOpt.AddAllowedClass(typeof(Arc), true); //可以选择圆弧线 PromptEntityResult tpLineRes = ed.GetEntity(tpLineOpt); if (tpLineRes.Status != PromptStatus.OK) { return; } ObjectId tpLineId = tpLineRes.ObjectId; Curve tpLine = trans.GetObject(tpLineId, OpenMode.ForRead) as Curve; #endregion #region 2.选择钢束线 PromptEntityOptions tdLineOpt = new PromptEntityOptions("\n选择钢束"); tdLineOpt.SetRejectMessage("\n钢束应为多段线"); tdLineOpt.AddAllowedClass(typeof(Polyline), true);//仅能选择多段线 PromptEntityResult tdLineRes = ed.GetEntity(tdLineOpt); if (tdLineRes.Status != PromptStatus.OK) { return; } ObjectId tdLineId = tdLineRes.ObjectId; Polyline tdLine = trans.GetObject(tdLineId, OpenMode.ForRead) as Polyline; //判断钢束线是否在顶缘线以内,否则报错返回 if (tdLine.StartPoint.X < tpLine.StartPoint.X || tdLine.EndPoint.X > tpLine.EndPoint.X) { Application.ShowAlertDialog("钢束线超出顶缘线,请检查!"); return; } tdLine.SetDefaultTendonParams();//设置钢束默认参数,如已有Xrecord信息则无动作 #endregion #region 3.设置绘图参数(包括张拉方式和工作长度设置) //3.1 尺寸标注绘图位置及张拉方式和工作长度设置 Point3d pos = new Point3d();//初始化标注点 PromptPointOptions posOpt = new PromptPointOptions("\n设置标注线位置或设置[张拉方式(D)/工作长度(W)]"); posOpt.Keywords.Add("D"); posOpt.Keywords.Add("W"); posOpt.AppendKeywordsToMessage = false; //提示信息中不显示关键字 //获取钢束张拉方式 int tdDrawStyle = 0; //默认为两端张拉 if (!tdLine.ExtensionDictionary.IsNull && tdLine.ObjectId.GetXrecord("DA_Tendons") != null) //如果钢束线有扩展记录则取扩展记录数据 { tdDrawStyle = (Int16)tdLine.ObjectId.GetXrecord("DA_Tendons")[4].Value; } //获取工作长度信息 double workLen = 800; DBDictionary dicts = db.NamedObjectsDictionaryId.GetObject(OpenMode.ForWrite) as DBDictionary; if (dicts.Contains("DA_Tendons"))//如果字典中含DA_Tendons的字典项 { ObjectId tdsDictId = dicts.GetAt("DA_Tendons"); DBDictionary tdsDict = tdsDictId.GetObject(OpenMode.ForRead) as DBDictionary; //获取DA_Tendons字典 ObjectId xrecId = tdsDict.GetAt("workLen"); //获取字典中的工作长度项 Xrecord xrec = xrecId.GetObject(OpenMode.ForRead) as Xrecord; //获取工作长度项中的Xrecird TypedValueList vls = xrec.Data; //获取Xrecord中的TypedValueList数据 workLen = (double)vls[0].Value; //根据TypedValueList数据中的数值更新工作长度workLen } for (;;) { PromptPointResult posRes = ed.GetPoint(posOpt); if (posRes.Status == PromptStatus.Keyword) { switch (posRes.StringResult) { case "D": //选择修改张拉方式 PromptIntegerOptions drwOpt = new PromptIntegerOptions($"\n输入张拉方式[两端张拉(0)/左端张拉[-1]/右端张拉[1]<{tdDrawStyle}>"); drwOpt.AllowNone = true; //允许ESC退出 PromptIntegerResult drwRes = ed.GetInteger(drwOpt); if (drwRes.Value == 0) { tdDrawStyle = 0; } else if (drwRes.Value == -1) { tdDrawStyle = -1; } else if (drwRes.Value == 1) { tdDrawStyle = 1; } TypedValueList values = tdLine.ObjectId.GetXrecord("DA_Tendons"); //根据输入更新钢束线的Xrecord记录 values.RemoveAt(4); values.Add(DxfCode.Int16, tdDrawStyle); break; case "W": //修改工作长度 PromptDoubleOptions wklOpt = new PromptDoubleOptions($"\n输入工作长度<{workLen.ToString("F0")}>"); wklOpt.AllowNone = true; //允许ESC退出 PromptDoubleResult wklRes = ed.GetDouble(wklOpt); if (wklRes.Status == PromptStatus.OK) { workLen = wklRes.Value; ObjectId tdsDictId = dicts.GetAt("DA_Tendons");//更新DA_Tendons字典中的钢束总体参数 DBDictionary tdsDict = tdsDictId.GetObject(OpenMode.ForRead) as DBDictionary; ObjectId xrecId = tdsDict.GetAt("workLen"); Xrecord xrec = xrecId.GetObject(OpenMode.ForWrite) as Xrecord; TypedValueList vls = new TypedValueList(); vls.Add(DxfCode.Real, workLen); xrec.Data = vls; xrec.DowngradeOpen(); } break; } } else if (posRes.Status == PromptStatus.OK) { pos = posRes.Value; break; } } //3.2 绘图比例 PromptDoubleOptions scaleOpt = new PromptDoubleOptions($"\n设置绘图比例<{scale}>"); scaleOpt.AllowNone = true; //允许回车,则采用前次比例 scaleOpt.AllowNegative = false; //不允许负值 scaleOpt.AllowZero = false; //不允许零值 PromptDoubleResult scaleRes = ed.GetDouble(scaleOpt); //获取比例 if (scaleRes.Status != PromptStatus.OK && scaleRes.Status != PromptStatus.None) { return; } else if (scaleRes.Status == PromptStatus.OK) { scale = scaleRes.Value; } #endregion #region 4.建立各类标注 List <Point3d> ptsH = new List <Point3d>(); //创建水平标注点集 List <Dimension> dims = new List <Dimension>(); //创建标注集,存放各类标注 for (int i = 0; i < tdLine.NumberOfVertices - 1; i++) { //4.1 水平点集 ptsH.Add(tdLine.GetPoint3dAt(i)); //4.2 每段钢束线的长度 //4.3 直线标注角度 //4.4 圆弧线标注半径 if (tdLine.GetSegmentType(i) == SegmentType.Line) { LineSegment3d lineSeg = tdLine.GetLineSegmentAt(i); //4.2 每段钢束线的长度 db.LineLengthDim(lineSeg, scale); //4.3 直线标注角度 if (tdLine.StartPoint.X < tdLine.EndPoint.X) { db.LineAngelDim(lineSeg, !(i == tdLine.NumberOfVertices - 2), scale); } else { db.LineAngelDim(lineSeg, (i == tdLine.NumberOfVertices - 2), scale); } } else if (tdLine.GetSegmentType(i) == SegmentType.Arc) { CircularArc3d arcSeg = tdLine.GetArcSegmentAt(i); //4.2 每段钢束线的长度 db.ArcLengthDim(arcSeg, scale); //4.3 圆弧标注半径 db.ArrowRadiusDim(arcSeg, scale); } //4.5 竖直距离标注 Ray vRay = new Ray();//建立竖直射线 vRay.BasePoint = tdLine.GetPoint3dAt(i); vRay.UnitDir = new Vector3d(0, 1, 0); Point3dCollection ptIntersects = new Point3dCollection(); tpLine.IntersectWith(vRay, Intersect.OnBothOperands, ptIntersects, IntPtr.Zero, IntPtr.Zero); Point3d ptIntersect = ptIntersects[0]; RotatedDimension dimV = new RotatedDimension(); dimV.XLine1Point = tdLine.GetPoint3dAt(i); //第一条尺寸边线 dimV.XLine2Point = ptIntersect; //第二条尺寸边线 dimV.DimLinePoint = tdLine.GetPoint3dAt(i); //尺寸线位置 dimV.Rotation = Math.PI / 2; //标注旋转90度 dimV.DimensionStyle = db.Dimstyle; //尺寸样式为当前样式 dimV.Dimscale = scale; //设置尺寸全局比例 dims.Add(dimV); } //4.1 节点间距点集缺钢束最后一个点、梁顶缘线端点 ptsH.Add(tdLine.EndPoint); ptsH.Add(tpLine.StartPoint); ptsH.Add(tpLine.EndPoint); db.ContinuedHorizontalDims(ptsH, pos, scale);//建立水平连续标注 //4.5 竖直距离标注缺最后一个点 Ray vRayLast = new Ray();//建立竖直射线 vRayLast.BasePoint = tdLine.GetPoint3dAt(tdLine.NumberOfVertices - 1); vRayLast.UnitDir = new Vector3d(0, 1, 0); Point3dCollection ptIntersectsLast = new Point3dCollection(); tpLine.IntersectWith(vRayLast, Intersect.OnBothOperands, ptIntersectsLast, IntPtr.Zero, IntPtr.Zero); Point3d ptIntersectLast = ptIntersectsLast[0]; RotatedDimension dimVLast = new RotatedDimension(); dimVLast.XLine1Point = tdLine.GetPoint3dAt(tdLine.NumberOfVertices - 1); //第一条尺寸边线 dimVLast.XLine2Point = ptIntersectLast; //第二条尺寸边线 dimVLast.DimLinePoint = tdLine.GetPoint3dAt(tdLine.NumberOfVertices - 1); //尺寸线位置 dimVLast.Rotation = Math.PI / 2; //标注旋转90度 dimVLast.DimensionStyle = db.Dimstyle; //尺寸样式为当前样式 dimVLast.Dimscale = scale; //设置尺寸全局比例 dims.Add(dimVLast); #endregion #region 5 绘制张拉端 //5.1 获取张拉端几何特征 //获取钢束线真实的起点和终点 Point3d tdStart = (tdLine.StartPoint.X < tdLine.EndPoint.X) ? tdLine.StartPoint : tdLine.EndPoint; Point3d tdEnd = (tdLine.StartPoint.X < tdLine.EndPoint.X) ? tdLine.EndPoint : tdLine.StartPoint; //获取钢束线真实的起终点角度 double iclStart = (tdLine.StartPoint.X < tdLine.EndPoint.X) ? tdLine.GetLineSegmentAt(0).GetAngleOfLineSeg() : tdLine.GetLineSegmentAt(tdLine.NumberOfVertices - 2).GetAngleOfLineSeg(); double iclEnd = (tdLine.StartPoint.X < tdLine.EndPoint.X) ? tdLine.GetLineSegmentAt(tdLine.NumberOfVertices - 2).GetAngleOfLineSeg() : tdLine.GetLineSegmentAt(0).GetAngleOfLineSeg(); //初始化张拉端图元 Polyline leftDraw = new Polyline(); Polyline rightDraw = new Polyline(); MText lengthL = new MText(); MText lengthR = new MText(); //5.2 左侧张拉端 //5.2.1 两侧张拉或左侧张拉时左端绘制工作长度线 if (tdDrawStyle == 0 || tdDrawStyle == -1) { //创建张拉端几何点 Point3d tdDrawL = GeTools.PolarPoint(tdStart, iclStart, -workLen); //创建张拉段 leftDraw = new Polyline(); leftDraw.AddVertexAt(0, tdStart.ToPoint2d(), 0, 0, 0); leftDraw.AddVertexAt(1, tdDrawL.ToPoint2d(), 0, 0, 0); leftDraw.Layer = tdLine.Layer;//张拉段与钢束线应该在同一层 //标注左侧张拉段 lengthL = new MText(); //长度 lengthL.Contents = "工作长度" + workLen.ToString("F0"); //文字高度 lengthL.TextHeight = 3 * scale; //样式为当前样式 lengthL.TextStyleId = db.Textstyle; //旋转角度同直线段倾角 lengthL.Rotation = iclStart; //对齐位置为右上 lengthL.Attachment = AttachmentPoint.TopRight; //位置为中点垂线以下0.5个单位 lengthL.Location = GeTools.PolarPoint(GeTools.MidPoint(leftDraw.StartPoint, leftDraw.EndPoint), iclStart - Math.PI / 2, 0.5 * scale); } //5.2.2 右侧张拉时绘制P锚标识 else { //创建P锚起终点 Point3d tdDrawL1 = GeTools.PolarPoint(tdStart, iclStart + Math.PI / 2, 0.75 * scale); Point3d tdDrawL2 = GeTools.PolarPoint(tdStart, iclStart + Math.PI / 2, -0.75 * scale); //创建P锚标志 leftDraw = new Polyline(); leftDraw.AddVertexAt(0, tdDrawL1.ToPoint2d(), 0, 0.35 * scale, 0.35 * scale); leftDraw.AddVertexAt(1, tdDrawL2.ToPoint2d(), 0, 0.35 * scale, 0.35 * scale); leftDraw.Layer = tdLine.Layer;//张拉段与钢束线应该在同一层 //标注左侧P锚 lengthL = new MText(); //长度 lengthL.Contents = "P锚"; //文字高度 lengthL.TextHeight = 3 * scale; //样式为当前样式 lengthL.TextStyleId = db.Textstyle; //旋转角度同直线段倾角 lengthL.Rotation = iclStart; //对齐位置为右中 lengthL.Attachment = AttachmentPoint.MiddleRight; //位置为P锚标志右侧0.5个单位 lengthL.Location = GeTools.PolarPoint(GeTools.MidPoint(leftDraw.StartPoint, leftDraw.EndPoint), iclStart, -2 * scale); } //5.3 右侧张拉端绘制 //5.3.1 两侧张拉或右侧张拉时右端绘制工作长度线 if (tdDrawStyle == 0 || tdDrawStyle == 1) { //创建张拉端几何点 Point3d tdDrawR = GeTools.PolarPoint(tdEnd, iclEnd, workLen); //创建张拉段 rightDraw = new Polyline(); rightDraw.AddVertexAt(0, tdEnd.ToPoint2d(), 0, 0, 0); rightDraw.AddVertexAt(1, tdDrawR.ToPoint2d(), 0, 0, 0); rightDraw.Layer = tdLine.Layer;//张拉段与钢束线应该在同一层 //标注右侧张拉段 lengthR = new MText(); //长度 lengthR.Contents = "工作长度" + workLen.ToString("F0"); //文字高度 lengthR.TextHeight = 3 * scale; //样式为当前样式 lengthR.TextStyleId = db.Textstyle; //旋转角度同直线段倾角 lengthR.Rotation = iclEnd; //对齐位置为左上 lengthR.Attachment = AttachmentPoint.TopLeft; //位置为中点垂线以下0.5个单位 lengthR.Location = GeTools.PolarPoint(GeTools.MidPoint(rightDraw.StartPoint, rightDraw.EndPoint), iclEnd - Math.PI / 2, 0.5 * scale); } //5.2.2 左侧张拉时绘制P锚标识 else//绘制P锚 { //创建P锚起终点 Point3d tdDrawR1 = GeTools.PolarPoint(tdEnd, iclEnd + Math.PI / 2, 0.75 * scale); Point3d tdDrawR2 = GeTools.PolarPoint(tdEnd, iclEnd + Math.PI / 2, -0.75 * scale); //创建P锚标志 rightDraw = new Polyline(); rightDraw.AddVertexAt(0, tdDrawR1.ToPoint2d(), 0, 0.35 * scale, 0.35 * scale); rightDraw.AddVertexAt(1, tdDrawR2.ToPoint2d(), 0, 0.35 * scale, 0.35 * scale); rightDraw.Layer = tdLine.Layer;//张拉段与钢束线应该在同一层 //标注左侧P锚 lengthR = new MText(); //长度 lengthR.Contents = "P锚"; //文字高度 lengthR.TextHeight = 3 * scale; //样式为当前样式 lengthR.TextStyleId = db.Textstyle; //旋转角度同直线段倾角 lengthR.Rotation = iclEnd; //对齐位置为左中 lengthR.Attachment = AttachmentPoint.MiddleLeft; //位置为P锚标志右侧0.5个单位 lengthR.Location = GeTools.PolarPoint(GeTools.MidPoint(rightDraw.StartPoint, rightDraw.EndPoint), iclEnd, 2 * scale); } #endregion #region 6 在截面顶缘标识“梁顶缘线” Point3d midPt = GeTools.MidPoint(tpLine.StartPoint, tpLine.EndPoint); //顶缘线起终点中点 Point3d midPtInTp = tpLine.GetClosestPointTo(midPt, Vector3d.YAxis, true); //顶缘线上靠近中点的点 MText tpAnno = new MText(); tpAnno.Contents = "梁顶缘线"; //文字高度 tpAnno.TextHeight = 3 * scale; //样式为当前样式 tpAnno.TextStyleId = db.Textstyle; //对齐位置为右上 tpAnno.Attachment = AttachmentPoint.BottomLeft; //位置为中点以上0.5个单位 tpAnno.Location = GeTools.PolarPoint(midPtInTp, Math.PI / 2, 0.5 * scale); #endregion db.AddToModelSpace(dims.ToArray()); //添加各类标注 db.AddToModelSpace(leftDraw, rightDraw, lengthL, lengthR); //添加张拉段线 db.AddToModelSpace(tpAnno); //添加梁顶缘线标识 trans.Commit(); } }
public void DimTest() { Database db = HostApplicationServices.WorkingDatabase; using (Transaction trans = db.TransactionManager.StartTransaction()) { // 创建要标注的图形 Line line1 = new Line(new Point3d(30, 20, 0), new Point3d(120, 20, 0)); Line line2 = new Line(new Point3d(120, 20, 0), new Point3d(120, 40, 0)); Line line3 = new Line(new Point3d(120, 40, 0), new Point3d(90, 80, 0)); Line line4 = new Line(new Point3d(90, 80, 0), new Point3d(30, 80, 0)); Arc arc = new Arc(new Point3d(30, 50, 0), 30, Math.PI / 2, Math.PI * 3 / 2); Circle cir1 = new Circle(new Point3d(30, 50, 0), Vector3d.ZAxis, 15); Circle cir2 = new Circle(new Point3d(70, 50, 0), Vector3d.ZAxis, 10); //将图形添加到模型空间中 db.AddToModelSpace(line1, line2, line3, line4, arc, cir1, cir2); //创建一个列表,用于存储标注对象 List <Dimension> dims = new List <Dimension>(); // 创建转角标注(水平) RotatedDimension dimRotated1 = new RotatedDimension { //指定第一条尺寸界线的附着位置 XLine1Point = line1.StartPoint, //指定第二条尺寸界线的附着位置 XLine2Point = line1.EndPoint, //指定尺寸线的位置 DimLinePoint = GeTools.MidPoint(line1.StartPoint, line1.EndPoint).PolarPoint(-Math.PI / 2, 10), DimensionText = "<>mm" //设置标注的文字为标注值+后缀mm }; dims.Add(dimRotated1); //将水平转角标注添加到列表中 //创建转角标注(垂直) RotatedDimension dimRotated2 = new RotatedDimension { Rotation = Math.PI / 2, //转角标注角度为90度,表示垂直方向 //指定两条尺寸界线的附着位置和尺寸线的位置 XLine1Point = line2.StartPoint, XLine2Point = line2.EndPoint, DimLinePoint = GeTools.MidPoint(line2.StartPoint, line2.EndPoint).PolarPoint(0, 10) }; dims.Add(dimRotated2);//将垂直转角标注添加到列表中 //创建转角标注(尺寸公差标注) RotatedDimension dimRotated3 = new RotatedDimension { //指定两条尺寸界线的附着位置和尺寸线的位置 XLine1Point = line4.StartPoint, XLine2Point = line4.EndPoint, DimLinePoint = GeTools.MidPoint(line4.StartPoint, line4.EndPoint).PolarPoint(Math.PI / 2, 10), //设置标注的文字为标注值+堆叠文字 DimensionText = TextTools.StackText("<>", "+0.026", "-0.025", StackType.Tolerance, 0.7) }; dims.Add(dimRotated3);//将尺寸公差标注添加到列表中 // 创建对齐标注 AlignedDimension dimAligned = new AlignedDimension { //指定两条尺寸界线的附着位置和尺寸线的位置 XLine1Point = line3.StartPoint, XLine2Point = line3.EndPoint, DimLinePoint = GeTools.MidPoint(line3.StartPoint, line3.EndPoint).PolarPoint(Math.PI / 2, 10), //设置标注的文字为标注值+公差符号 DimensionText = "<>" + TextSpecialSymbol.Tolerance + "0.2" }; dims.Add(dimAligned);//将对齐标注添加到列表中 // 创建半径标注 RadialDimension dimRadial = new RadialDimension { Center = cir1.Center, //圆或圆弧的圆心 //用于附着引线的圆或圆弧上的点 ChordPoint = cir1.Center.PolarPoint(GeTools.DegreeToRadian(30), 15), LeaderLength = 10 //引线长度 }; dims.Add(dimRadial); //将半径标注添加到列表中 // 创建直径标注 DiametricDimension dimDiametric = new DiametricDimension { //圆或圆弧上第一个直径点的坐标 ChordPoint = cir2.Center.PolarPoint(GeTools.DegreeToRadian(45), 10), //圆或圆弧上第二个直径点的坐标 FarChordPoint = cir2.Center.PolarPoint(GeTools.DegreeToRadian(-135), 10), LeaderLength = 0 //从 ChordPoint 到注解文字或折线处的长度 }; dims.Add(dimDiametric); //将直径标注添加到列表中 // 创建角度标注 Point3AngularDimension dimLineAngular = new Point3AngularDimension { //圆或圆弧的圆心、或两尺寸界线间的共有顶点的坐标 CenterPoint = line2.StartPoint, //指定两条尺寸界线的附着位置 XLine1Point = line1.StartPoint, XLine2Point = line2.EndPoint, //设置角度标志圆弧线上的点 ArcPoint = line2.StartPoint.PolarPoint(GeTools.DegreeToRadian(135), 10) }; dims.Add(dimLineAngular);//将角度标注添加到列表中 // 创建弧长标注,标注文字取为默认值 ArcDimension dimArc = new ArcDimension(arc.Center, arc.StartPoint, arc.EndPoint, arc.Center.PolarPoint(Math.PI, arc.Radius + 10), "<>", db.Dimstyle); dims.Add(dimArc);//将弧长标注添加到列表中 // 创建显示X轴值的坐标标注 OrdinateDimension dimX = new OrdinateDimension { UsingXAxis = true, //显示 X 轴值 DefiningPoint = cir2.Center, //标注点 //指定引线终点,即标注文字显示的位置 LeaderEndPoint = cir2.Center.PolarPoint(-Math.PI / 2, 20) }; dims.Add(dimX);//将坐标标注添加到列表中 // 创建显示Y轴值的坐标标注 OrdinateDimension dimY = new OrdinateDimension { UsingXAxis = false, //显示Y轴 DefiningPoint = cir2.Center, //标注点 //指定引线终点,即标注文字显示的位置 LeaderEndPoint = cir2.Center.PolarPoint(0, 20) }; dims.Add(dimY); //将坐标标注添加到列表中 foreach (Dimension dim in dims) //遍历标注列表 { dim.DimensionStyle = db.Dimstyle; //设置标注样式为当前样式 db.AddToModelSpace(dim); //将标注添加到模型空间中 } trans.Commit();//提交更改 } }
public static void GetInfoIndirectas() { Document acDoc = Application.DocumentManager.MdiActiveDocument; Database acCurDb = acDoc.Database; bool? oked = false; System.Windows.Window win = new Indirectas(); oked = Application.ShowModalWindow(win); oked = true; if (oked.HasValue && oked.Value) { Indirectas instance = (Indirectas)win; List <Indirectas.Apoyo> apoyos; if (instance.finalizo) { apoyos = instance.apoyos; using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction()) { BlockTable acBlkTbl; acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) as BlockTable; BlockTableRecord acBlkTblRec; acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord; Polyline[] acPoly = new Polyline[apoyos.Count]; Polyline[] columna = new Polyline[apoyos.Count]; Point3d[] points = new Point3d[apoyos.Count]; for (int i = 0; i < apoyos.Count; i++) { points[i] = new Point3d(apoyos[i].CoordEjeX, apoyos[i].CoordEjeY, 0); using (acPoly[i] = new Polyline()) { acPoly[i].AddVertexAt(0, new Point2d(apoyos[i].Vertice1X, apoyos[i].Vertice1Y), 0, 0, 0); acPoly[i].AddVertexAt(1, new Point2d(apoyos[i].Vertice2X, apoyos[i].Vertice2Y), 0, 0, 0); acPoly[i].AddVertexAt(2, new Point2d(apoyos[i].Vertice4X, apoyos[i].Vertice4Y), 0, 0, 0); acPoly[i].AddVertexAt(3, new Point2d(apoyos[i].Vertice3X, apoyos[i].Vertice3Y), 0, 0, 0); acPoly[i].AddVertexAt(4, new Point2d(apoyos[i].Vertice1X, apoyos[i].Vertice1Y), 0, 0, 0); acBlkTblRec.AppendEntity(acPoly[i]); acTrans.AddNewlyCreatedDBObject(acPoly[i], true); } using (MText acMText = new MText()) { acMText.Location = new Point3d(apoyos[i].Vertice3X, apoyos[i].Vertice3Y - 0.2, 0); acMText.Width = apoyos[i].Vertice2X - apoyos[i].Vertice1X + apoyos[i].DistanciaMinimaEntrePilotes; acMText.Contents = "-Carga actuante " + apoyos[i].Carga + "Ton \n-Pilotes " + apoyos[i].Pilotes.Count + " ∅" + (apoyos[i].Pilotes[0].Diametro / 100) + "mts \n-Altura del Cabezal " + apoyos[i].GrosorCabezal + "mts \n-Acero Longitudinal " + apoyos[i].NumeroCabillas + " ∅" + apoyos[i].DiametroTeoricoPulgadas + "” \n-QADM de Grupo " + Math.Round(apoyos[i].QadmisibleGrupo, 2) + "Ton \n-QEST " + Math.Round(apoyos[i].Qestructural, 2) + "Ton \n-Momento en X " + apoyos[i].MtoEnEjeX + "Ton.m \n-Momento en Y " + apoyos[i].MtoEnEjeY + "Ton.m \n-Mayor Carga de Pilote " + Math.Round(apoyos[i].MayorCargaPilote, 2) + "Ton"; acBlkTblRec.AppendEntity(acMText); acTrans.AddNewlyCreatedDBObject(acMText, true); } using (columna[i] = new Polyline()) { columna[i].AddVertexAt(0, new Point2d(apoyos[i].ColumnaV1X, apoyos[i].ColumnaV1Y), 0, 0, 0); Point3d punto1 = new Point3d(apoyos[i].ColumnaV1X, apoyos[i].ColumnaV1Y, 0); columna[i].AddVertexAt(1, new Point2d(apoyos[i].ColumnaV2X, apoyos[i].ColumnaV2Y), 0, 0, 0); Point3d punto2 = new Point3d(apoyos[i].ColumnaV2X, apoyos[i].ColumnaV2Y, 0); columna[i].AddVertexAt(2, new Point2d(apoyos[i].ColumnaV4X, apoyos[i].ColumnaV4Y), 0, 0, 0); columna[i].AddVertexAt(3, new Point2d(apoyos[i].ColumnaV3X, apoyos[i].ColumnaV3Y), 0, 0, 0); Point3d punto3 = new Point3d(apoyos[i].ColumnaV3X, apoyos[i].ColumnaV3Y, 0); columna[i].AddVertexAt(4, new Point2d(apoyos[i].ColumnaV1X, apoyos[i].ColumnaV1Y), 0, 0, 0); Point3d punto4 = new Point3d(apoyos[i].ColumnaV1X, apoyos[i].ColumnaV1Y, 0); acBlkTblRec.AppendEntity(columna[i]); acTrans.AddNewlyCreatedDBObject(columna[i], true); using (RotatedDimension dimc1 = new RotatedDimension()) { dimc1.XLine1Point = punto1; dimc1.XLine2Point = punto2; dimc1.DimLinePoint = new Point3d(0, apoyos[i].ColumnaV1Y + 0.5, 0); dimc1.DimensionStyle = acCurDb.Dimstyle; acBlkTblRec.AppendEntity(dimc1); acTrans.AddNewlyCreatedDBObject(dimc1, true); } using (RotatedDimension dimc2 = new RotatedDimension()) { dimc2.XLine1Point = punto3; dimc2.XLine2Point = punto4; dimc2.DimLinePoint = new Point3d(apoyos[i].ColumnaV1X - 0.5, 0, 0); dimc2.Rotation = Math.PI / 2.0; dimc2.DimensionStyle = acCurDb.Dimstyle; acBlkTblRec.AppendEntity(dimc2); acTrans.AddNewlyCreatedDBObject(dimc2, true); } } Circle[] circle = new Circle[apoyos[i].Pilotes.Count]; for (int j = 0; j < apoyos[i].Pilotes.Count; j++) { using (circle[j] = new Circle()) { circle[j].Center = new Point3d(apoyos[i].Pilotes[j].PosicionX, apoyos[i].Pilotes[j].PosicionY, 0); circle[j].Radius = apoyos[i].DiametroPilotes / 200; acBlkTblRec.AppendEntity(circle[j]); acTrans.AddNewlyCreatedDBObject(circle[j], true); /*using (RadialDimension acRadDim = new RadialDimension()) * { * acRadDim.Center = circle[j].Center; * acRadDim.ChordPoint = new Point3d(apoyos[i].Pilotes[j].PosicionX + circle[j].Radius, apoyos[i].Pilotes[j].PosicionY, 0); * acRadDim.DimensionStyle = acCurDb.Dimstyle; * acBlkTblRec.AppendEntity(acRadDim); * acTrans.AddNewlyCreatedDBObject(acRadDim, true); * * }este codigo es para mostrar el diametro del circulo, no hace falta ya que se imprime*/ } } } double[] xCoords = points.Select(p => p.X).Distinct().OrderBy(x => x).ToArray(); double[] yCoords = points.Select(p => p.Y).Distinct().OrderBy(y => y).ToArray(); for (int i = 0; i < yCoords.Length - 1; i++) { var dim = new RotatedDimension(); dim.XLine1Point = new Point3d(xCoords[0], yCoords[i], 0.0); dim.XLine2Point = new Point3d(xCoords[0], yCoords[i + 1], 0.0); dim.DimLinePoint = new Point3d(xCoords[0] - 1.5, 0.0, 0.0); dim.Rotation = Math.PI / 2.0; acBlkTblRec.AppendEntity(dim); acTrans.AddNewlyCreatedDBObject(dim, true); } for (int i = 0; i < xCoords.Length - 1; i++) { var dim = new RotatedDimension(); dim.XLine1Point = new Point3d(xCoords[i], yCoords[0], 0.0); dim.XLine2Point = new Point3d(xCoords[i + 1], yCoords[0], 0.0); dim.DimLinePoint = new Point3d(0.0, yCoords[0] - 1.5, 0.0); //ojo, -1.5 porque usualmente esta cota va la ultima fila dim.Rotation = 0.0; acBlkTblRec.AppendEntity(dim); acTrans.AddNewlyCreatedDBObject(dim, true); } acTrans.Commit(); } } } }
public void Execute() { /// promote: /// /// CMD /// 当前设置:对齐坐标 = 世界坐标 /// 选择对象或改变坐标系[世界坐标(W)/用户坐标(U)]: /// /// 修改完成,共修改[x]个对象 Document doc = Application.DocumentManager.MdiActiveDocument; Database database = doc.Database; Editor ed = doc.Editor; Matrix3d wcs2ucs = ed.CurrentUserCoordinateSystem.Inverse(); ed.WriteMessage(PromoteStatus); using (Transaction acTrans = database.TransactionManager.StartTransaction()) { PromptSelectionOptions selOptions = new PromptSelectionOptions(); selOptions.Keywords.Add("WC", "WC", "世界坐标(WC)"); selOptions.Keywords.Add("UC", "UC", "用户坐标(UC)"); selOptions.MessageForAdding = "\n选择对象或" + selOptions.Keywords.GetDisplayString(true); selOptions.KeywordInput += delegate(object sender, SelectionTextInputEventArgs args) { CoordKeyWord = args.Input; ed.WriteMessage(PromoteStatus); }; PromptSelectionResult selResult = doc.Editor.GetSelection(selOptions); if (selResult.Status != PromptStatus.OK) { return; } SelectionSet selectionSet = selResult.Value; foreach (SelectedObject selectedObject in selectionSet) { if (selectedObject != null) { Entity ent = acTrans.GetObject(selectedObject.ObjectId, OpenMode.ForWrite) as Entity; Debug.Assert(ent != null, nameof(ent) + " != null"); BlockReference blockRef = ent as BlockReference; if (blockRef != null) { blockRef.Position = GetZ0Point(blockRef.Position, wcs2ucs, ed.CurrentUserCoordinateSystem); continue; } DBPoint point = ent as DBPoint; if (point != null) { point.Position = GetZ0Point(point.Position, wcs2ucs, ed.CurrentUserCoordinateSystem); continue; } Circle circle = ent as Circle; if (circle != null) { circle.Center = GetZ0Point(circle.Center, wcs2ucs, ed.CurrentUserCoordinateSystem); continue; } Line line = ent as Line; if (line != null) { line.StartPoint = GetZ0Point(line.StartPoint, wcs2ucs, ed.CurrentUserCoordinateSystem); line.EndPoint = GetZ0Point(line.EndPoint, wcs2ucs, ed.CurrentUserCoordinateSystem); continue; } Polyline pline = ent as Polyline; if (pline != null) { double elevation = 0; if (CoordType == CoordTypeEnum.UCS) { // 求原点在UCS上的投影点,然后与OCS平面向量(单位向量)点乘则得标高。 Point3d ptUZ = Point3d.Origin.TransformBy(wcs2ucs); ptUZ = new Point3d(ptUZ.X, ptUZ.Y, 0); Point3d ptWZ = ptUZ.TransformBy(ed.CurrentUserCoordinateSystem); Vector3d vec = ptWZ - Point3d.Origin; elevation = vec.DotProduct(pline.Normal); } pline.Elevation = elevation; continue; } RotatedDimension rd = ent as RotatedDimension; if (rd != null) { rd.DimLinePoint = GetZ0Point(rd.DimLinePoint, wcs2ucs, ed.CurrentUserCoordinateSystem); rd.XLine1Point = GetZ0Point(rd.XLine1Point, wcs2ucs, ed.CurrentUserCoordinateSystem); rd.XLine2Point = GetZ0Point(rd.XLine2Point, wcs2ucs, ed.CurrentUserCoordinateSystem); rd.Elevation = GetZ0elevation(wcs2ucs, ed.CurrentUserCoordinateSystem, rd.Normal); continue; } AlignedDimension ad = ent as AlignedDimension; if (ad != null) { ad.DimLinePoint = GetZ0Point(ad.DimLinePoint, wcs2ucs, ed.CurrentUserCoordinateSystem); ad.XLine1Point = GetZ0Point(ad.XLine1Point, wcs2ucs, ed.CurrentUserCoordinateSystem); ad.XLine2Point = GetZ0Point(ad.XLine2Point, wcs2ucs, ed.CurrentUserCoordinateSystem); ad.Elevation = GetZ0elevation(wcs2ucs, ed.CurrentUserCoordinateSystem, ad.Normal); continue; } } } acTrans.Commit(); } }
// draw a rectrangle with dimensions // nFlag: dimension control private void DrawSideRectangle(Plate pl, Point3d p0, double dT, double dL, int nFlag) { Point3d[] pt = new Point3d[16]; // geometry helpers Line[] ln = new Line[16]; // database objects // create points pt[0] = p0; pt[1] = new Point3d(p0.X + dT, p0.Y, p0.Z); pt[2] = new Point3d(p0.X + dT, p0.Y + dL, p0.Z); pt[3] = new Point3d(p0.X, p0.Y + dL, p0.Z); //more points pt[4] = new Point3d(p0.X, p0.Y + pl.R1, p0.Z); pt[5] = new Point3d(p0.X + dT, p0.Y + pl.R1, p0.Z); pt[6] = new Point3d(p0.X, pt[4].Y + pl.L9, p0.Z); pt[7] = new Point3d(p0.X + dT, pt[4].Y + pl.L9, p0.Z); pt[8] = new Point3d(p0.X, pt[6].Y + pl.L8, p0.Z); pt[9] = new Point3d(p0.X + dT, pt[6].Y + pl.L8, p0.Z); pt[10] = new Point3d(p0.X, pt[8].Y + pl.L7, p0.Z); pt[11] = new Point3d(p0.X + dT, pt[8].Y + pl.L7, p0.Z); pt[12] = new Point3d(p0.X, pt[10].Y + pl.L6, p0.Z); pt[13] = new Point3d(p0.X + dT, pt[10].Y + pl.L6, p0.Z); pt[14] = new Point3d(p0.X, pt[12].Y + pl.L5, p0.Z); pt[15] = new Point3d(p0.X + dT, pt[12].Y + pl.L5, p0.Z); // create lines of the main rectangle and store them into the database for (int i = 0; i < 4; i++) { ln[i] = new Line(pt[i], pt[(i + 1) % 4]); ln[i].ColorIndex = pl.nColor[CONTOUR]; // 0:index AcTrans.Add(ln[i]); } // create vertical lines for (int i = 4; i < 15; i += 2) { ln[i] = new Line(pt[i], pt[(i + 1)]); ln[i].ColorIndex = pl.nColor[HIDDEN]; // 0:index AcTrans.Add(ln[i]); } // Draw the horizontal dimension if ((nFlag & DIMHOR) != 0) { RotatedDimension dim = new RotatedDimension(); dim.XLine1Point = pt[0]; dim.XLine2Point = pt[1]; dim.DimLinePoint = new Point3d(pt[0].X, pt[0].Y - pl.dDimLineSp, pt[0].Z); dim.Dimscale = pl.dDimScale; dim.ColorIndex = pl.nColor[DIMENSION]; dim.Dimzin = 12; // Suppresses the Decimal Point AcTrans.Add(dim); } // Draw the vertical dimension if ((nFlag & DIMVER) != 0) { RotatedDimension dim = new RotatedDimension(); dim.XLine1Point = pt[1]; dim.XLine2Point = pt[5]; dim.DimLinePoint = new Point3d(pt[1].X + pl.dDimLineSp, pt[1].Y, pt[0].Z); dim.Rotation = Math.PI / 2.0; dim.Dimscale = pl.dDimScale; dim.ColorIndex = pl.nColor[DIMENSION]; dim.Dimzin = 12; // Suppresses the Decimal Point AcTrans.Add(dim); for (int i = 5; i < 15; i += 2) { RotatedDimension dim1 = new RotatedDimension(); dim1.XLine1Point = pt[i]; dim1.XLine2Point = pt[i + 2]; dim1.DimLinePoint = new Point3d(pt[1].X + pl.dDimLineSp, pt[1].Y, pt[0].Z); dim1.Rotation = Math.PI / 2.0; dim1.Dimscale = pl.dDimScale; dim1.ColorIndex = pl.nColor[DIMENSION]; dim1.Dimzin = 12; // Suppresses the Decimal Point AcTrans.Add(dim1); } RotatedDimension dim2 = new RotatedDimension(); dim2.XLine1Point = pt[15]; dim2.XLine2Point = pt[2]; dim2.DimLinePoint = new Point3d(pt[1].X + pl.dDimLineSp, pt[1].Y, pt[0].Z); dim2.Rotation = Math.PI / 2.0; dim2.Dimscale = pl.dDimScale; dim2.ColorIndex = pl.nColor[DIMENSION]; dim2.Dimzin = 12; // Suppresses the Decimal Point AcTrans.Add(dim2); } }
private void DimToSpace2(List <Point3d> ptArr, List <Dimension> listDim, Point3d pt1, Point3d wrongPt, int indexPt2) { RotatedDimension dimOld = null; RotatedDimension dimOld2 = null; int indexPt = ptArr.IndexOf(pt1); Point3d pt3 = Point3d.Origin; if (indexPt < indexPt2) { pt3 = ptArr[Math.Abs((indexPt2 - 1)) % ptArr.Count]; } else { pt3 = ptArr[(indexPt2 + 1) % ptArr.Count]; } foreach (var d in listDim) { if ((d as RotatedDimension) != null) { dimOld = d as RotatedDimension; if ((PtEqual(dimOld.XLine1Point, pt1) && PtEqual(dimOld.XLine2Point, wrongPt)) || (PtEqual(dimOld.XLine1Point, wrongPt) && PtEqual(dimOld.XLine2Point, pt1))) { dimOld = d as RotatedDimension; break; } else { dimOld = null; } } } foreach (var d in listDim) { if ((d as RotatedDimension) != null) { dimOld2 = d as RotatedDimension; if ((PtEqual(dimOld2.XLine1Point, pt3) && PtEqual(dimOld2.XLine2Point, wrongPt)) || (PtEqual(dimOld2.XLine1Point, wrongPt) && PtEqual(dimOld2.XLine2Point, pt3))) { dimOld2 = d as RotatedDimension; if (dimOld2 != dimOld) { break; } else { dimOld2 = null; } } else { dimOld2 = null; } } } double dimLen = 20d; if (null != dimOld) { var line = new Line(dimOld.XLine1Point, dimOld.XLine2Point); var ptDim = dimOld.DimLinePoint; var ptDim2 = line.GetClosestPointTo(ptDim, true); var v2 = ptDim - ptDim2; dimLen = v2.Length; var ptGet = pt1 + v2; Vector3d v = pt1 - ptArr[indexPt2]; //var dimNew = new RotatedDimension(0, pt1, ptArr[indexPt2], ptGet, v.Length.ToString(), dimOld.DimensionStyle); var dimNew = new AlignedDimension(pt1, ptArr[indexPt2], ptGet, v.Length.ToString("f2"), dimOld.DimensionStyle); Dim2Dim(dimNew, dimOld); dimNew.ToSpace(); using (var trans = Db.TransactionManager.StartTransaction()) { var ent = trans.GetObject(dimOld.ObjectId, OpenMode.ForWrite) as Entity; ent.Erase(true); trans.Commit(); } } if (dimOld2 != null) { var line = new Line(dimOld2.XLine1Point, dimOld2.XLine2Point); var ptDim = dimOld2.DimLinePoint; var ptDim2 = line.GetClosestPointTo(ptDim, true); var v2 = ptDim - ptDim2; dimLen = v2.Length; var ptGet = ptArr[indexPt2] + v2; Vector3d v3 = ptArr[indexPt2] - pt3; //var dimNew2 = new RotatedDimension(0, ptArr[indexPt2], pt3, pt4, v3.Length.ToString(), dimOld2.DimensionStyle); var dimNew2 = new AlignedDimension(ptArr[indexPt2], pt3, ptGet, v3.Length.ToString("f2"), dimOld2.DimensionStyle); Dim2Dim(dimNew2, dimOld2); dimNew2.ToSpace(); using (var trans = Db.TransactionManager.StartTransaction()) { //var ent = trans.GetObject(dimOld.ObjectId, OpenMode.ForWrite) as Entity; // ent.Erase(true); var ent2 = trans.GetObject(dimOld2.ObjectId, OpenMode.ForWrite) as Entity; ent2.Erase(true); trans.Commit(); } } }
static public void MlineDim() { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; // pick some point in PS Point3d p1, p2; PromptPointResult res = ed.GetPoint("选择第一根线端点。"); if (res.Status != PromptStatus.OK) { return; } PromptPointResult resend = ed.GetPoint("选择第二根线端点。"); if (resend.Status != PromptStatus.OK) { return; } p1 = res.Value; p2 = resend.Value; Log4NetHelper.WriteInfoLog("第一个点" + p1.ToString() + "\n"); Log4NetHelper.WriteInfoLog("第二个点" + p2.ToString() + "\n"); CadHelper.ClearDict(); PromptSelectionResult acSSPrompt; Point3d mp1 = Extension.Trans(p1, Extension.CoordSystem.PSDCS, Extension.CoordSystem.DCS); Point3d mp2 = Extension.Trans(p2, Extension.CoordSystem.PSDCS, Extension.CoordSystem.DCS); Log4NetHelper.WriteInfoLog("转换后第一个点" + mp1.ToString() + "\n"); Log4NetHelper.WriteInfoLog("转换后第二个点" + mp2.ToString() + "\n"); //acSSPrompt = ed.SelectCrossingWindow(mp1, // mp2); ed.SwitchToModelSpace(); TypedValue[] tvs = new TypedValue[] { new TypedValue((int)DxfCode.Start, "LINE") }; SelectionFilter sf = new SelectionFilter(tvs); acSSPrompt = ed.SelectCrossingWindow(mp1, mp2, sf); if (acSSPrompt.Status != PromptStatus.OK) { Log4NetHelper.WriteInfoLog("没有选择到实体.\n"); return; } SelectionSet acSSet = acSSPrompt.Value; Log4NetHelper.WriteInfoLog("Number of objects selected: " + acSSet.Count.ToString()); ed.SwitchToPaperSpace(); Document acDoc = Application.DocumentManager.MdiActiveDocument; Database acCurDb = acDoc.Database; Vector3dCollection vcs = new Vector3dCollection(); // Start a transaction Vector3d ev, sv, sbv; int pii = 0; Point3d ep1, ep2, pp1, pp2, dp1, dp2; using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction()) { BlockTable acBlkTbl; acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) as BlockTable; // Open the Block table record Model space for write BlockTableRecord acBlkTblRec; acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.PaperSpace], OpenMode.ForWrite) as BlockTableRecord; foreach (ObjectId lid in acSSet.GetObjectIds()) { var ln = acTrans.GetObject(lid, OpenMode.ForRead) as Line; if (ln != null) { ev = new Vector3d(ln.EndPoint.X, ln.EndPoint.Y, ln.EndPoint.Z); sv = new Vector3d(ln.StartPoint.X, ln.StartPoint.Y, ln.StartPoint.Z); sbv = ev.Subtract(sv); CadHelper.AddVPDict(sbv, ln.EndPoint); vcs.Add(sbv); pii = pii + 1; } } if (vcs.Count >= 2) { for (int i = 0; i < vcs.Count - 1; i++) { if (vcs[i].IsCodirectionalTo(vcs[i + 1]) == true) { ep1 = CadHelper.GetEndPoint(vcs[i]); ep2 = CadHelper.GetEndPoint(vcs[i + 1]); dp1 = Extension.Trans(ep1, Extension.CoordSystem.WCS, Extension.CoordSystem.DCS); pp1 = Extension.Trans(dp1, Extension.CoordSystem.DCS, Extension.CoordSystem.PSDCS); dp2 = Extension.Trans(ep2, Extension.CoordSystem.WCS, Extension.CoordSystem.DCS); pp2 = Extension.Trans(dp2, Extension.CoordSystem.DCS, Extension.CoordSystem.PSDCS); // Create the rotated dimension using (RotatedDimension acRotDim = new RotatedDimension()) { acRotDim.XLine1Point = pp1; acRotDim.XLine2Point = pp2; acRotDim.Rotation = 0; acRotDim.DimLinePoint = new Point3d(0, 5, 0); acRotDim.DimensionStyle = acCurDb.Dimstyle; // Add the new object to Model space and the transaction acBlkTblRec.AppendEntity(acRotDim); acTrans.AddNewlyCreatedDBObject(acRotDim, true); } // Commit the changes and dispose of the transaction } } } acTrans.Commit(); } // Start a transaction // now to make sure this works for all viewpoints //ObjectId btId = ed.Document.Database.BlockTableId; //// create a new DBPoint and add it to model space to show where we picked //using (DBPoint pnt = new DBPoint(new Point3d(retPoint[0], retPoint[1], retPoint[2]))) //using (BlockTable bt = btId.Open(OpenMode.ForRead) as BlockTable) //using (BlockTableRecord ms = bt[BlockTableRecord.ModelSpace].Open(OpenMode.ForWrite) // as BlockTableRecord) // ms.AppendEntity(pnt); }
protected RotatedDimension CreateDim(Point3d ptPrev, Point3d ptNext, Point3d ptDimLine, bool doTrans, Matrix3d trans, int rangeSize = 0, double rotation = 0, bool interlineText = false) { if (doTrans) { ptPrev = ptPrev.TransformBy(trans); ptNext = ptNext.TransformBy(trans); ptDimLine = ptDimLine.TransformBy(trans); } var dim = new RotatedDimension(rotation.ToRadians(), ptPrev, ptNext, ptDimLine, "", panelBase.Service.Env.IdDimStyle); if (rangeSize>0) { dim.Suffix = getTextRange(dim.Measurement, rangeSize); } if (interlineText) { dim.Dimtmove = 0; dim.Dimtix = true; } dim.Dimscale = Settings.Default.SheetScale; btrDim.AppendEntity(dim); t.AddNewlyCreatedDBObject(dim, true); return dim; }