aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Hanspeter Portner <dev@open-music-kontrollers.ch>2014-07-15 20:59:43 +0200
committerGravatar Hanspeter Portner <dev@open-music-kontrollers.ch>2014-07-15 20:59:43 +0200
commit5ebe242ed769f14d4c82d54209839660e59c4dda (patch)
treee909aef2ecbf83c322c5dd2e186048e22fddd4f8
parent5addfc80130e3cd66cbe7721bcd73ad3e69aa524 (diff)
downloadchimaera_mplek-5ebe242ed769f14d4c82d54209839660e59c4dda.zip
chimaera_mplek-5ebe242ed769f14d4c82d54209839660e59c4dda.tar.gz
chimaera_mplek-5ebe242ed769f14d4c82d54209839660e59c4dda.tar.bz2
chimaera_mplek-5ebe242ed769f14d4c82d54209839660e59c4dda.tar.xz
update mstamp
-rw-r--r--mstamp.py60
1 files changed, 37 insertions, 23 deletions
diff --git a/mstamp.py b/mstamp.py
index 871e57c..5409f25 100644
--- a/mstamp.py
+++ b/mstamp.py
@@ -12,11 +12,11 @@ import sys
import bpy
from math import pi, sin, cos
-prec = 1.01
+add = 0.05
-W = 4 # width of bar magnet
-H = 3 # height of bar magnet
-L = 20 # length of bar magnet
+W = add+4 # width of bar magnet
+H = add+3 # height of bar magnet
+L = add+20 # length of bar magnet
R0 = 3
L0 = 50
@@ -32,6 +32,7 @@ bpy.ops.object.delete()
bpy.ops.mesh.primitive_uv_sphere_add(size=R1, location=(0, 0, L0))
knob = bpy.context.active_object
knob.name = "knob"
+bpy.ops.transform.resize(value=(0.5, 1, 1))
# create pistill
bpy.ops.mesh.primitive_cylinder_add(vertices=64, radius=R0, depth=L0, location=(0, 0, L0/2))
@@ -39,16 +40,22 @@ pistill = bpy.context.active_object
pistill.name = "pistill"
# create stamp
-bpy.ops.mesh.primitive_cylinder_add(vertices=64, radius=1, depth=1, location=(0, 0, 0))
+bpy.ops.mesh.primitive_uv_sphere_add(size=1, location=(0, 0, -H/2))
stamp = bpy.context.active_object
stamp.name = "stamp"
-bpy.ops.transform.resize(value=(W * 1.2, L/2, H*2))
+bpy.ops.transform.resize(value=(W*1.2, L/2, H*2))
# create bar magnet
bpy.ops.mesh.primitive_cube_add(location=(0, 0, 0))
bar = bpy.context.active_object
bar.name = "bar"
-bpy.ops.transform.resize(value=(W/2*prec, L/2*prec, H/2*prec))
+bpy.ops.transform.resize(value=(W/2, L/2, H/2))
+
+# create base
+bpy.ops.mesh.primitive_cube_add(location=(0, 0, -H*2))
+base = bpy.context.active_object
+base.name = "base"
+bpy.ops.transform.resize(value=(W*2, L*2, H))
scn = bpy.context.scene
scn.objects.active = knob
@@ -56,20 +63,10 @@ knob.select = True
# merge knob with pistill
bpy.ops.object.modifier_add(type="BOOLEAN")
-sub_knob = knob.modifiers["Boolean"]
-sub_knob.name = "sub_knob"
-sub_knob.operation = "UNION"
-sub_knob.object = pistill
-
-# add simple smooth modifier
-#bpy.ops.object.modifier_add(type="SMOOTH")
-#simple = knob.modifiers["Smooth"]
-#simple.name = "smooth"
-#simple.factor = 1
-#simple.iterations = 10
-#simple.use_x = False
-#simple.use_y = False
-#simple.use_z = True
+sub_knob1 = knob.modifiers["Boolean"]
+sub_knob1.name = "sub_knob1"
+sub_knob1.operation = "UNION"
+sub_knob1.object = pistill
# merge knob with stamp
bpy.ops.object.modifier_add(type="BOOLEAN")
@@ -79,14 +76,31 @@ sub_knob2.operation = "UNION"
sub_knob2.object = stamp
# subtract bar from stamp
-#scn.objects.active = stamp
-#stamp.select = True
bpy.ops.object.modifier_add(type="BOOLEAN")
sub_knob3 = knob.modifiers["Boolean"]
sub_knob3.name = "sub_knob3"
sub_knob3.operation = "DIFFERENCE"
sub_knob3.object = bar
+# subtract bar from stamp
+bpy.ops.object.modifier_add(type="BOOLEAN")
+sub_knob4 = knob.modifiers["Boolean"]
+sub_knob4.name = "sub_knob4"
+sub_knob4.operation = "DIFFERENCE"
+sub_knob4.object = base
+
+# apply modifiers
+bpy.ops.object.modifier_apply(modifier="sub_knob1")
+bpy.ops.object.modifier_apply(modifier="sub_knob2")
+bpy.ops.object.modifier_apply(modifier="sub_knob3")
+bpy.ops.object.modifier_apply(modifier="sub_knob4")
+
+# unlink unneeded objects
+scn.objects.unlink(pistill)
+scn.objects.unlink(stamp)
+scn.objects.unlink(bar)
+scn.objects.unlink(base)
+
# export to STL
bpy.ops.export_mesh.stl(filepath=sys.argv[4], check_existing=False, ascii=True, use_mesh_modifiers=True)
bpy.ops.wm.quit_blender()