Automate an export
Is there a way to automate an export?
I want to export my geometry as and IGES 144 with IGES tolerance of .1, units of inches, and none of the check boxes checked. Is there a way to do this?
I currently just run Command(“_Export”) but I’d like to make it a little more fool proof.
You should be able to use the "dashed" version of Export to get at the command line options that you want. Something like
Command('-_Export C:\\myfile.igs "IGES 144" Tolerance=0.1')
Originally Posted by Steve Baer
Thanks Steve. Do you (or anyone) know of any documentation that discusses this? I’m not having any luck finding it.
You mean help with scripting rs.Command()? There's only the page in the Python help (type "Command" in the index tab). Basically you need to create a string that duplicates the Rhino command line options in the order in which they are needed. Spaces in the string represent Enters. Sometimes it's a bit tricky to know which order to run the options - you often need to experiment with the Rhino interface version to figure it out or run the script then hit F2 to bring up the command history and see where it is going wrong. You can also get tripped up with some options, as they can either be in the form of:
ThisOption Value or ThatOption=Value (i.e. either a space or an equal sign, one will work and the other won't).
In your example, if you type -Export at the Rhino command line (assuming objects are preselected), the first thing you get is a prompt for a save file name. However, you have a bunch of other options, most of which concern Rhino files. These need to be programmed in your string before the file name, as if you enter a file name first it will export with the existing defaults...
So, rs.Command("_-Export Version=5 SaveSmall=No GeometryOnly=No SaveTextures=No SavePlugInData=Yes C:\\myfile.3dm")
Now, since you're exporting an IGES and not a 3DM, you need to follow how that works on the command line. First, you need to know that if the file name is filename.igs, that will automatically set the file type. So, in this case, you need to start with the filename. Then you get a prompt for the IGES export type plus the following: (ListTypes UnitSystem=Millimeter Tolerance=0.001). In this case, you can either enter the type first or the other options first because Rhino allows it (it doesn't always). Any options you don't script will use the existing command line values.
So you can use either
('-_Export C:\\myfile.igs "IGES 144" UnitSystem=Millimeter Tolerance=0.1')
('-_Export C:\\myfile.igs UnitSystem=Millimeter Tolerance=0.1 "IGES 144"')
Last edited by Mitch; 08-29-2012 at 05:39 PM.
Thanks Mitch. I was looking for specific documentation that explained how to write out IGES files using Python. Your explanation helps me understand the concept better. Now I see why I couldn’t find what I was looking for ;-)