Kangaroo

THIS FORUM IS NO LONGER ACTIVE. PLEASE POST ANY NEW QUESTIONS OR DISCUSSION ON:

https://discourse.mcneel.com/c/grasshopper/kangaroo

The discussions here are preserved for reference, but new questions posted here are likely to go unanswered.

Kangaroo is a Live Physics engine for interactive simulation, optimization and form-finding directly within Grasshopper.

Collider Goal in Python: List[Object] type?

Hi everyone,

I am trying to use the K2 Collider Goal in Python, but I am having hard times understanding what does a 'List[Object]' is.

This is the error I am getting when feeding in a list of Lines:

"Runtime error (ArgumentTypeException): expected List[object], got list".

I tried to check in the C# example goal in Daniel Piker GitHub (https://github.com/Dan-Piker/K2Goals/blob/master/Collisions.cs) but I am pretty new in scripting and I could not figure out which is the problem.

Any help would be much appreciated,

Thanks.

Luca

  • up

    Anders Holden Deleuran

    It's referring to the .NET generic list type. To instantiate one using IronPython you can do like so:


    # Import the type
    from System.Collections.Generic import List


    # Instantiate a list
    myDotNetList = List[object]()


    Edit: Object might be capitalized, I forget. Also, If you're making a list which contains a specific type (like say, Kangaroo2 goals) you might want to declare this instead of object (for instance: ks.IGoal with the KangarooSolver.dll imported under the alias ks).

    2