Hi, I am running into an issue trying to execute the MeshRay function from Rhinocommon in Python. Specifically I am getting the error message 'float' object is not iterable on the following line of code:
I think the issue arises when trying to get the second output of the function, specifically the list of mesh faces that the ray intersects. However this works fine:
The second MeshRay method overload you are trying to call has an out parameter. Out parameters are not returned by method, but rather “filled” when supplied to the method call:
import System
import Rhino
import clr
# define someMesh, someRay
faceIndexArray = clr.StrongBox[System.Array[System.Int32]]()
t = Rhino.Geometry.Intersect.Intersection.MeshRay(someMesh, someRay, faceIndexArray)
if t >= 0:
faceIndexL = list(faceIndexArray.Value)
print faceIndexL
Where is this documented though? I found something very similar in an IronPython documentation for working with .NET libraries but it had a different Syntax that didn’t work in Rhino’s Python. I’m not sure where some of this syntax you are showing is coming from.
You can find more info on ironpython.net/documentation. Check the explicit call on that page. clr.Reference is an equivalent to clr.StrongBox.
For typed arrays, check this page.