C# . Problem with FindByUserString, Curves

Hello everybody. I’m a long time Rhino and Grasshopper user, I have just started doing some programming. Some basic scripts have worked “flawlessly” with help of the solutions offered in this forum, but now I ask for your help.

I’ve been trying to filter the geometry in a Document to find some objects that I had already tagged with some user strings. The selections goes ok, but then I do not know how to “extract” the curves from the objects. And the objects should already be curves, for I use ObjectType.Curve as a filter on the FindByUserString parameter.

Any Idea how I could solve my problem??? Thanks!!!

        RhinoObject[] TrazasDoc = doc.Objects.FindByUserString("Alignment", "true", false,true,true,ObjectType.Curve);
        List<Curve> Trazas = new List<Curve>();

        foreach (RhinoObject TrazaDoc in TrazasDoc)
        {
            if (TrazaDoc. ??????? = ObjectType.Curve)   <--------------------------------------------
                Trazas.Add(TrazaDoc[0]);
        }

Hi Pedro,

doc.Objects.FindByUserString returns RhinoObjects
https://developer.rhino3d.com/api/RhinoCommon/html/T_Rhino_DocObjects_RhinoObject.htm

the Curve object is the geometry part of the RhinoObject:

RhinoObject.Geometry

Does this help?
-Willem

Hi Willem,

Thank you for your comment. I’ve managed to do this:

RhinoObject[] TrazasDoc = doc.Objects.FindByUserString(“Alignment”, “true”, false,true,true,ObjectType.Curve);

        List<Curve> Trazas = new List<Curve>();

        for (int i = 0; i < TrazasDoc.Length; i++)
            Trazas.Add(TrazasDoc.Object(i).Curve());

And that should give me the Curves as a List. I hope it works, I’ll post later the advances if there is any.

Thank you!