summaryrefslogtreecommitdiff
path: root/src/hal/user_comps/vismach/maho600gui.py
blob: 2ad78fcdf13dbfb1b743a432c7e7605387499bec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!/usr/bin/python2.4
#
#    Visulization model of U of Akron's Maho 600C with 2-axis NC table
#
#    Copyright 2007 John Kasunich
#    Derived from a work by John Kasunich, Jeff Epler, and Chris Radek
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


from vismach import *
import hal
import math
import sys

# give endpoint Z values and radii
# resulting cylinder is on the Z axis
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")
# table
c.newpin("table", hal.HAL_FLOAT, hal.HAL_IN)
# full width ways that table rides one
# this assembly moves up and down for Y
c.newpin("tableway", hal.HAL_FLOAT, hal.HAL_IN)
# head vertical slide
c.newpin("head", hal.HAL_FLOAT, hal.HAL_IN)
# head tilt
c.newpin("arotate", hal.HAL_FLOAT, hal.HAL_IN)
# rotary table
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,
	# spindle housing
	CylinderZ( -9, 2.5, -10, 2.5),
	# spindle nose and/or toolholder
	CylinderZ( -3, 1.75, -9, 2.0),
	])

spindle = Color([1,0,1,0], [spindle] )


head = Collection([
	spindle,
	# main block, holds 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,
	# this is the round part on which the angle plate and 2nd rotary
	# are mounted
	CylinderX(-12, 6, -10, 6),
	# center marker
	CylinderX(-10, 0.5, 0, 0.01),
	# can't see a cylinder turn, so stick a lump on one side
	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,
	# this is what holds the A axis rotary table
	# horizontal plate
	Box( -18, -12, -9, 0, -10, 9),
	CylinderY (-12, 9, -10, 9),
	# vertical plate
	Box( -18, -10, -9, -12, 7, 9)
        ])

brotary = Collection([
	angleplate,
	# this is the round part on which the angle plate and 2nd rotary
	# are mounted
	CylinderY(-13, 9, -12, 9),
	# center marker
	CylinderY(-12, 0.5, 0, 0.01),
	# can't see a cylinder turn, so stick a lump on one side
	Box( -0.5, -13, 10, 0.5, -12, 9)
        ])

# HalRotate([thing-to-rotate],c,"hal-pin", scalefactor, axis-vector-x,y,z)
brotary = HalRotate([brotary],c,"brotate",1,0,1,0)
brotary = Color([1,0,1,0], [brotary] )

brotary = Collection([
	brotary,
	# this is the non-rotating part that sits on the main table
	# modeled as a simple, 18 x 18 x 2" box
	Box(-9, -15, -9, 9, -13, 9),
        ])

# main table - for three axis, put work here instead of rotary
table = Collection([
	brotary,
	# body of table
	# 26" wide, 19 deep, 18 hi
	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,
	# 82" wide, 1/2" thick, 18" hi
	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,
	# main base
	# 84" wide, 30" deep, 38" tall
	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)