Cast from Brep or GeometryBase to Cone

Hi all,

I am using the native C#-scripting component and like to pass a Cone as a input. However, as it doesn’t have Cone as a type hint I need to pass it as something else. I’ve therefore tried to add it as a Brep and a GeometryBase input but in both cases I can’t cast it back to a Cone afterwards (I like to access some Cone-properties such as ApexPoint and BasePoint).

Tried normal casting like below, but only get errors.

Cone castedCone = (Cone) inputCone;

Do anyone know how to cast a Brep or a GeometryBase to a Cone? Or have any other suggestion how I can have a Cone as an input and still use all of the Cone-properties?

maybe this helps:
https://developer.rhino3d.com/api/RhinoCommon/html/Overload_Rhino_Geometry_Surface_TryGetCone.htm

1 Like

Yes this kind of works, thanks!

Seems like I can first cast my Cone to a RevSurface with Cone.ToRevSurface() and then cast it back with Surface.TryGetCone(). My new cone then lost it’s bottom but both the BasePoint and ApexPoint seem right so guess I can just cap it again. Maybe not the smoothest solution but at least it seem to work and all info I need seem to be there :slight_smile: