mirror of
https://github.com/nophead/Mendel90.git
synced 2025-08-29 16:00:35 +02:00
Render.py can now do a single file.
Added delay after rmtree() to avoid race condition on Win7 with SSD.
This commit is contained in:
19
render.py
19
render.py
@@ -4,23 +4,32 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
|
from time import *
|
||||||
|
|
||||||
def render(machine):
|
def render(machine, parts):
|
||||||
stl_dir = machine + os.sep + "stls"
|
stl_dir = machine + os.sep + "stls"
|
||||||
render_dir = machine + os.sep + "render"
|
render_dir = machine + os.sep + "render"
|
||||||
|
|
||||||
if os.path.isdir(render_dir):
|
if os.path.isdir(render_dir):
|
||||||
shutil.rmtree(render_dir) #clear out any dross
|
if not parts:
|
||||||
|
shutil.rmtree(render_dir) #if doing them all clear the directory first
|
||||||
|
sleep(0.1)
|
||||||
os.makedirs(render_dir)
|
os.makedirs(render_dir)
|
||||||
|
else:
|
||||||
|
os.makedirs(render_dir)
|
||||||
|
|
||||||
#
|
#
|
||||||
# List of individual part files
|
# List of individual part files
|
||||||
#
|
#
|
||||||
|
if parts:
|
||||||
|
stls = [i[:-4] for i in parts]
|
||||||
|
else:
|
||||||
stls = [i[:-4] for i in os.listdir(stl_dir) if i[-4:] == ".stl"]
|
stls = [i[:-4] for i in os.listdir(stl_dir) if i[-4:] == ".stl"]
|
||||||
#
|
#
|
||||||
# Add the multipart files
|
# Add the multipart files
|
||||||
#
|
#
|
||||||
for i in os.listdir(stl_dir + os.sep + "printed"):
|
for i in os.listdir(stl_dir + os.sep + "printed"):
|
||||||
if not i[:-4] in stls:
|
if i[-4:] == ".stl" and not i[:-4] in stls:
|
||||||
stls.append("printed" + os.sep + i[:-4])
|
stls.append("printed" + os.sep + i[:-4])
|
||||||
|
|
||||||
for i in stls:
|
for i in stls:
|
||||||
@@ -31,7 +40,7 @@ def render(machine):
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
render(sys.argv[1])
|
render(sys.argv[1], sys.argv[2:])
|
||||||
else:
|
else:
|
||||||
print "usage: render [mendel|sturdy|your_machine]"
|
print "usage: render dibond|mendel|sturdy|your_machine, [part.stl ...]"
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
Reference in New Issue
Block a user