diff --git a/dxf.py b/dxf.py index c00ab1a..d544575 100755 --- a/dxf.py +++ b/dxf.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +from __future__ import print_function from math import * from svg import * diff --git a/make_all_machines.py b/make_all_machines.py new file mode 100644 index 0000000..96ff805 --- /dev/null +++ b/make_all_machines.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python + +from __future__ import print_function +from make_machine import make_machine +from render import render +from views import views +from prune import prune +from set_machine import set_machine + +machines = ["dibond", "dibond_E3D", "sturdy", "mendel", "huxley", "sturdy_E3D"] +has_manual = ["dibond"] +has_views = ["dibond", "sturdy", "huxley"] + +for machine in machines: + make_machine(machine) + + if machine in has_manual: + render(machine) + + if machine in has_views: + views(machine, False) + + if '_' in machine and machine.split('_')[0] in machines: + prune(machine) +set_machine("dibond") diff --git a/make_machine.py b/make_machine.py index e0db901..864b413 100755 --- a/make_machine.py +++ b/make_machine.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +from __future__ import print_function import sys from bom import boms from sheets import sheets diff --git a/plates.py b/plates.py index 671a16e..ffb6b6f 100755 --- a/plates.py +++ b/plates.py @@ -1,39 +1,42 @@ #!/usr/bin/env python +from __future__ import print_function import sys import os import shutil +from time import * + from stls import stls, bom_to_stls -plate_list = [ - "cal.stl", - "atx_brackets.stl", - "bar_clamps.stl", - "cable_clips.stl", - "d_motor_brackets.stl", - "fixing_blocks.stl", - "ribbon_clamps.stl", - "small_bits.stl", - "spool_holder_brackets.stl", - "wades_extruder.stl", - "x_carriage_parts.stl", - "y_bearing_mounts.stl", - "y_belt_anchors.stl", - "z_motor_brackets.stl" -] - def plates(machine): + plate_list = [ + "cal.stl", + "atx_brackets.stl", + "bar_clamps.stl", + "cable_clips.stl", + "d_motor_brackets.stl", + "fixing_blocks.stl", + "ribbon_clamps.stl", + "small_bits.stl", + "spool_holder_brackets.stl", + "wades_extruder.stl", + "x_carriage_parts.stl", + "y_bearing_mounts.stl", + "y_belt_anchors.stl", + "z_motor_brackets.stl" + ] # # Make the target directory # target_dir = machine + "/stls/printed" if os.path.isdir(target_dir): shutil.rmtree(target_dir) + sleep(0.1) os.makedirs(target_dir) # # Make the stls in the list # - if not machine in ["sturdy", "mendel"]: + if not machine in ["sturdy", "sturdy_E3D", "mendel"]: plate_list.remove("cable_clips.stl") if machine == "huxley": plate_list.remove("atx_brackets.stl") diff --git a/prune.py b/prune.py new file mode 100644 index 0000000..272e25d --- /dev/null +++ b/prune.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python + +from __future__ import print_function +import sys +import os +import shutil +import filecmp + + +def prune_dir(dst, src): + for file in os.listdir(dst): + dfile = dst + '/' + file + sfile = src + '/' + file + if os.path.isdir(dfile): + prune_dir(dfile, sfile) + else: + if not os.path.isfile(sfile) or not filecmp.cmp(dfile, sfile): + print(dfile) + else: + os.remove(dfile) + +def prune(variant): + # + # Check directories exist + # + target_dir = variant + if not os.path.isdir(target_dir): + print("directory", target_dir, "does not exist") + return + + source_dir = variant.split('_')[0] + if not os.path.isdir(source_dir): + print("directory", source_dir, "does not exist") + return + + prune_dir(target_dir, source_dir) + +if __name__ == '__main__': + if len(sys.argv) == 2: + prune(sys.argv[1]) + else: + print("usage: remove_identical_files machine_variant") + sys.exit(1) diff --git a/render.py b/render.py index ce1970b..cd06f0d 100755 --- a/render.py +++ b/render.py @@ -1,12 +1,13 @@ #!/usr/bin/env python +from __future__ import print_function import os import sys import shutil import subprocess from time import * -def render(machine, parts): +def render(machine, parts = None): stl_dir = machine + os.sep + "stls" render_dir = machine + os.sep + "render" @@ -42,5 +43,5 @@ if __name__ == '__main__': if len(sys.argv) > 1: render(sys.argv[1], sys.argv[2:]) else: - print "usage: render dibond|mendel|sturdy|huxley|your_machine, [part.stl ...]" + print("usage: render dibond|mendel|sturdy|huxley|your_machine, [part.stl ...]") sys.exit(1) diff --git a/sheets.py b/sheets.py index 3f96802..fe760e2 100755 --- a/sheets.py +++ b/sheets.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +from __future__ import print_function import os import openscad import InkCL diff --git a/stls.py b/stls.py index dda802c..dce2256 100755 --- a/stls.py +++ b/stls.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +from __future__ import print_function import os import openscad import shutil diff --git a/views.py b/views.py index 4888e46..3fb585e 100644 --- a/views.py +++ b/views.py @@ -1,20 +1,22 @@ #!/usr/bin/env python +from __future__ import print_function import os import sys import shutil import openscad import re from set_machine import * +from time import * - - -def views(machine): +def views(machine, clean = False): scad_dir = "views" render_dir = machine + os.sep + "views" - if not os.path.isdir(render_dir): - os.makedirs(render_dir) + if os.path.isdir(render_dir): + shutil.rmtree(render_dir) + sleep(0.1) + os.makedirs(render_dir) # # Set the target machine # @@ -65,7 +67,7 @@ def views(machine): d = float(words[10]) if dx == None or rx == None or d == None: - print "Missing camera data in " + scad_name + print("Missing camera data in " + scad_name) sys.exit(1) camera = "%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f" % (dx, dy, dz, rx, ry, rz, d) @@ -83,11 +85,11 @@ def views(machine): "--camera=" + camera, "-D$exploded=" + exploded, "-o", png_name, scad_name) - print + print() if __name__ == '__main__': if len(sys.argv) > 1: views(sys.argv[1]) else: - print "usage: views dibond|mendel|sturdy|huxley|your_machine" + print("usage: views dibond|mendel|sturdy|huxley|your_machine") sys.exit(1)