Can i use Kangaroo in pure c#

hello gays
i try to make an Standalong Grasshopper Plugin ( means the plugin start at out side of grasshopper )
and want to use Kangaroosolver.dll in pure C# and .netFramework plugin for Rhino
my problem is i don’t know how to start calculating
and after complete the calculating how to read the result position and rotation of my rigidbodys

i forget say Sorry for my bad english :frowning:

thats my sample code , my app crash without error at end of this code
( i try with one element list of goal and multiple element but result was the same )


if i should use goal.calculate so the calculate method want particle parameters :open_mouth:
pleas help me

To the best of my knowledge, you are looking for these examples: https://github.com/Dan-Piker/Kangaroo-examples/tree/master/scripting. It’s been a while since I checked them but I guess they will sill work.

Kudos to @LongNguyen for his original answer in the grasshopper forum, helped me a lot when looking for this a while back(https://www.grasshopper3d.com/group/kangaroo/forum/topics/kangaroo-in-c-component)

Thanks alan Rynne
:blush:
but i want use kanagoroosolver.dll in pure c# not in grasshopper c# component
my writen plugin is such a standalon plugin of rhyno

in grasshopper everything works well but i want to use it on Pure c#

Interesting! I don’t think I’ve ever seen that approach.

I just inspected the KangarooSolver.dll assembly (maybe I shouldn’t be doing that… but it’s already done :sweat_smile:). It looks like KangarooSolver directly depends on RhinoCommon and Grasshopper, so I’m not sure if you’ll be able to do this. :frowning:

Maybe someone with a little more knowledge can give you more insight!

Screenshot 2020-06-30 at 09.34.17

thanks @alan2
i you right for before using kangarooSolver we must include the rhinocommon , but i think it work without grasshopper refrance (dll) ,
by the way i think the only one can help me is owner of kangoro @DanielPiker :smiley:

Hi @iranikhaze,

Yes, it should work to call the KangarooSolver.dll from a Rhino plugin, without opening Grasshopper, and when doing this the Grasshopper reference isn’t needed.

The issue I see with the code you show is that the goals do not get their indexing assigned. It’s also not clear where you are initialising your instance of PhysicalSystem.

Here’s a simple example:

    var PS = new KangarooSolver.PhysicalSystem();
    double tol = 0.0001; // points closer than this will get combined into a single particle
    var GoalList = new List<IGoal>();
    //Assign indexes to the particles in each Goal:
    foreach(IGoal G in x)
    {
      PS.AssignPIndex(G, tol);
      GoalList.Add(G);
    }    
    double threshold = 1e-10;
    PS.Step(GoalList, false, threshold);
    A = PS.GetOutput(GoalList);

AssignPIndex is the function which looks at the point positions and adds them to the particle list of the PhysicalSystem, and sets the index in the goal. The step method does not work until this indexing is assigned.

2 Likes

thanks @DanielPiker Pindex work like charm :star_struck:

1 Like