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 (45, self.comp["tool-radius"], -self.comp["tool-length"], self.comp["tool-radius"])
c = hal.component("max5gui")
c.newpin("table", hal.HAL_FLOAT, hal.HAL_IN)
c.newpin("saddle", hal.HAL_FLOAT, hal.HAL_IN)
c.newpin("head", hal.HAL_FLOAT, hal.HAL_IN)
c.newpin("tilt", hal.HAL_FLOAT, hal.HAL_IN)
c.newpin("rotate", 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=5
for setting in sys.argv[1:]: exec setting
tooltip = Capture()
tool = Collection([
HalTranslate([tooltip], c, "tool-length", 0, 0, -1),
HalToolCylinder(c),
])
tool = Color([1,0,0,0], [tool] )
spindle = Collection([
tool,
CylinderZ( 55, 20, 140, 20),
CylinderZ( 45, 12, 55, 15),
])
spindle = Translate([spindle], 0, 40, 0)
head = Collection([
spindle,
Box( -25, 10, 60, 25, 125, 135 ),
Box( -45, 125, 60, 45, 160, 135 ),
Box( -50, 160, 0, 50, 170, 135 )
])
brotary = Collection([
head,
CylinderY(161, 50, 185, 50),
])
brotary = HalRotate([brotary],c,"tilt",1,0,-1,0)
brotary = Color([0,1,0,0], [brotary] )
brotary = Collection([
brotary,
Box(-53, 185, -53, 53, 230, 53),
Box(-73, 170, -53, -53, 230, 85),
Box( -68, 177, 85, -22, 223, 145)
])
zslide = Collection([
brotary,
Box(-53, 230, -53, 53, 256, 53),
])
zslide = Translate([zslide], 0, 0,200)
zslide = HalTranslate([zslide],c,"head",0,0,1)
zslide = Color([1,1,0,0], [zslide] )
column = Collection([
zslide,
Box(-50, 256, 15, 50, 275, 315),
Box(-40, 250, 15, 40, 256, 315),
Box(-23, 227, 315, 23, 273, 375)
])
column = Color([0,0,1,0], [column] )
work = Capture()
crotary = Collection([
work,
CylinderZ(130, 50, 150, 50),
Box( 40,-5, 131, 54, 5, 149)
])
crotary = HalRotate([crotary],c,"rotate",1,0,0,-1)
crotary = Color([1,0,1,0], [crotary] )
crotary = Collection([
crotary,
Box(-53,-53, 100, 53, 53, 130),
Box( 53,-85, 100, 73, 53, 148),
Box( 22,-85, 102, 68, -145, 146)
])
table = Collection([
crotary,
Box(-150,-50, 81, 150, 50, 100),
Box(-150,-40, 75, 150, 40, 81),
Box(150, -23, 52, 210, 23, 98)
])
table = HalTranslate([table],c,"table",-1,0,0)
table = Color([0,1,1,0], [table] )
saddle = Collection([
table,
Box(-53,-53, 44, 53, 53, 81),
])
saddle = HalTranslate([saddle],c,"saddle",0,-1,0)
saddle = Color([1,1,0,0], [saddle] )
base = Collection([
saddle,
Box(-50, -150, 25, 50, 150, 44),
Box(-40,-150, 44, 40, 150, 50),
Box(-70, -150, 0, 70, -135, 25),
Box(-23, -150, 27, 23, -210, 73),
Box(-50, 125, 0, 50, 300, 25),
Box(-50, 275, 25, 50, 300, 50),
])
base = Color([0,0,1,0], [base] )
model = Collection([column, base])
main(model, tooltip, work, 500)