2014-06-12 19:21:16 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
from __future__ import print_function
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import bom
|
|
|
|
import stls
|
|
|
|
import shutil
|
|
|
|
import os
|
|
|
|
|
|
|
|
def accessories(machine, assembly = None):
|
2014-06-19 14:46:17 +01:00
|
|
|
assemblies = [
|
|
|
|
"raspberry_pi_assembly",
|
|
|
|
"raspberry_pi_camera_assembly",
|
|
|
|
"light_strip_assembly",
|
|
|
|
"z_limit_switch_assembly"
|
|
|
|
]
|
2014-06-12 19:21:16 +01:00
|
|
|
#
|
|
|
|
# Make the target directory
|
|
|
|
#
|
|
|
|
target_dir = machine + "/stls/accessories"
|
|
|
|
if os.path.isdir(target_dir):
|
|
|
|
if not assembly:
|
|
|
|
shutil.rmtree(target_dir) #if making all of them clear the directory first
|
|
|
|
os.makedirs(target_dir)
|
|
|
|
else:
|
|
|
|
os.makedirs(target_dir)
|
|
|
|
|
|
|
|
|
|
|
|
if assembly:
|
|
|
|
assemblies = [ assembly ]
|
2014-06-19 14:46:17 +01:00
|
|
|
|
2014-06-12 19:21:16 +01:00
|
|
|
for assembly in assemblies:
|
|
|
|
print(assembly)
|
|
|
|
bom.boms(machine, assembly)
|
|
|
|
stl_list = stls.bom_to_stls(machine, assembly)
|
|
|
|
stls.stls(machine, stl_list)
|
|
|
|
#
|
|
|
|
# Move all the stls that are not in the plates to the plates directory
|
|
|
|
#
|
|
|
|
for file in stl_list:
|
|
|
|
src = machine + "/stls/"+ file
|
|
|
|
if os.path.isfile(src):
|
|
|
|
shutil.move(src, target_dir + "/" + file)
|
|
|
|
else:
|
|
|
|
print("can't find %s to move" % src)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
args = len(sys.argv)
|
2016-01-02 13:54:07 +00:00
|
|
|
if args in [2,3]:
|
|
|
|
if args == 3:
|
2014-06-12 19:21:16 +01:00
|
|
|
accessories(sys.argv[1], sys.argv[2])
|
|
|
|
else:
|
|
|
|
accessories(sys.argv[1])
|
|
|
|
else:
|
2016-01-16 10:47:25 +00:00
|
|
|
print("usage: accessories dibond|mendel|sturdy|huxley|your_machine [assembly_name]")
|
2014-06-12 19:21:16 +01:00
|
|
|
sys.exit(1)
|