1 /// <summary> 2 /// 绘制断面方向 多段线 3 /// </summary> 4 /// <param name="polylineStartPoint"></param> 5 /// <param name="polylineEndPoint"></param> 6 /// <param name="lintypeId"></param> 7 public Line DrawDMFX(Point3d polylineStartPoint, Point3d polylineEndPoint, ObjectId lintypeId) 8 { 9 Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; 10 Database db = Autodesk.AutoCAD.DatabaseServices.HostApplicationServices.WorkingDatabase; 11 using (Transaction trans = db.TransactionManager.StartTransaction()) 12 { 13 //获取块表 14 BlockTable bt = (BlockTable)(trans.GetObject(db.BlockTableId, OpenMode.ForRead)); 15 16 //获取块表记录-模型空间,三维坐标等 17 BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite); 18 19 Line l = new Line(polylineStartPoint, polylineEndPoint); 20 l.LinetypeId = lintypeId; 21 l.Layer = "dmx"; 22 l.ColorIndex = 7; 23 24 //Polyline p = new Polyline(); 25 //p.LinetypeId = lintypeId; 26 //p.StartPoint = polylineStartPoint; 27 //p.EndPoint = polylineEndPoint; 28 //p.Layer = "dmx"; 29 //p.ColorIndex = 256; 30 31 btr.AppendEntity(l); 32 trans.AddNewlyCreatedDBObject(l, true); 33 trans.Commit(); 34 return l; 35 } 36 37 }
1 /// <summary> 2 /// 绘制断面方向 3维多段线 3 /// </summary> 4 /// <param name="type"></param> 5 /// <param name="polylineStartPoint"></param> 6 /// <param name="polylineEndPoint"></param> 7 /// <param name="lintypeId"></param> 8 /// <returns></returns> 9 public void DrawDMFX(Poly3dType type, Point3d polylineStartPoint, Point3d polylineEndPoint, ObjectId lintypeId) 10 { 11 Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; 12 Database db = Autodesk.AutoCAD.DatabaseServices.HostApplicationServices.WorkingDatabase; 13 using (Transaction trans = db.TransactionManager.StartTransaction()) 14 { 15 //获取块表 16 BlockTable bt = (BlockTable)(trans.GetObject(db.BlockTableId, OpenMode.ForRead)); 17 18 //获取块表记录-模型空间,三维坐标等 19 BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite); 20 21 22 //绘制多段线 23 type = Poly3dType.SimplePoly; 24 Point3d[] p3d = new Point3d[2] { polylineStartPoint, polylineEndPoint }; 25 Point3dCollection vertex = new Point3dCollection(p3d); 26 Polyline3d p = new Polyline3d(type, vertex, false); 27 28 //Polyline p = new Polyline(); 29 //设置线型 30 p.LinetypeId = lintypeId; 31 32 //设置颜色,图层等 33 p.ColorIndex = 7; 34 p.Layer = "dmx"; 35 btr.AppendEntity(p); 36 trans.AddNewlyCreatedDBObject(p, true); 37 trans.Commit(); 38 39 } 40 41 }