如果想判断一个线串是顺时针还是逆时针绘制的,我们可以利用线串上的点来构造一个封闭的CurveVector,然后可以调用CurveVector下的CentroidNormalArea方法来得到该封闭区域的发现方法,从而可以判断出该线串的方向:
public static void CLockWiseCheckTest()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();
Element elem = dgnModel.FindElementById((ElementId)1175L);
CurvePrimitive cp = CurvePathQuery.ElementToCurveVector(elem).GetAt(0);
IList<DPoint3d> points = new List<DPoint3d>();
cp.TryGetLineString(points);
CurveVector cv = CurveVector.CreateLinear(points, CurveVector.BoundaryType.Outer, true);
cv.CentroidNormalArea(out DPoint3d centroid, out DVector3d normal, out double area);
}