Script for exporting different geometries as separate .stl files

Hi!
I’m a complete novice when it comes to scripting. I’ve tried using ChatGPT for help, but I end up with error no matter how much it tries to help me.

I want to make a script or macro or something that allows me to export more than one geometry in Rhino as separate .stl files.
Any help is appriciated, I’ve attatched the script AI gave me that dosn’t work. Thank you.

TestScript 2.py (1.2 KB)

try
rs.filter.allobjects

@Helvetosaur has a few good scripts for this

1 Like

Thank you Martin. I will check that out and have a go!

1 Like

Yes…
Exports each object as a numbered file, uses last-used or default settings
BatchExportSTLByObjBasic.py (1.1 KB)

Hard-coded settings in the script - you can edit the script to change them
BatchExportSTLByObjWFixedSettingsPlus.py (2.6 KB)

Choice of four different settings - Coarse, Medium, Fine, Extra fine
BatchExportSTLByObjWSett.py (4.0 KB)

Any of these can be used as a starting point for further modifications

2 Likes

Hi Helvetosaur!
The Basic script worked like a charm.
I feel like the only thing I might want to change is the ability to give the stl files a name and maybe setup a folder where the stl files export to. I feel like there’s possibilities to do this in the script : BatchExportSTLByObjWFixedSettingsPlus

Can you point to which line in the script is responsible for the naming and destination of the export so to speak?

Quick bakground: I make custom insoles for 3d printing. Typically there would be between 1 and 5 meshes that I would like to export as separate stl files. These should have the ordernumber for the job + L (for left side) + 001 (partnumber). The same for the right insole but changed to R for right side.

Typing the ordernumber manually through the Commandline or something is okay. I will get by just fine with the basic script, but if there’s possibilities of polishing the workflow even more that super. Thanks for your time.
/ Linus

The basic script does ask for a folder where to store the files. In the “plus” script below, I added the possibility to add a prefix name to the object numbering. It currently adds an underscore between the prefix and the number, you can eliminate that by changing this:

image

to this:

image

(or change the separator to something else…)

I also added the option to change the start number to something other than 1 (0 minimum). Let me know if this works for you.

BatchExportSTLByObjBasicPlus.py (2.0 KB)

2 Likes

Worked like a charm! Thank you very much.

1 Like