通过下面的代码,我可以确定两条曲线之间的最短距离。这很管用
然后,我如何确定每个曲线上出现最短距离的点3d
这是为了在这两个点之间画一条线,以帮助用户确定最短距离的位置。
https://forums.autodesk.com/t5/net/minimum-distance-between-two-entities/td-p/6381823
- [CommandMethod("MinDist")]
- public void GetMinimumDistance()
- {
- var doc = Application.DocumentManager.MdiActiveDocument;
- var db = doc.Database;
- var ed = doc.Editor;
- var options = new PromptEntityOptions("\nSelect first object: ");
- options.SetRejectMessage("Must be a curve.");
- options.AddAllowedClass(typeof(Curve), false);
- var result = ed.GetEntity(options);
- if (result.Status != PromptStatus.OK)
- return;
- var id1 = result.ObjectId;
- options.Message = "\nSelect second object: ";
- result = ed.GetEntity(options);
- if (result.Status != PromptStatus.OK)
- return;
- var id2 = result.ObjectId;
- using (var tr = db.TransactionManager.StartTransaction())
- {
- var curve1 = (Curve)tr.GetObject(id1, OpenMode.ForRead);
- var curve2 = (Curve)tr.GetObject(id2, OpenMode.ForRead);
- var distance = curve1.GetGeCurve().GetDistanceTo(curve2.GetGeCurve());
- ed.WriteMessage("\nDistance = {0}", distance);
- tr.Commit();
- }
- }
本帖以下内容被隐藏保护;需要你回复后,才能看到! 游客,如果您要查看本帖隐藏内容请 回复 |