mirror of
https://github.com/nophead/Mendel90.git
synced 2025-01-16 20:38:15 +01:00
Mods for Python 3 compatibility.
Added make_all_machines.py to build all variations.
This commit is contained in:
parent
055c47dc45
commit
8a5578948f
1
dxf.py
1
dxf.py
@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from __future__ import print_function
|
||||
from math 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
|
||||
|
||||
from __future__ import print_function
|
||||
import sys
|
||||
from bom import boms
|
||||
from sheets import sheets
|
||||
|
13
plates.py
13
plates.py
@ -1,11 +1,15 @@
|
||||
#!/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 = [
|
||||
def plates(machine):
|
||||
plate_list = [
|
||||
"cal.stl",
|
||||
"atx_brackets.stl",
|
||||
"bar_clamps.stl",
|
||||
@ -20,20 +24,19 @@ plate_list = [
|
||||
"y_bearing_mounts.stl",
|
||||
"y_belt_anchors.stl",
|
||||
"z_motor_brackets.stl"
|
||||
]
|
||||
|
||||
def plates(machine):
|
||||
]
|
||||
#
|
||||
# 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")
|
||||
|
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
|
||||
|
||||
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)
|
||||
|
@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from __future__ import print_function
|
||||
import os
|
||||
import openscad
|
||||
import InkCL
|
||||
|
1
stls.py
1
stls.py
@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from __future__ import print_function
|
||||
import os
|
||||
import openscad
|
||||
import shutil
|
||||
|
16
views.py
16
views.py
@ -1,19 +1,21 @@
|
||||
#!/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):
|
||||
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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user