Export as .3ds from python

I need to create many models with python and export them as .3ds files. In the code, I do some modification, then export, then modify, then export. etc… I cant find anything in the help docs for doing this. Does anyone know?

Thanks!

You can likely use the rs.command() function for this. While I haven’t exported anything myself, I have used it for importing and layering files from Autocad. Here is a simple example of how to import a .dwg file from within a Grasshopper Python component. There was a thread on how to construct the input strings for the rs.command() function over on the old Python forum, perhaps @stevebaer can dig it up if necessary. Hope that helps…

Awesome thank you!

import rhinoscriptsyntax as rs
filename = "1"
rs.Command("All")
rs.Command("_-Export " + filename + ".3ds _Enter")
1 Like

Here are the relevant posts from that old thread


@AndersDeleuran wrote

I almost had it except for the _Enter there at the end. Does it matter if one uses " " or “=” when passing arguments to the command? Here’s a (long) example for a .Dwg file:

rs.Command("_-import " + FilePath + " _ReadUnreferencedLayers=No _ReadUnreferencedBlocks=No _ReadUnreferencedLinetypes=No _WidePlinesAsSurfaces=No _IgnoreThickness=No _RegionsAsCurves=No _LayerMaterialsToColors=No _MeshPrecision=Automatic _ModelUnits=Centimeters _LayoutUnits=Millimeters _enter")

Anyhow, if anyone has any further suggestions for how to approach this using RhinoCommon, that would be most cool as well.

Thanks,
Anders


@Helvetosaur replied…

There is a difference between “=” and a space - they are not interchangeable. You generally need to put in what you see in the command line when running the command manually.

Usually, an “=” is used when assigning one of a fixed set of possibilities that the command has - like getting something from a list or a changing a boolean value (yes or no). OTOH, a space is an Enter and is used where Rhino is waiting for some arbitrary command line input like a number. But there are exceptions, Rhino is not always consistent in this regard, so sometimes you have to play and test to find the correct combo.

Also the order in which you pass the options is important - again the only way I really know how to do this is to run the scripted command and if something goes wrong, hit F2 and see what the command history says - it will tell you where it got unexpected input.
–Mitch