Getting geometrybase from guid

python

#1

I am trying to use the rayshoot method on some objects in a rhino scene.

geometry       = rs.GetObject ("Pick object")
intPt = Rhino.Geometry.Intersect.Intersection.RayShoot(ray, [geometry], bounce)
print intPt

currently I an just trying to get it to work by selecting the object (mesh or surface) and see the return value. This gives the error:

Unable to cast object of type 'System.Guid' to type 'Rhino.Geometry.GeometryBase'.

Is there a way to convert a Guid to a geometry base object?

Ultimately I want to just parse the entire scene and go through all the objects, so the user wont be selecting each one, but for now, I can’t find information on how to get the basetype and not the guid.


(Dale Fugier) #2

Hi Matthew,

If you have an object’s id (e.g. Guid), then you can get the object. And from the object you can get the geometry.

Also, rhinoscryptsyntax does have a ShootRay method. Check the help file for details.

import rhinoscriptsyntax as rs

def TestRayShooter():
    corners = []
    corners.append((0,0,0))
    corners.append((10,0,0))
    corners.append((10,10,0))
    corners.append((0,10,0))
    corners.append((0,0,10))
    corners.append((10,0,10))
    corners.append((10,10,10))
    corners.append((0,10,10))
    box = rs.AddBox(corners)
    dir = 10,7.5,7
    reflections = rs.ShootRay(box, (0,0,0), dir)
    rs.AddPolyline( reflections )
    rs.AddPoints( reflections )

TestRayShooter()

More on Rhino.Python

– Dale


#3

For others, the function I was looking for was coerce

geometry = rs.coercebrep(geometry)