OBJ export batching

Hi!

I made a python script witch generates the meshes in a loop, and I would like to export them one-by-one in .obj (one obj for one mesh). Now I’m try with the scriptcontext.doc.WriteFile(), but it pops up a the ‘OBJ Export Options’ window. It is not goot for me, because I would like to generate many thousands of objects, and I don’t want to click the ok every time ;).

Do you know a better method to batching the .obj export?

Hi Viktor,

one way is to use rs.Command instead and script the _-Export command to suppress the dialog. Make shure (only) the object to export is selected via your script, then use something like this:

path = "C:\MyFolder\ObjectName.obj"
cmd = "_-Export " + path + " _EnterEnd"
rs.Command(cmd)

You can set various obj specific options before passing _EnterEnd. Make shure you unselect exported objects once done.

c.

1 Like

Thank You, it works, but it remeshing my objects:

Save file name ( Version=5 SaveSmall=No GeometryOnly=No SaveTextures=No SavePlugInData=Yes Browse ): C:\Users\ChuBakka\Works\Export\exportTest9.obj
Choose OBJ option ( Geometry=Mesh EndOfLine=CRLF ExportRhinoObjectNames=ExportObjectsAsOBJObjects ExportRhinoGroupOrLayerNames=ExportLayersAsOBJGroups SortByOBJGroups=No ExportMeshTextureCoordinates=Yes ExportMeshVertexNormals=Yes CreateNGons=No ExportMaterialDefinitions=No YUp=No WrapLongLines=Yes VertexWelding=Unmodified WritePrecision=8 ): _EnterEnd
Choose OBJ option ( Geometry=Mesh EndOfLine=CRLF ExportRhinoObjectNames=ExportObjectsAsOBJObjects ExportRhinoGroupOrLayerNames=ExportLayersAsOBJGroups SortByOBJGroups=No ExportMeshTextureCoordinates=Yes ExportMeshVertexNormals=Yes CreateNGons=No ExportMaterialDefinitions=No YUp=No WrapLongLines=Yes VertexWelding=Unmodified WritePrecision=8 ):
Choose meshing option ( DetailedOptions PolygonDensity=50 ):
Meshing… Press Esc to cancel
File successfully written as C:\Users\ChuBakka\Works\Export\exportTest9.obj

I don’t need to remesh them because they are meshes already. Could I scip this step somehow?

Hi Viktor, if it is a mesh allready, Rhino cannot remesh it on export. It just shows you the message “Meshing…Press ESC to cancel” but your mesh will stay the same. You can prove it by re-importing an exported mesh. It should be identical to the source.

Btw. To get rid of the commandline clutter, you can turn command echoing off like this:

rs.Command(cmd, False)

c.

viktorius
can you post your script
cuz im stuck in trying to export as a DXF 250 files
and i need to know how to use the scriptcontext.doc.writefile

and your script can be a good example

Hi Toussaint,

you may find some example batch import / export script examples at these links A, B and C.

c.