protected override void OnExecute(Command command, ExecutionContext context, System.Drawing.Rectangle buttonRect) { if (excelWorksheet == null) { excelWorksheet = new ExcelWorksheet(); } Window activeWindow = Window.ActiveWindow; List <ITrimmedCurve> iTrimmedCurves = new List <ITrimmedCurve>(activeWindow.GetAllSelectedITrimmedCurves()); if (iTrimmedCurves.Count != 2) { return; } ITrimmedCurve curveA = iTrimmedCurves[0]; ITrimmedCurve curveB = iTrimmedCurves[1]; var intersections = new List <IntPoint <CurveEvaluation, CurveEvaluation> >(curveA.IntersectCurve(curveB)); CurveEvaluation evalA = curveA.ProjectPoint(intersections[0].Point); CurveEvaluation evalB = curveB.ProjectPoint(intersections[0].Point); double angle = Math.Acos(Vector.Dot(evalA.Tangent.UnitVector, evalB.Tangent.UnitVector)); excelWorksheet.SetCell(row++, 1, angle * 180 / Math.PI); }
public CurveEvaluation ProjectPoint(Point point) { return(trimmedCurve.ProjectPoint(point)); }