Batch operations in Rhino files

Hello everyone,
We have thousands of files in our server that are almost never opened, but have to be there just in case.
If we could just delete their display meshes to save disk space, that would be great.

The files usually shrink to a 1/3 of the size when I use [SaveSmall] or [ClearAllMeshes].
I would like to know if there is a way to perform a batch operation of a Rhino macro, so that operation could be performed on all specified files at once.

Photoshop works like this: You create a “macro”, like “open this folder, do this and this, save and close”, Can you do that in Rhino, create a “macro” and it will apply it on several files at once?

I don’t know how to create a script like that from scratch, but if It thats possible with RhinoScript, Python or C# I would be very grateful for a direction from where to start.

Thank you!

Hello - here is an old RhinoScript from Dale Fugier - see how that works. Drag and drop it onto Rhino and then type in BatchSaveSmall to run it.

BatchSaveSmall.rvb (3.5 KB)


Hi Pascal, thanks for the response.
The ol’develpers page, some real hidden gems there

Had to make a little edit on Dale’s code to keep layers as they were and backwards compatibility, other than that the code works perfectly. My sample folder had 1,41GB, and after running the script, got down to 400MB. Perfect, just what I needed.

Thank you very much!

Hello everyone again!
Continuing with the quest to clean our thousand .3dm files, we’re succesfully cleaning the render meshes and materials with [Purge], but encountered yet another problem: Textures and Environments.

I’ve edited the attached script so it could [SaveSmall as Rhino 4], and clean only the materials.

Call Rhino.Command(“_Purge _BlockDefinitions=_No _DimStyles=_No _Groups=_No _HatchPatterns=_No _Layers=_No _Linetypes=_No _Materials=_Yes _Enter”, 0)
Call Rhino.Command(“-_Save _Version=4 _Enter”, 0)

There’s files with over 3000 environments accumulated over years of rendering and copy+pasting between projects, and now all that data is starting to become a really BIG problem.

Files over 250MB become only 16MB after manually cleaning environments and textures.

I wonder if there is a Rhino.Command we could use to delete ALL environments and textures as well?

BatchSaveSmall.rvb (3.5 KB)

Hello -
-Save, with SaveTextures=No will do what I think you are asking - the references to the textures will not be removed but the textures will not be in the file, they will have to be found on the disk or network to be used.

Does that get at what you need?


Thanks @pascal for the feedback. In this case it doesn’t get what we need.
All files are saved in the smallest size possible, while maintaining the information needed.
We always save our files like this:

! -_Save V=4 _SaveSmall=Yes _SaveTextures=No Enter

If we add SavePlugInData=No to the “Save Macro” above, we lose all plugin informartion, and that can’t happen (we use Gemvision’s Matrix 7 for Jewelry, based on Rhino 4, and all the files need to be compatible).

I’m really looking for a direction to embed a “Delete All Textures and Environments” within our file cleaning script. I’m not that experienced in Rhino Script I couldn’t find a way to deal with that information in the developers documentation.

All that It wouldn’t be such a issue if Rhino didn’t carry all the environments and textures while copy+pasting and importing from one file to another.

Well, if you save without textures, the textures will not be saved - they will not take up space in the file, (so if you were to delete all the textures from your disk, the file would open with none showing) - if that is the issue. But right now, no good way comes to mind to actually remove these from the file before saving without losing material assignments. But I am still a little stuck on what the goal is.


Sorry if I’m being confusing. What I’m really looking for is an direction to how can I add “Delete All Textures and Environments” in my Rhino Script. I could’nt find a command like that in the documentation.
In short, to do in a script, what I’m doing below:

As an example of the asset multiplication I’m talking about, the file from this screenshot was itself never rendered, but carries the renders assets from the files wich the objects come from.
The problem about still having those references to the textures in the file is that, when opening a file with 500 textures and environments, Rhino takes forever searching those on our network and drives.

(I hope I made myself clearer this time, thank you so much for the help.)

I see - I guess I do not know the answer to that from a scripting point of view - I’ll dig around - Purge has more to offer in V7, compared to V6, assigning a default material to everything will allow Purge (V7) to get rid of any textures used in materials and Purge also optionally removes environment textures as well.

‘Bitmaps’ here refers, I expect (not tested) to the bitmap table where BackgroundBitmaps and possibly Wallpaper are stored.


It’s great that Purge is improving in Rhino 7. Did you find any any tips on where to find this resource in a script in Rhino 6?