Grasshopper

algorithmic modeling for Rhino

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

Views: 707

Replies to This Discussion

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).

Wow, cool! 

And seems like object doesn't need to be capitalised.

Cheers,

Mange tak

EDIT: I get the following error. 


Runtime error (NullReferenceException): Object reference not set to an instance of an object.


But if I capitalise Object, then it simply says:

expected Array[Type], got list

Think we'll need a definition to troubleshoot further, otherwise it'd just be guesswork. Or, pop downstairs :)

RSS

About

Translate

Search

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service