学习C#。NET for Autocad。
处理Autocad内置命令的一个简单练习:用栅栏修剪一束线。我在" ed.command("_ "获得豁免。TRIM”)”,而我在任何地方都找不到我做错了什么。
有什么建议和想法吗?
- [CommandMethod("TST2")]
- public void Tst2()
- {
- Document doc = AcAp.DocumentManager.MdiActiveDocument;
- Database db = doc.Database;
- Editor ed = doc.Editor;
- Line obj;
- PromptEntityOptions peo = new PromptEntityOptions("\nSelect edge: ");
- peo.SetRejectMessage("\nSelect a LINE for edge...");
- peo.AddAllowedClass(typeof(Line), true);
- PromptEntityResult per = ed.GetEntity(peo);
- if (per.Status != PromptStatus.OK) return;
- using (Transaction tr = db.TransactionManager.StartTransaction())
- {
- obj = tr.GetObject(per.ObjectId, OpenMode.ForRead) as Line;
- obj.Highlight();
- tr.Commit();
- }
- // Prompt for the start point
- PromptPointOptions ppt = new PromptPointOptions("\nFirst point of the edge: ");
- PromptPointResult pep = doc.Editor.GetPoint(ppt);
- Point3d pini = pep.Value;
- if (pep.Status == PromptStatus.Cancel) return;
- // Prompt for the end point
- ppt.Message = "\nSecond point of the edge: ";
- ppt.UseBasePoint = true;
- ppt.BasePoint = pini;
- pep = doc.Editor.GetPoint(ppt);
- Point3d pfin = pep.Value;
- if (pep.Status == PromptStatus.Cancel) return;
- ed.Command("_.TRIM", obj, "_F", pini, pfin );
- obj.Unhighlight();
- }
本帖以下内容被隐藏保护;需要你回复后,才能看到! 游客,如果您要查看本帖隐藏内容请 回复 |