符工好,上周查看论坛发现你发的图片关于求交点的函数,在该 https://communities.bentley.com/communities/other_communities/chinafirst/f/microstation-projectwise/140318/c-ce网址下,但是里面你发的图片打不开,网速很好的情况下也是打不开,能否再发一下
这个社区平台Telligent最近由10.1升级到了10.3,以前的某些图片居然看不到了。
我也记不清楚当初我给的方案是什么了。不过,我到MicroStationApi.chm中搜索Intersect*,很容易就能找到CurveCurve类下的函数IntersectionsXY。你按此思路到C#帮助中找一下。
好的
符工好,我按照你说的找了一下:
CurveCurve.IntersectionsXY(CurvePathQuery.ElementToCurveVector(newel), CurvePathQuery.ElementToCurveVector(element), curVec1, curVec2);
CurveCurve.IsSinglePointPair(CurvePathQuery.ElementToCurveVector(newel), CurvePathQuery.ElementToCurveVector(element),2,out fractionA,out pointA, out fractionB, out pointB);
我是按照图中的定义写的,测试结果不对,我不知道我的写法对不对,因为输入的参数我总是感觉不对,其中intersectionA=CurvePathQuery.ElementToCurveVector(newel),curVec1=CurvePathQuery.ElementToCurveVector(newel).GetPrimitive(0);,参数intersectionB也是类似的,感觉输入的参数不对。
测试代码如下:
public static void IntersectXYTest(string unparsed) { DgnModel dgnModel = Session.Instance.GetActiveDgnModel(); Element elemA = dgnModel.FindElementById((ElementId)576L); Element elemB = dgnModel.FindElementById((ElementId)577L); if (elemA == null || elemB == null) return; CurveVector curveA = CurvePathQuery.ElementToCurveVector(elemA); CurveVector curveB = CurvePathQuery.ElementToCurveVector(elemB); CurveVector intersectionA = CurveVector.Create(CurveVector.BoundaryType.Open); CurveVector intersectionB = CurveVector.Create(CurveVector.BoundaryType.Open); CurveCurve.IntersectionsXY(intersectionA, intersectionB, curveA, curveB); double fractionA, fractionB; DPoint3d pointA, pointB; string msgStr = ""; for (uint i=0; i< intersectionA.Count; i++) if (CurveCurve.IsSinglePointPair(intersectionA, intersectionB, i, out fractionA, out pointA, out fractionB, out pointB)) msgStr += string.Format("point[{0}] = ({1:F2}, {2:F2})\n", i, pointA.X, pointA.Y); MessageCenter.Instance.ShowInfoMessage(msgStr, msgStr, true); }
测试结果如下图:
修改图形使其有四个交点,则程序运行结果如下:
符工,我想问下参数中intersectionA表示的什么意思呢?我看API中英文介绍,理解的不清楚