from vismach import *
import hal
import math
import sys
class HalToolCylinder(CylinderZ):
def __init__(self, comp, *args):
CylinderZ.__init__(self, *args)
self.comp = comp
def coords(self):
return (0, self.comp["tool-radius"], self.comp["tool-length"], self.comp["tool-radius"])
c = hal.component("mahogui")
c.newpin("table", hal.HAL_FLOAT, hal.HAL_IN)
c.newpin("tableway", hal.HAL_FLOAT, hal.HAL_IN)
c.newpin("head", hal.HAL_FLOAT, hal.HAL_IN)
c.newpin("arotate", hal.HAL_FLOAT, hal.HAL_IN)
c.newpin("brotate", hal.HAL_FLOAT, hal.HAL_IN)
c.newpin("tool-length", hal.HAL_FLOAT, hal.HAL_IN)
c.newpin("tool-radius", hal.HAL_FLOAT, hal.HAL_IN)
c.ready()
pivot_len=100
tool_radius=0.25
for setting in sys.argv[1:]: exec setting
tooltip = Capture()
tool = Collection([
HalTranslate([tooltip], c, "tool-length", 0, 0, 1),
HalToolCylinder(c),
])
tool = Translate([tool], 0, 0, -3)
tool = Color([1,0,0,0], [tool] )
spindle = Collection([
tool,
CylinderZ( -9, 2.5, -10, 2.5),
CylinderZ( -3, 1.75, -9, 2.0),
])
spindle = Color([1,0,1,0], [spindle] )
head = Collection([
spindle,
Box( -6, -10, -10, 6, 6, -50 ),
])
head = HalTranslate([head],c,"head",0,0,1)
head = Color([0,1,0,0], [head] )
work = Capture()
arotary = Collection([
work,
CylinderX(-12, 6, -10, 6),
CylinderX(-10, 0.5, 0, 0.01),
Box( -12, -0.5, 6, -10, 0.5, 7)
])
arotary = HalRotate([arotary],c,"arotate",1,1,0,0)
arotary = Color([0,1,0,0], [arotary] )
angleplate = Collection([
arotary,
Box( -18, -12, -9, 0, -10, 9),
CylinderY (-12, 9, -10, 9),
Box( -18, -10, -9, -12, 7, 9)
])
brotary = Collection([
angleplate,
CylinderY(-13, 9, -12, 9),
CylinderY(-12, 0.5, 0, 0.01),
Box( -0.5, -13, 10, 0.5, -12, 9)
])
brotary = HalRotate([brotary],c,"brotate",1,0,1,0)
brotary = Color([1,0,1,0], [brotary] )
brotary = Collection([
brotary,
Box(-9, -15, -9, 9, -13, 9),
])
table = Collection([
brotary,
Box(-13, -33, 10, 13, -15, -9.5),
])
table = HalTranslate([table],c,"table",-1,0,0)
table = Color([0,1,1,0], [table] )
tableway = Collection([
table,
Box(-41, -33, -9.5, 41, -15, -10),
])
tableway = HalTranslate([tableway],c,"tableway",0,-1,0)
tableway = Color([1,1,0,0], [tableway] )
base = Collection([
tableway,
Box(-42, -48, -10, 42, -10, -30),
])
base = Color([0,0,1,0], [base] )
model = Collection([head, base])
model = Rotate([model],90,1,0,0)
main(model, tooltip, work, 100)