mirror of
https://github.com/nophead/Mendel90.git
synced 2025-08-01 11:00:16 +02:00
Render.py modifeid to work on Windows and handle the composite STLs in the printed directory.
Added renders for mendel version.
This commit is contained in:
42
render.py
42
render.py
@@ -1,27 +1,37 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
import shutil
|
||||
import commands
|
||||
import subprocess
|
||||
|
||||
def render(machine):
|
||||
render_dir = machine + os.sep + "render"
|
||||
print render_dir
|
||||
try:
|
||||
os.stat(render_dir)
|
||||
except:
|
||||
os.mkdir(render_dir)
|
||||
li = os.listdir(machine+os.sep+'stls')
|
||||
stls = []
|
||||
for i in li:
|
||||
stls.append(i[:-4])
|
||||
for i in stls:
|
||||
command = 'blender -b utils'+os.sep+'render.blend -P utils'+os.sep+'viz.py -- '+machine+os.sep+'stls'+os.sep+i+'.stl '+machine+os.sep+'render'+os.sep+i+'.png'
|
||||
print(command)
|
||||
print commands.getstatusoutput(command)[1]
|
||||
stl_dir = machine + os.sep + "stls"
|
||||
render_dir = machine + os.sep + "render"
|
||||
|
||||
if os.path.isdir(render_dir):
|
||||
shutil.rmtree(render_dir) #clear out any dross
|
||||
os.makedirs(render_dir)
|
||||
#
|
||||
# List of individual part files
|
||||
#
|
||||
stls = [i[:-4] for i in os.listdir(stl_dir) if i[-4:] == ".stl"]
|
||||
#
|
||||
# Add the multipart files
|
||||
#
|
||||
for i in os.listdir(stl_dir + os.sep + "printed"):
|
||||
if not i[:-4] in stls:
|
||||
stls.append("printed" + os.sep + i[:-4])
|
||||
|
||||
for i in stls:
|
||||
command = 'blender -b utils' + os.sep + 'render.blend -P utils' + os.sep + 'viz.py -- ' + \
|
||||
stl_dir + os.sep + i + '.stl ' + render_dir + os.sep + i + '.png'
|
||||
print(command)
|
||||
subprocess.check_output(command.split())
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) > 1:
|
||||
render(sys.argv[1])
|
||||
else:
|
||||
print "usage: bom [mendel|sturdy|your_machine]"
|
||||
print "usage: render [mendel|sturdy|your_machine]"
|
||||
sys.exit(1)
|
||||
|
Reference in New Issue
Block a user