Kangaroo attraction and repulsion forces

Hello everyone,
I used attraction force to make minimal paths that pass though 3 buildings on the ground level. But I failed to combine with repulsion force to make the paths detour from the elevators and staircases in the cores of the buildings. Can somebody help me have a look at the codes to see how to do it please?
Thank you for your help ! :pray:
Wool_Threads_v2.gh (65.3 KB)



Here are some examples with more up to date version of the attraction/repulsion

Thank you for your scripts David :slight_smile: I understood this script less than the old one. I tried to connect the positive points to the points I want attractive force, and connect the negative points to the points I want repulsive force, but it didn’t work. How do I convert the points into minimal paths? Thank you!

Hi @ka.man.lee
Here’s an updated example specifically for the Frei Otto wet threads type form-finding.


woolthreads_k2.gh (13.8 KB)

1 Like

As for including obstacles which the paths have to go around-
One simple way could be to keep the threads on a surface with holes cut out for the obstacles:


woolthreads_obstacles.gh (16.6 KB)

10 Likes

Hi @DanielPiker
I’m quite new to Kangaroo so apologies if my question has quite an obvious answer or is in the wrong place. I saw your C# script outputs the following string “Script_Instance+RangedAttraction” how does the solver use this string to extract all the relevant information for the goal?
Also I can’t read C#, is it possible to script for kangaroo in Python? If so is there any documentation?
Thanks in advance!

Hi @david.prior-hope17

The script is not outputting a string, but an object. In this case the object is an instance of the ‘RangedAttraction’ class which is defined in the script (and inherits from the GoalObject class defined in KangarooSolver.dll).
When you hover over the output or connect a text panel, Grasshopper converts the object to a string to try and tell you something about the object, but what is really passed between the components is more than just that string - it’s the whole class with its methods and properties, which can then be called by the solver.

Yes, it is possible to script Kangaroo goals with Python. @AndersDeleuran has kindly shared some examples here GitHub - AndersDeleuran/KangarooGHPython: How to stuff a Kangaroo in your Python using a Grasshopper</

I think doing it with C# will probably be a bit easier though, as there will just be a lot more examples to refer to. Normally creating a goal will involve mostly just vector operations, so you won’t need to learn a lot of esoteric language specific things.

1 Like

Very cool! Thanks so much for the prompt response, all makes sense!

1 Like

Hi @DanielPiker
Thank you for the script! I’m now also working on a little project with it.
I’m new to C# so apologies if the answer to my question was obvious. I want to figure out what the inputs of the C# script means, but I can’t figure out What the “cutoff” stands for.
Does it has geometric or physical meanings?
Thank you in Advance!
woolthreads_obstacles.gh (16.3 KB)

Cutoff here is a way of preventing infinite forces when points are very close together.
The force in this example has its magnitude varying as an inverse power of distance.
This means that as the distance between 2 points approaches zero, the force becomes infinite. To avoid numerical issues with division by zero it lets you specify a small distance at which this force is cut off.

An alternative approach here would be to use something like a Lennard-Jones potential, which adds an attractive force to a steeper repulsive one, so particles are pulled together up to a certain distance, but when they get very close the repulsion dominates.

Thank you so much Daniel! That was really clear and helpful!

1 Like

:pray: :pray:
:100: Thank you @DanielPiker !
I am new to Kangaroo and was using this attraction and repulsion forces as a first study sample!

Hi Daniel, I have been trying to apply this GH definition on to other model, even though I don’t change the setting, the simulation doesn’t work as well as the original script…I wonder why…I guess the issue is from either the division setting or the C# component input? I have try to change the setting but without luck…



Uploading: 1a86ff5af97ba60b972ef89d9dafbe6.png…

For extended query, is it possible to apply this GH on to a site with around 60 points? Is there any strategy or parameter we can adjust to make the script run faster with 60 points?

Thanks for any information

Wool Path Test.3dm (143.6 KB)
woolthreads_obstacles4.gh (829.8 KB)

Thanks @DanielPiker it works really well!
I have used the algorithm on a terrain mesh and had to make adjustments to compensate for the larger scale, so I reduced the segment length and increased the range parameter in the C# component.

So for anyone using this on a large scale mesh/ surface, here’s the adjusted version:
Woolythreads_obstacles_LargeScale.gh (27.5 KB)

Note that you can adjust the threshold value to let the algorithm stop earlier on. In my case a value of 150mm was about right.

1 Like