Curve equal distance

I should really upload some more up-to-date code to the repository. Anywho, here’s how I’ve been importing Kangaroo2 since it was made a standard Grasshopper plugin:

import clr
import Grasshopper as gh
clr.AddReferenceToFileAndPath(gh.Folders.PluginFolder+"Components\KangarooSolver.dll")
import KangarooSolver as ks

This negates fiddling with paths etc. So when you issue a definition it’ll “just work” (well, ideally).

Also, I tend to use the KangarooSolver.PhysicalSystem.SimpleStep method when implementing a solver in GHPython. I can’t quite recall why, but I’m sure there was some good reasoning behind this. Anywho, something to keep in mind when you’re testing things.

1 Like

Hi @anon39580149 ,
yeah it is a recursive function call, so you’ll have to take care about the return values. Attached is a ghPython version of this script.
Jess
EquiDistantCurveDivision_ghpython_jM.gh (7.3 KB)

1 Like

Thanks , i added counter back but still freezing with c# unlike python, i will try my first method with arcs or maybe tangent lines created from derivatives than find the intersections with curve, maybe this will also work with 3d curve but i need at the end to scale the polyline where the points keep moving along the curve until the endpoint, i don’t know is that possible with Kangaroo.

Thank you @AndersDeleuran , the examples are very helpful.

1 Like

Can you upload the file which is freezing?

No worries, regarding implementing this zombie-style (i.e. using a while loop) in GHPython, have a look here:

2 Likes

Thank you @Jess , i see now you call the same function inside itself.
I will try to improve the result by Kangaroo if there is a way to use EqualLength component,
and i will change crv.DivideEquidistant(distance) by using tangent lines because DivideEquidistant make the script very slow.

Yes , this is the file i don’t test it now because i work on another files

equal dist_freeze.gh (11.6 KB)

Yes i saw that in one of your useful files and i used it, i also tested for i in range(100) ,
using while and counter sometimes freeze GhPython and Grasshopper.

image

#brainfart


crv2Ddist.gh (46.2 KB)

This idea is to create a 3D graph containing all the data, which can be done fully-multithreaded, then intersect the graph and use the resulting curve for a much simpler and faster loop.
The algorithm have many, many parts where it can be tweaked.
POC

(Edit: for example, intersecting the 3d graph with rays instead of a plane, would let the use of different distances between points, by using a different Z for every ray…)

Currently very slow compared to sphere/circle intersection methods, but i guess this would be handy when the amount of segment is very high.

Thank you @maje90 i will check it later

I test all previous script and the one of @RIL with his self intersected curve and the scripts failed to find equal distances with some distances or division count.
I try to find the right intersection points using circle and these steps than with loop it will find all points,than using extend curve + flow than Kangaroo to improve the result.

Divide Distance find the right points but it is very slow

EquiDistantCurve.gh (27.7 KB)