GH/PY bake and export mesh as obj

python
mesh
unhandled
export

#1

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.*
bakeAndExport.gh (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

(http://developer.rhino3d.com/wip/api/RhinoCommonWin/html/T_Rhino_FileIO_FileObjWriteOptions_ObjGroupNames.htm)

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!

Tim


#2

Hi @timothytai,

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

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

does it work ?

_
c.


#3

Hi clement,

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

Best,

Tim


#4

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

_
c.


#5

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!


#6

@timothytai,

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 objWriter.gh file, maybe you could try this as an alternative.

_
c.