当前位置:网站首页 > 去中心化金融(DeFi) > 正文

ad20怎么设置捕捉(ad20怎么捕捉线的中心)

下面是一个使用C#语言编写的.NET平台上的

CAD

应用程序的代码示例,实现了自动

捕捉

端点功能:

 using Autodesk. AutoCAD .Runtime; using Autodesk. AutoCAD .ApplicationServices; using Autodesk. AutoCAD .DatabaseServices; using Autodesk. AutoCAD .EditorInput; using Autodesk. AutoCAD .Geometry;  namespace My CAD App { public class MyCommands { [CommandMethod("MyLine")] public void MyLine() { Document doc = Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; Editor ed = doc.Editor;  using (Transaction tr = db.TransactionManager.StartTransaction()) { BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead); BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);  PromptPointOptions ppo1 = new PromptPointOptions(" Start point: "); ppo1.UseBasePoint = true; ppo1.BasePoint = Point3d.Origin; ppo1.UseDashedLine = true; ppo1.AllowNone = true; ppo1.Keywords.Add("E"); ppo1.Keywords.Add("X"); ppo1.Keywords.Default = "E";  PromptPointResult ppr1 = ed.GetPoint(ppo1); if (ppr1.Status != PromptStatus.OK) return;  if (ppr1.Status == PromptStatus.Keyword) { if (ppr1.StringResult == "X") return; else if (ppr1.StringResult == "E") { ppo1.UseBasePoint = false; ppo1.UseDashedLine = false; ppo1.Message = " Endpoint: "; ppo1.Keywords.Clear(); } }  PromptPointOptions ppo2 = new PromptPointOptions(" End point: "); ppo2.UseBasePoint = true; ppo2.BasePoint = ppr1.Value; ppo2.UseDashedLine = true; ppo2.AllowNone = true; ppo2.Keywords.Add("E"); ppo2.Keywords.Add("X"); ppo2.Keywords.Default = "E";  PromptPointResult ppr2 = ed.GetPoint(ppo2); if (ppr2.Status != PromptStatus.OK) return;  if (ppr2.Status == PromptStatus.Keyword) { if (ppr2.StringResult == "X") return; else if (ppr2.StringResult == "E") { ppo2.UseBasePoint = false; ppo2.UseDashedLine = false; ppo2.Message = " Endpoint: "; ppo2.Keywords.Clear(); } }  Line line = new Line(ppr1.Value, ppr2.Value);  btr.AppendEntity(line); tr.AddNewlyCreatedDBObject(line, true);  tr.Commit(); } } } } 

在这个代码示例中,使用了

AutoCAD

的API中的PromptPointOptions类的UseBasePoint属性和UseDashedLine属性来实现自动

捕捉

端点功能。在获取起点坐标时,

设置

UseBasePoint属性为true,并将BasePoint属性

设置

为原点,同时

设置

UseDashedLine属性为true,这样在鼠标移动过程中,会自动

捕捉

到距离原点最近的端点。在获取终点坐标时,

设置

UseBasePoint属性为true,并将BasePoint属性

设置

为起点坐标,同时

设置

UseDashedLine属性为true,这样在鼠标移动过程中,会自动

捕捉

到距离起点坐标最近的端点。通过使用PromptPointOptions类的Keywords属性,可以添加关键字,实现在命令过程中的交互。

到此这篇ad20怎么设置捕捉(ad20怎么捕捉线的中心)的文章就介绍到这了,更多相关内容请继续浏览下面的相关 推荐文章,希望大家都能在编程的领域有一番成就!

版权声明


相关文章:

  • 肃州区人力资源配置中心工资待遇(肃州区人力资源配置中心工资待遇怎么样)2025-10-21 16:00:10
  • 静脉药物配置中心工作流程(静脉药物配置中心的一般运作流程是什么?)2025-10-21 16:00:10
  • Apollo配置中心多个meta(apollo配置中心使用)2025-10-21 16:00:10
  • 配置中心系统(配置中心在哪)2025-10-21 16:00:10
  • 静脉配置中心出科小结(静脉配置中心出科小结及总结)2025-10-21 16:00:10
  • apollo配置中心(Apollo配置中心页面长什么样)2025-10-21 16:00:10
  • 肃州区人力资源配置中心联系人(肃州区人力资源与社会保障局)2025-10-21 16:00:10
  • Nacos配置中心死活连接不上(nacos 配置中心)2025-10-21 16:00:10
  • nacos配置中心(Nacos配置中心使用)2025-10-21 16:00:10
  • pivas静脉配置中心(pivas静脉配置中心人员配置要求)2025-10-21 16:00:10
  • 全屏图片