Cast File3dmObject into RhinoObject


I’m upgrading a code from to rhinocommon, and I need change a function and read a 3dm file instead of to work with RhinoDoc.ActiveDoc

I open the file with File3dm.

File3dm file = File3dm.Read(pathRobot);

Read and need get all object in a layer.

File3dmObject[] objList = file.Objects.FindByLayer(rhinoLayer.Name);

But the objects there are File3dmObjects and I need RhinoObjects for the constructor in a class.

I can make other constructor, but I prefer to do casting, so

How can I convert the File3dmObjects in RhinoObjects?


Short answer: you can’t.

File3dmObject is part of the open source 3dm toolkit. RhinoObject is part of the closed source Rhino SDK.
You can create a constructor based on the geometry and attributes contained in the File3dmObject.

For example, to add an object read from File3dm to RhinoDoc:

File3dmObject obj; // read from 3dm
RhinoDoc doc; // available from e.g. a command or RhinoDoc.ActiveDoc

doc.Objects.Add(obj.Geometry, obj.Attributes);
1 Like

Oki, thanks

1 Like