Can a curve be twisted?

Awesome. This is the kind of stuff I would like to see in a gallery on the side when I open the Rhino forums, and not only when I happen to read a specific topic.

There was this website that has this kind of gallery :thinking:

1 Like

Super! Exactly what I was looking for!

// Rolf

I’m recently starting to write my own custom K2 goals, so just wanted to say that having worked examples like this one to reverse-engineer are really helpful (given the current state of Kangaroo documentation!)

One thing I’m confused about is what the GoalObject.Torque and TorqueWeighting properties do? From what I understand, the solver operates on PPos points and nudges them around based on the Move vectors which are updated by the Calculate method.

It’s the first time seeing a Torque variable being used, how does that even apply to particle systems which have no intrinsic orientation? Thanks :slight_smile:

Particles can now have an orientation, and all the goals under the 6dof tab make use of this. Orientations are only created for particles when needed by one of these goals. They can be accessed as a Rhino Plane.

As you say, generally goals create Move vectors, and in the Calculate method all the different Move vectors from all the goals acting on each particle get combined to update the position of that particle, with the Weighting value being a scalar multiplier for the relative importance of each Move.

Just as Move vector and Weighting are to particle position, so are Torque vector and TorqueWeighting to particle orientation. The direction of the Torque vector is the axis about which that goal wants to rotate that particle, and the length of the vector is the angle in radians it wants to rotate it by.

1 Like

This is awesome work!

When I try to open this file, I get a kangaroosolver.dll error. Basically, it’s saying it cannot find the reference file (kangaroosolver.dll) and asks me to specify where it is.

Assuming you are using Rhino 5 (?), anyway, if you right click the C# (“Support2”) component and select “Manage Assemblies” you can select the KangarooSolver.dll you have on your machine,

bild

You will probably find it somewhere in your Library folder (Bold text: my folder for Kangaroo in Rhino 5):

C:\Users\ < your name > \AppData\Roaming\Grasshopper\Libraries*kangaroo242_2017-10-25*

Then just drop the existing KangarooSolver and add yours (from the path above)

// Rolf

I’m in Rhino 6, but perhaps the solution is similar.

Probably, yes.

For Rhino 6 the KangarooSolver.dll file is usually located in
C:\Program Files\Rhino 6\Plug-ins\Grasshopper\Components

I was able to get the first two errors to go away, but I’m also having errors on other components downstream.

The first error reads
1. Solution exception:Unable to cast object of type ‘Support2’ to type ‘KangarooSolver.IGoal’.

…the second
1. Object reference not set to an instance of an object. (line: 71)

…last error
1. ArgumentOutOfRangeException: Array is empty Parameter name: array

I think the last two errors might disappear after resolving the first one.
I hate to hijack this thread like this.

In the fourth C# component after the Solver (well, it is red as you can see), open the code editor and add a new first row like so:

if (P0 == null || P1 == null) return;

The other errors I have no idea.

// Rolf

Thankyou Daniel for providing this solution/file. It looks really realistic and amazingly effordless (even though the technical solution is not). Thanks to Rolf for asking.

At StF-7 we talked about the native Rhino-command for maintaining a specific curvelenght and I asked you if it would be possible to improve this command using GH and Kangaroo 2, now they are both included in Rhino 6. The old command I mentioned is listed here:

I’m interested since I get the same errors…

The only one that matters is in fact the Kangaroo error: it seems like the Kangaroo solver doesn’t recognize the custom class Support2 created in the C# component as a KangarooSolver.IGoal (even though it’s declared as an extension of a GoalObject): what come out of the C# that creates the Support2 is in fact listed as “Script_Instance+Support2”.

The other 2 errors are simply due to a cascade effect… the downstream components are not receiving as input what they are supposed to due to the error in the Kangaroo component. @RIL wisely suggested an error catch strategy - yet the error remains.

I am trying this definition on Rhino 6 - all latest versions of the software and plugins.

Maybe the wrong assembly DLL file is being referenced - try pasting the following into a C# scripting component and check the out output to see where it points to on your computer:

var assm = Assembly.Load("KangarooSolver");
Print(assm.Location);

( Incidentally this is a big gripe for me - don’t understand why the scripting components can’t automatically resolve assemblies by name, instead of requiring an absolute file path which breaks on everyone else’s but the original creator’s computer :confused: )

2 Likes

Hey, leave GHPython out of this mess!

1 Like

Nope, I referenced the correct assembly and I still get the error

Hmm, I’m out of ideas then - might be a Rhino 6 bug? See if the GrowingLine or CustomIteration scripts from here (https://github.com/Dan-Piker/Kangaroo-examples/tree/master/scripting) work, they’re independent of the K2 solver component.

@AndersDeleuran whoops, that should’ve been ‘statically compiled scripting components’? :sweat_smile: Too bad Python subclasses of KangarooGoal don’t seem to play well with the solver - I did try a simple one and it ran 100x slower than the C# version…

1 Like

Hmm… There’s definitely something in Rhino 6.

GrowingLine works, but CustomIteration gives me the following error:

Unable to cast object of type ‘KangarooSolver.Goals.Locator’ to type ‘KangarooSolver.IGoal’. (line: 80)

If you’re sure you’re referencing the rhino 6 copy of the DLL, another thing to try could be to toggle the COFF loading option in GH developer settings, then restart rhino