1
0
mirror of https://github.com/nophead/Mendel90.git synced 2025-08-27 23:10:01 +02:00

Now combines some STLs into single files and puts all the ones that need printing the the plates directory.

Added hash bangs for Linux users.
This commit is contained in:
Chris Palmer
2012-03-16 00:31:47 +00:00
parent df12df0354
commit 77b4add099
68 changed files with 385459 additions and 4500 deletions

36
stls.py
View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python
import os
import openscad
import shutil
@@ -5,6 +7,19 @@ import sys
source_dir = "scad"
def bom_to_stls(machine):
#
# Make a list of all the stls in the BOM
#
stl_files = []
for line in open(machine + "/bom/bom.txt", "rt").readlines():
words = line.split()
if words:
last_word = words[-1]
if len(last_word) > 4 and last_word[-4:] == ".stl":
stl_files.append(last_word)
return stl_files
def stls(machine, parts = None):
#
# Make the target directory
@@ -25,21 +40,16 @@ def stls(machine, parts = None):
f.close()
#
# Make a list of all the stls in the BOM
# Decide which fils to make
#
if parts:
targets = parts
targets = list(parts) #copy the list so we dont modify the list passed in
else:
targets = []
for line in open(machine + "/bom/bom.txt", "rt").readlines():
words = line.split()
if words:
last_word = words[-1]
if len(last_word) > 4 and last_word[-4:] == ".stl":
targets.append(last_word)
targets = bom_to_stls(machine)
#
# Find all the scad files
#
used = []
for filename in os.listdir(source_dir):
if filename[-5:] == ".scad":
#
@@ -65,12 +75,18 @@ def stls(machine, parts = None):
stl_name = target_dir + "/" + module[:-4] + ".stl"
openscad.run("-o", stl_name, stl_maker_name)
targets.remove(stl)
#
# Add the files on the BOM to the used list for plates.py
#
for line in open("openscad.log"):
if line[:7] == 'ECHO: "' and line[-6:] == '.stl"\n':
used.append(line[7:-2])
#
# List the ones we didn't find
#
for module in targets:
print "Could not find", module
return used
if __name__ == '__main__':
if len(sys.argv) > 1: