Grasshopper

algorithmic modeling for Rhino

About generic list in iron python,how to convert a dynamic python list into generic list?

I know in python list is dynamic,But some method's input in RhinoCommon needs to be Generic list,like "Curve.ClosestPoints Method (IEnumerable(GeometryBase), Point3d, Point3d, Int32)",and I write some code like below:

sphere 1=Sphere(Point3d(0,0,0),10)

sphere 2=Sphere(Point3d(20,20,20),10)

spherelist=[]

spherelist.append(sphere1)

spherelist.append(sphere2)

crv.ClosestPoints(spherelist,pt1,pt2,int)

 

then I got this" Runtime error (ArgumentTypeException): expected IEnumerable[GeometryBase], got list",and after search hard in web,I find this

https://github.com/mcneel/rhinopython/issues/25,so I tried to write something like this:

 

spherelist2=List[Brep](spherelist)

 

also there is an error message"Runtime error (MissingMemberException): 'type' object has no attribute '__index__'"

Is there any possible idea for the answer?

Any help would be greatly appreciated.Thanks!

 

 

Views: 1610

Replies to This Discussion

Anyone?

Your problem is somewhat difficult to understand. You'll usually get more of a response by providing a file(s) to troubleshoot. That said, have a look at the attached example. I implemented the Curve.ClosestPoints method for a curve and a list of three spheres. The method returns a list containing a boolean value indicating success followed by the closest point on the curve and then the closest point on the closest sphere. Seems to work, hope that helps.

Attachments:

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service