Read/import object from file

Hi all,

I’m trying to get a reference of a mesh in a 3dmfile. To do some stuff with it, but i’m not succeeding in this.
I would like to do something like.
file3dm.read(myfile)
then select mesh form objecttable
mesh mymesh = selected mesh from objecttable.

I succeeded in adding a object from file to my current rhinodoc. But this should be done only after deforming this mesh.

Hopefully one of you van help me out.

kind regards,

Reinder

Hi all,

I found the solution! :smiley:
Below a copy of the code i found on : rhino-developer-samples/Program.cs at 7 · mcneel/rhino-developer-samples · GitHub. The provided sample is of course for curves.

public static void Main(string args)
{
Console.WriteLine(“Hello World!”);

        //read file
        var file3dm = File3dm.Read("../../curves.3dm");
        Console.WriteLine("Number of objects in file {0}", file3dm.Objects.Count);

        //get objects

        var curves = new List<Curve>();

        foreach ( var obj in file3dm.Objects )
        {
            if ( obj.Geometry is Curve )
            {
                curves.Add( obj.Geometry as Curve );
            }
        }

        //call join

        var joined = Curve.JoinCurves(curves)[0];

        //save new file

        File3dm newFile = new File3dm();
        newFile.Objects.AddCurve(joined);
        newFile.Write("newFile.3dm", null);
        
    }

greets Reinder