GH/PY bake and export mesh as obj



Hi all,

I have a few questions regarding what I’m currently working on:
A script with python to bake the referenced geometry into rhino and then export as obj.* (9.7 KB)

First, the baking process seems generally fine. Although, because it is basically copied over from @piac 's script from 2013/2015, I am wondering if there are any updates to be done within the component since then:

Secondly, I added a few lines for the exporting process from @clement 's code here:

However, a property doesn’t seem to work (line 25 in script), and returns error stating that the object is read-only:

Rhino.FileIO.FileObjWriteOptions.ObjGroupNames = 1


I would like to export the meshes as separate objs similar to selecting the “Layers as OBJ groups” options in Export Options in Rhino WIP, so that when they are imported back in later they could be separate meshes.

*Please toggle the bake first before toggling the export.

Thanks a lot!



Hi @timothytai,

i think you need to write below, in one line:

obj_options.ExportGroupNameLayerNames = Rhino.FileIO.FileObjWriteOptions.ObjGroupNames.LayerAsGroup

does it work ?



Hi clement,

Thanks a lot - it works !
Any advice on the baking part?




Hi @timothytai, what is wrong with the baking part ? (It worked here)



Hi clement,

It does work here, but I was just wondering if there’s maybe some other way of doing this.
For instance, if there is currently other geometries visible in the Rhino document, the export component will export out everything. I understand that there is an option to export only selected objects, but wondering if it is possible to either not having to bake the geometry, and export whatever is referenced, or export only the baked geometry and not other objects. (I guess it still isn’t really about the baking, but more on the overall workflow)

Thanks again!



apart from exporting what has been baked you could write the mesh manually as a textfile using the information available from decomposing the mesh.

In the topic above @atair posted an file, maybe you could try this as an alternative.