autocadautocad-plugin

Is there a way to disassemble a polyline with curves so that I can check angles between each of the tangents?


I am new to AutoCAD plugin programming and C#. I'm trying to place points along a polyline in C# for a function I am writing, and I need to know when the point is being placed, is it on a curved portion, and what is the angle between the tangent lines on either end of the curved portion. A single polyline might have multiple curves, but will always have tangents between them.

My current function, without the additional functionality, takes a polyline input from modelspace and uses GetPointAtDist to calculate points along the polyline at set intervals. I'm not really sure where to start to get that additional info I need. I thought maybe I could build lines and curves along the polyline so that I could assign each segment/curve a variable but that seems inefficient.


Solution

  • You can get tangency vector then You can get angles between vectors

    Point3d p0 = axis.GetPointAtDist(d0);
    Vector3d v0 = axis.GetFirstDerivative(p0);    
    Point3d px = axis.GetPointAtDist(curentDist);    
    Vector3d v = axis.GetFirstDerivative(px);    
    double angle = v.GetAngleTo(v0);