How to obtain the location on the line

Akane Ito
Akane Ito Member Posts: 26
10 Comments Name Dropper
**

I want to obtain the position of a point on a line where Y has an arbitrary value.
For example, I want to obtain the position of the point on the arc (the red dot) when Y equals 4.

Answers

  • Landon Mitchell Kanner
    Landon Mitchell Kanner Member, Employee Posts: 287
    100 Comments 25 Answers 25 Likes Photogenic
    ✭✭✭✭

    Here is something crude to get you started:

    edge = ExtAPI.SelectionManager.CurrentSelection.Entities[0]
    tolerance = .01 # 1%
    y_value = .01
    points = [edge.Points[3*i:3*i+3] for i in range(int(len(edge.Points)/3))]
    ps = [p for p in points if p[1]>y_value*(1-tolerance) and p[1]<y_value*(1+tolerance)]
    

    To get more refined, I think you would want to find the two points closest to the Y-line and then do an interpolation to get the intersection.