输出的dwg文件中的线要加上说明:线段长度。 但是添加的线都是根据点添加的,都是水平方向。。。。也不知道如何获取线段长度! 请问要如何才能给线加上长度的说明?? 代码如下: using System; using System.Collections.Generic; using System.Text; using System.Reflection; using System.Collections; using System.Drawing; using Autodesk.AutoCAD.Interop; using Autodesk.AutoCAD.Interop.Common; using System.Windows.Forms; namespace ModelManage { public class cad { AcadApplication a; public void ex(Line[] ls) { a = new AcadApplicationClass(); a.Visible = false; foreach (Line l in ls) { double[] s = new double[3]; //声明直线起点坐标 double[] e = new double[3];//声明直线终点坐标 s[0] = double.Parse((l.PS.X).ToString()); s[1] = double.Parse((l.PS.Y).ToString()); e[0] = double.Parse((l.PE.X).ToString()); e[1] = double.Parse((l.PE.Y).ToString()); a.ActiveDocument.ModelSpace.AddLine(s, e); a.ActiveDocument.ModelSpace.AddText(l.LineId, s, 5);//添加说明文字 } SaveFileDialog f = new SaveFileDialog(); f.Filter = "(*.dwg)|*.dwg"; if (f.ShowDialog() == DialogResult.OK) { try { a.ActiveDocument.SaveAs(f.FileName, AcSaveAsType.acR14_dwg, null); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } a.Quit(); } } }
初学cad开发,大家多帮下忙 |