Skip to content

Instantly share code, notes, and snippets.

@jhorikawa
Created February 21, 2020 19:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhorikawa/b13d88bf888ac68e19eafbbc466a3931 to your computer and use it in GitHub Desktop.
Save jhorikawa/b13d88bf888ac68e19eafbbc466a3931 to your computer and use it in GitHub Desktop.
Rhinoscript snippet to batch convert all ascii stl files to binary stl files in a selected folder.
import rhinoscriptsyntax as rs
from os import listdir
from os.path import isfile, join
folder = rs.BrowseForFolder()
if folder is not None:
files = [f for f in listdir(folder) if isfile(join(folder, f))]
for file in files:
f = file.split('.')
if len(f) == 2 and f[1] == 'stl':
filepath = join(folder, file)
filepath = '"' + filepath + '"'
rs.Command("-_Import " + filepath + " _Enter")
rs.Command("_Flip")
rs.Command('-_Export "' + join(folder,f[0]+'-b.stl') + '" _Enter')
rs.Command('_SelAll')
rs.Command('_Delete')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment