Created
February 21, 2020 19:48
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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