Boids moving shortest path

Hello, I’m a computational student so I’m still trying to make a moving agent by python. My goal is to move the agent by the shortest path to the boundary. still confused about how to manage the data to control all agents. If you guys have experience pls help me debug.

class (5.3 KB)

I guess here you’d better use Grasshopper instead of Rhino. Here is a starting point:

import Rhino.Geometry as rg
def findPath(pt, crv):
    ct = crv.ClosestPoint(pt)[1]
    cp = crv.PointAt(ct)
    return rg.Line(pt, cp)
if 'paths' not in globals() or reset:
    paths = [findPath(pt, boundary) for pt in pts]
    t = 0.0
if t < 1.0 - speed:
    t += speed
a = [path.PointAt(t) for path in paths]
1 Like

I’m also want to use grasshopper but my class does not allow it. T_T

What do you mean?