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?
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.
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?
Good evening, I would like to join in here. @fabian, were you able to find resources/documentation?
@dale
I tried adding objects to a File3dmObjectTable as a File3dmObject().
Yet I get the following error.
Cannot create instances of File3dmObject because it has no public constructors
Pretty sure I am not using this correctly, but I cannot see why.
As @fabian says, it would be very comfy to be able to export content like that.
@stevebaer
I tried your approach. The problem I had was that for each object I tried to export Rhino closed the current document and opened the exported file.
Would it be okay for you to show how this is meant to be used?
@stevebaer thanks. Works.
Yet, the export would be better, because it supports any fileformat that rhino can export.
Do you see any chances that this might work “silent” like the SaveAs method?
@stevebaer a (hopefully) last question.
Let’s say I want to export Step-files or dxf-files and I want to chose an export scheme.
Is there any option to chose them when coding it or would that rather be controlled by the pre-setting chosen in Rhino in advance?
Defining different options for export programmatically is not currently available. This is a project we have been working on in Rhino 8 and will hopefully have something available in the next few weeks.
Hi @stevebaer , @dale ,
So currently, it is not possible to define the Export Scheme neither through the Export command?
For example, I would like to use 2007 Lines:
@djordje it works perfectly fine via the commandline. That’s how I am doing it so far. I think what @stevebaer means is that it does not work when using a RhinoDoc.
Yes, the command line scripting should work fine for the case that you are working with the active doc in Rhino. I was referring to a method of creating temporary docs that could be filled with geometry and exported.