两条曲线之间的最小距离,并在这些点上画一条线
通过下面的代码,我可以确定两条曲线之间的最短距离。这很管用然后,我如何确定每个曲线上出现最短距离的点3d
这是为了在这两个点之间画一条线,以帮助用户确定最短距离的位置。
https://forums.autodesk.com/t5/net/minimum-distance-between-two-entities/td-p/6381823
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();
}
}
**** Hidden Message ***** 做了一些挖掘,设法想出一个磨破 我觉得不错
欢迎加入!
DWG几何API非常丰富,如果你挖掘得足够深入,你可能会找到它 如果你碰巧有Civil 3D,那里有一个命令可以做到这一点:
https://knowledge.autodesk.com/support/civil-3d/learn-explore/caas/CloudHelp/cloudhelp/2016/ENU/Civil3D-UserGuide/files/GUID-26094B8A-1A5F-462E-AAF1-AF1716DE526A-htm.html
页:
[1]