Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5827

Rhino for Mac / Python script for batch-converting .stp to .obj

$
0
0

@Jonas_Ehstein wrote:

I tried to write the following script for opening all files from one folder and saving them in an other one.
However, it's not working and I can't figure out what I'm doing wrong. Im working with Version 5.3.2

Someone here that can point me to what exactly is wrong with this script?

import rhinoscriptsyntax as rs
import os.path

def BatchSaveAs():

    folder = rs.BrowseForFolder("/Users/jehrenstein/Desktop/TEST/stp")

    if folder: print folder

    saveFolder = rs.BrowseForFolder("/Users/jehrenstein/Desktop/TEST/obj")

    if saveFolder: print saveFolder

    for filename in os.listdir(folder):
        if filename.endswith(".stp"):
            fullpath = os.path.join(folder,filename).lower()
            rs.EnableRedraw(False)
            rs.DocumentModified(False)
            rs.Command("_-New _None",False)


            rs.Command('_-Open {} _Enter'.format(fullpath))
            comm="_-Export"
            rs.Command(comm + chr(34) + saveFolder + "/" + filename + chr(34) + ".obj" + "_Enter")


    rs.DocumentModified(False)
    rs.Command("_-New _None",False)
    rs.EnableRedraw(True)

BatchSaveAs()

Posts: 5

Participants: 4

Read full topic


Viewing all articles
Browse latest Browse all 5827

Trending Articles