cleanup

Mon, 03 Apr 2017 02:14:43 +0200

author
mdd
date
Mon, 03 Apr 2017 02:14:43 +0200
changeset 2
9ec8fa3d0348
parent 1
14a420653a5f
child 3
d8745f771267

cleanup

config.py file | annotate | diff | comparison | revisions
cylindertransport.py file | annotate | diff | comparison | revisions
cylindertransport.scad file | annotate | diff | comparison | revisions
data.py file | annotate | diff | comparison | revisions
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/config.py	Mon Apr 03 02:14:43 2017 +0200
@@ -0,0 +1,2 @@
+# pfad zu den TTF files (arial.ttf)
+FONTBASE = "/usr/share/fonts/truetype/msttcorefonts/"
--- a/cylindertransport.py	Mon Apr 03 01:32:02 2017 +0200
+++ b/cylindertransport.py	Mon Apr 03 02:14:43 2017 +0200
@@ -1,50 +1,16 @@
 from math import sqrt
 from PIL import Image, ImageDraw, ImageFont
 import argparse, sys
-
-# pfad zu den TTF files (arial.ttf)
-FONTBASE = "/usr/share/fonts/truetype/msttcorefonts/"
-
-SPACE_MIN = 10 # minimum offset between bottles
-
-SCADSCRIPT = "include <cylindertransport.scad>\n"
+from data import CYLINDER, PIPES
+from config import FONTBASE
 
-# Durchmesser, Laenge, Volumen und Gewicht der verfuegbaren Tauchflaschen
-CYLINDER = {
-	"03"	: [100, 515, 3,  4.7],
-	"05"	: [140, 466, 5,	 5.7],
-	"07"	: [140, 605, 7,  8.8],
-	"08"	: [171, 490, 8,  10.4],
-	"10"	: [171, 595, 10, 12.4],
-	"12S"	: [204, 550, 12, 15.4],
-	"12L"	: [171, 690, 12, 14.5],
-	"15"	: [204, 640, 15, 18.1],
-}
-
-PIPES = [
-	["DN8", 13.5],
-	["DN10", 17.2],
-	["DN15", 21.3],
-	["DN20", 26.9],
-	["DN25", 33.7],
-	["DN32", 42.4],
-	["DN40", 48.3],
-	["DN50", 60.3],
-	["DN65", 76.1],
-	["DN80", 88.9],
-	["DN100", 114.3],
-	["DN125", 139.7],
-	["DN150", 168.3],
-]
+SCADSCRIPT = "// Color support only in compile mode (F5)\ninclude <cylindertransport.scad>\n"
 
 def offset(r1, r2):
-	o = (2*sqrt(r1*r2))
-	#print "offset %i" % o
-	return o
+	return (2*sqrt(r1*r2))
 
-def calc_min(r1, r2):
+def calc_min(r1, r2, space_min):
 	# stupider annaehreungsversuch, bis sich die beiden Tauchflaschen r1 und r2 nicht mehr beruehren
-	#print "r1=%.0f r2=%.0f" % (r1, r2)
 	for p in PIPES:
 		i = p[1] / 2
 		if i>r1 or i>r2:
@@ -53,7 +19,7 @@
 		x1 = offset(r1, i)
 		x2 = offset(r2, i)
 		x = (x1 + x2) - (r1+r2) 
-		if x >= SPACE_MIN:
+		if x >= space_min:
 			print "%s Pipe (%.1fmm), Cylinder spacing: %imm" % (p[0], p[1], x)
 			return [r1, i, r2, p[0]]
 	return None
@@ -69,7 +35,6 @@
 def draw_bottles(draw, args):
 	global SCADSCRIPT
 	bottles = args.cylinders
-	SPACE_MIN = args.space_min
 
 	spacerY1 = 200
 	spacerY2 = 220
@@ -77,7 +42,7 @@
 	r1 = CYLINDER[bottles[0]][0] / 2
 	r2 = CYLINDER[bottles[1]][0] / 2
 	x = 20 + r1 # start offset x
-	r1, r2, r3, dn  = calc_min(r1, r2)
+	r1, r2, r3, dn  = calc_min(r1, r2, args.space_min)
 	circ(draw, x, r2, dn, 0.5)
 	SCADSCRIPT = SCADSCRIPT + "spacer(%i, %i, %i, %i);\n" % (
 		x, r2, r3, CYLINDER[bottles[0]][1])
@@ -86,7 +51,7 @@
 	for i in range(0, len(bottles)-1):
 		r1 = CYLINDER[bottles[i]][0] / 2
 		r2 = CYLINDER[bottles[i+1]][0] / 2
-		r1, r2, r3, dn  = calc_min(r1, r2)
+		r1, r2, r3, dn  = calc_min(r1, r2, args.space_min)
 		# draw bottle
 		circ(draw, x, r1, "Tank "+bottles[i])
 		SCADSCRIPT = SCADSCRIPT + "tank(%i, %i, %i);\n" % (
@@ -130,7 +95,7 @@
 	parser.add_argument('cylinders', metavar='cylinder', type=str, nargs='+',
                     help='cylinder types')
 	parser.add_argument('--space', dest='space_min', type=int,
-                    default=SPACE_MIN,
+                    default=10,
                     help='minimum space between cylinders (mm)')
 
 	args = parser.parse_args()
--- a/cylindertransport.scad	Mon Apr 03 01:32:02 2017 +0200
+++ b/cylindertransport.scad	Mon Apr 03 02:14:43 2017 +0200
@@ -3,7 +3,7 @@
 */
 module tank(x, r, h) {
 	cap = r;
-
+	color("SteelBlue") render() rotate([90,0,0]) {
 	translate([x, r, cap]) {
 		sphere(r = r); // bottom
 		cylinder(h = h-2*cap, r = r);
@@ -12,11 +12,13 @@
 		sphere(r = r); // top
 		cylinder(h = 30+cap, r = 25);
 	}
+	}
 }
 
 module spacer(x, r, rcylinder, h) {
 	cap = rcylinder;
 
+	color("DarkGrey") render() rotate([90,0,0])
 	translate([x, r, cap]) {
 		difference() {
 			cylinder(h = h-2*cap, r = r);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data.py	Mon Apr 03 02:14:43 2017 +0200
@@ -0,0 +1,28 @@
+# Durchmesser, Laenge, Volumen und Gewicht der verfuegbaren Tauchflaschen
+CYLINDER = {
+	"03"	: [100, 515, 3,  4.7],
+	"05"	: [140, 466, 5,	 5.7],
+	"07"	: [140, 605, 7,  8.8],
+	"08"	: [171, 490, 8,  10.4],
+	"10"	: [171, 595, 10, 12.4],
+	"12S"	: [204, 550, 12, 15.4],
+	"12L"	: [171, 690, 12, 14.5],
+	"15"	: [204, 640, 15, 18.1],
+}
+
+# Standard Rohrdurchmesser (Mr. Baumarkt)
+PIPES = [
+	["DN8", 13.5],
+	["DN10", 17.2],
+	["DN15", 21.3],
+	["DN20", 26.9],
+	["DN25", 33.7],
+	["DN32", 42.4],
+	["DN40", 48.3],
+	["DN50", 60.3],
+	["DN65", 76.1],
+	["DN80", 88.9],
+	["DN100", 114.3],
+	["DN125", 139.7],
+	["DN150", 168.3],
+]
\ No newline at end of file

mercurial