cylindertransport.py

changeset 1
14a420653a5f
parent 0
007bbb709982
child 2
9ec8fa3d0348
--- a/cylindertransport.py	Sun Apr 02 23:59:00 2017 +0200
+++ b/cylindertransport.py	Mon Apr 03 01:32:02 2017 +0200
@@ -7,6 +7,8 @@
 
 SPACE_MIN = 10 # minimum offset between bottles
 
+SCADSCRIPT = "include <cylindertransport.scad>\n"
+
 # Durchmesser, Laenge, Volumen und Gewicht der verfuegbaren Tauchflaschen
 CYLINDER = {
 	"03"	: [100, 515, 3,  4.7],
@@ -35,8 +37,6 @@
 	["DN150", 168.3],
 ]
 
-
-
 def offset(r1, r2):
 	o = (2*sqrt(r1*r2))
 	#print "offset %i" % o
@@ -67,6 +67,7 @@
 
 
 def draw_bottles(draw, args):
+	global SCADSCRIPT
 	bottles = args.cylinders
 	SPACE_MIN = args.space_min
 
@@ -78,6 +79,8 @@
 	x = 20 + r1 # start offset x
 	r1, r2, r3, dn  = calc_min(r1, r2)
 	circ(draw, x, r2, dn, 0.5)
+	SCADSCRIPT = SCADSCRIPT + "spacer(%i, %i, %i, %i);\n" % (
+		x, r2, r3, CYLINDER[bottles[0]][1])
 	x = x + offset(r2, r3)
 
 	for i in range(0, len(bottles)-1):
@@ -86,15 +89,21 @@
 		r1, r2, r3, dn  = calc_min(r1, r2)
 		# draw bottle
 		circ(draw, x, r1, "Tank "+bottles[i])
+		SCADSCRIPT = SCADSCRIPT + "tank(%i, %i, %i);\n" % (
+			x, r1, CYLINDER[bottles[i]][1])
 		sx1 = x+r1
 		x = x + offset(r1, r2)
 		# draw right spacer
 		circ(draw, x, r2, dn, 0.5)
+		SCADSCRIPT = SCADSCRIPT + "spacer(%i, %i, %i, %i);\n" % (
+			x, r2, r1, CYLINDER[bottles[i]][1])
 		x = x + offset(r2, r3)
 		sx2 = x-r3
 		if i == (len(bottles)-2):
 			# draw last bottle
 			circ(draw, x, r3, "Tank "+bottles[i+1])
+			SCADSCRIPT = SCADSCRIPT + "tank(%i, %i, %i);\n" % (
+				x, r3, CYLINDER[bottles[i+1]][1])
 			x = x + offset(r2, r3)
 		# draw the space between bottles
 		draw.line((sx1, spacerY1, sx1, spacerY2), fill='#ffffff')
@@ -106,6 +115,8 @@
 
 	# last bottle spacer
 	circ(draw, x, r2, dn, 0.5)
+	SCADSCRIPT = SCADSCRIPT + "spacer(%i, %i, %i, %i);\n" % (
+		x, r2, r3, CYLINDER[bottles[i+1]][1])
 
 def getimage(args):
 	image = Image.new('1', (1000, 250)) #create new image, 1000x500 pixels, 1 bit per pixel
@@ -130,4 +141,7 @@
 			sys.exit(1)
 
 	image = getimage(args)
-	image.show()
\ No newline at end of file
+	image.show()
+
+	print "\n------------ START SCAD SCRIPT ------------"
+	print SCADSCRIPT + "------------ END SCAD SCRIPT ------------"

mercurial