How to use File3dmObjectTable.Add?

I might be missing some entirely, but I am stuck in a dead end here.

My task is to take a bunch of objects (by GUID) and export those objects into a new 3dm-file. So I thought I’d create a new File3dm-instance, add copies of the objects at hand to its empty object table and write the file. But:

  • Rhino.FileIO.File3dm gives access to the property Objects, which contains all objects.
  • File3dmObjectTable has a method Add(item) that “duplicates the object, then adds a copy of the object to the document”. That sounds great, because I am getting a mixed platter of objects and don’t want to distinguish between AddBrep, AddCurve etc.
  • Add(item) takes a single item of type File3dmObject
  • File3dmObject has NO constructor and I couldn’t find any method that returns a File3dmObject - except for taking them out of aFile3dmObjectTable.

So, there’s no easy way to add a copy of an object in the current file to the object table of a new file?

Moved to Developer category

Sorry for misplacing… :grimacing:

I moved it so other developers would see it.
Generally, uncategorized messages are ignored.

Cheers

Hi @fabian,

You could trying writing a 3dm file yourself. But with all the stuff that hands of Rhino objects (e.g. layers, materials, etc.), and since you have the object id’s, it’s way easier to just select the object and then script the _-Export command.

– Dale

Hi @dale,

I thought about the Export-command too, and this is what I am using now. But my list of objects might contain some hidden or locked ones on hidden or locked layers. I hoped there would be an easy way to just write the objects out, instead of switching layers on, unlocking them, unhiding and unlocking objects etc…

When I have more time, I need to get into writing 3dm-files - any hints where I can get more documentation on that?

Thanks anyway! Fabian

Are you using Rhino 7? If you are, then you could create a headless RhinoDoc, fill it with geometry and write that document.