mirror of
https://github.com/nophead/Mendel90.git
synced 2025-07-31 18:40:14 +02:00
Mods for Python 3 compatibility.
Added make_all_machines.py to build all variations.
This commit is contained in:
1
dxf.py
1
dxf.py
@@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
from math import *
|
from math import *
|
||||||
from svg import *
|
from svg import *
|
||||||
|
|
||||||
|
25
make_all_machines.py
Normal file
25
make_all_machines.py
Normal file
@@ -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")
|
@@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
from bom import boms
|
from bom import boms
|
||||||
from sheets import sheets
|
from sheets import sheets
|
||||||
|
39
plates.py
39
plates.py
@@ -1,39 +1,42 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
from time import *
|
||||||
|
|
||||||
from stls import stls, bom_to_stls
|
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):
|
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
|
# Make the target directory
|
||||||
#
|
#
|
||||||
target_dir = machine + "/stls/printed"
|
target_dir = machine + "/stls/printed"
|
||||||
if os.path.isdir(target_dir):
|
if os.path.isdir(target_dir):
|
||||||
shutil.rmtree(target_dir)
|
shutil.rmtree(target_dir)
|
||||||
|
sleep(0.1)
|
||||||
os.makedirs(target_dir)
|
os.makedirs(target_dir)
|
||||||
#
|
#
|
||||||
# Make the stls in the list
|
# 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")
|
plate_list.remove("cable_clips.stl")
|
||||||
if machine == "huxley":
|
if machine == "huxley":
|
||||||
plate_list.remove("atx_brackets.stl")
|
plate_list.remove("atx_brackets.stl")
|
||||||
|
43
prune.py
Normal file
43
prune.py
Normal file
@@ -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)
|
@@ -1,12 +1,13 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
from time import *
|
from time import *
|
||||||
|
|
||||||
def render(machine, parts):
|
def render(machine, parts = None):
|
||||||
stl_dir = machine + os.sep + "stls"
|
stl_dir = machine + os.sep + "stls"
|
||||||
render_dir = machine + os.sep + "render"
|
render_dir = machine + os.sep + "render"
|
||||||
|
|
||||||
@@ -42,5 +43,5 @@ if __name__ == '__main__':
|
|||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
render(sys.argv[1], sys.argv[2:])
|
render(sys.argv[1], sys.argv[2:])
|
||||||
else:
|
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)
|
sys.exit(1)
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import os
|
import os
|
||||||
import openscad
|
import openscad
|
||||||
import InkCL
|
import InkCL
|
||||||
|
1
stls.py
1
stls.py
@@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import os
|
import os
|
||||||
import openscad
|
import openscad
|
||||||
import shutil
|
import shutil
|
||||||
|
18
views.py
18
views.py
@@ -1,20 +1,22 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import shutil
|
import shutil
|
||||||
import openscad
|
import openscad
|
||||||
import re
|
import re
|
||||||
from set_machine import *
|
from set_machine import *
|
||||||
|
from time import *
|
||||||
|
|
||||||
|
def views(machine, clean = False):
|
||||||
|
|
||||||
def views(machine):
|
|
||||||
scad_dir = "views"
|
scad_dir = "views"
|
||||||
render_dir = machine + os.sep + "views"
|
render_dir = machine + os.sep + "views"
|
||||||
|
|
||||||
if not os.path.isdir(render_dir):
|
if os.path.isdir(render_dir):
|
||||||
os.makedirs(render_dir)
|
shutil.rmtree(render_dir)
|
||||||
|
sleep(0.1)
|
||||||
|
os.makedirs(render_dir)
|
||||||
#
|
#
|
||||||
# Set the target machine
|
# Set the target machine
|
||||||
#
|
#
|
||||||
@@ -65,7 +67,7 @@ def views(machine):
|
|||||||
d = float(words[10])
|
d = float(words[10])
|
||||||
|
|
||||||
if dx == None or rx == None or d == None:
|
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)
|
sys.exit(1)
|
||||||
|
|
||||||
camera = "%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f" % (dx, dy, dz, rx, ry, rz, d)
|
camera = "%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f" % (dx, dy, dz, rx, ry, rz, d)
|
||||||
@@ -83,11 +85,11 @@ def views(machine):
|
|||||||
"--camera=" + camera,
|
"--camera=" + camera,
|
||||||
"-D$exploded=" + exploded,
|
"-D$exploded=" + exploded,
|
||||||
"-o", png_name, scad_name)
|
"-o", png_name, scad_name)
|
||||||
print
|
print()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
views(sys.argv[1])
|
views(sys.argv[1])
|
||||||
else:
|
else:
|
||||||
print "usage: views dibond|mendel|sturdy|huxley|your_machine"
|
print("usage: views dibond|mendel|sturdy|huxley|your_machine")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
Reference in New Issue
Block a user