Python script to export STLs

Hi

This is a quick setup that seems to work:

import rhinoscriptsyntax as rs
import os


objects = rs.GetObjects("Select objects to export", 16)

for obj in objects:
    name = rs.ObjectName(obj)
    stl_suffix = '_{}.stl'.format(name)
    stl_basename = rs.DocumentName().split('.')[0]
    
    stl_fullname = '{}{}'.format(stl_basename,stl_suffix)

    stl_path = rs.DocumentPath()
    
    full_filepath = os.path.join(stl_path,stl_fullname)
    
    rs.SelectObject(obj)
    command_string = '-_Export "{}" _Enter _Enter'.format(full_filepath)
    rs.Command(command_string)
1 Like