How can I turn a RhinoObject into an Extrusion


#1

Hi all,

First, sorry for my basic English…

I’m using RhinoCommon dll with C#.

I’m trying to get the curves which are the “bottom” of all extrusions of my document.
I manage to get the whole extrusions but in the form of RhinoObject type, so I would like to turn my RhinoObject into an Extrusion.

IEnumerable<RhinoObject> allExtrusion = doc.Objects.GetObjectList(ObjectType.Extrusion);
foreach (RhinoObject obj in allExtrusion)
{
     // Turn my RhinoObject into Extrusion type
     // Get the curve
     // And do other things...
}

I’ve managed to do the same thing with polylines, using this experiment :

IEnumerable<RhinoObject> allCurve = doc.Objects.GetObjectList(ObjectType.Curve);
foreach (RhinoObject objCurve in allCurve)
{
     ObjRef refCurve = new ObjRef(objCurve.Id);
     Curve curve = refCurve.Curve();
     Polyline poly; 
     curve.TryGetPolyline(out poly);

     // Other things...
}

But I didn’t find a method to get Extrusion from an ObjRef as well…

Thanks a lot for your answers.


(Menno Deij - van Rijswijk) #2
IEnumerable<RhinoObject> allExtrusion = doc.Objects.GetObjectList(ObjectType.Extrusion);
foreach (RhinoObject obj in allExtrusion)
{
    GeometryBase geom = obj.Geometry;
    Extrusion x = geom as Extrusion;
    if (null != x)
    {
        // aha! my object's geometry is an extrusion.
    }
}

#3

Thank you very much !
So easy…