getLineInfo

public static String getLineInfo() {
		StackTraceElement ste = new Throwable().getStackTrace()[1];
		return ste.getFileName() + ": Line " + ste.getLineNumber();
	}
getLineCount:static counter-->++counter
好的,我可以帮你回答这个问题。 首先,在Visual Studio中新建一个“类库”项目,然后在解决方案资源管理器中右键点击“引用”,选择“添加引用”,选择“Autodesk.AutoCAD.Runtime”和“Autodesk.AutoCAD.EditorInput”两个程序集,并点击“确定”按钮。 接下来,编写一个类,例如“LineInfo”,用于获取直线的信息,其中包括直线的起点坐标和终点坐标。代码如下: ```csharp using Autodesk.AutoCAD.Runtime; using Autodesk.AutoCAD.EditorInput; using Autodesk.AutoCAD.Geometry; namespace MyCADApp { public class LineInfo { [CommandMethod("GetLineInfo")] public void GetLineInformation() { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; PromptEntityOptions peo = new PromptEntityOptions("\n请选择一条直线:"); peo.SetRejectMessage("\n请选择一条直线:"); peo.AddAllowedClass(typeof(Line), true); PromptEntityResult per = ed.GetEntity(peo); if (per.Status == PromptStatus.OK) { using (Transaction tr = per.ObjectId.Database.TransactionManager.StartTransaction()) { Line line = (Line)tr.GetObject(per.ObjectId, OpenMode.ForRead); Point3d startPoint = line.StartPoint; Point3d endPoint = line.EndPoint; ed.WriteMessage("\n直线起点坐标为: ({0}, {1}, {2})", startPoint.X, startPoint.Y, startPoint.Z); ed.WriteMessage("\n直线终点坐标为: ({0}, {1}, {2})", endPoint.X, endPoint.Y, endPoint.Z); tr.Commit(); } } } } } ``` 最后,在Visual Studio中生成项目,生成的dll文件将被放置在项目文件夹的“bin/Debug”目录下。将生成的dll文件复制到AutoCAD的搜索路径中,并在AutoCAD中输入“netload”命令,加载dll文件。 最后,在AutoCAD中输入“GetLineInfo”命令,选择一条直线,直线的起点坐标和终点坐标将显示在AutoCAD信息窗口中。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值