forked from waynegramlich/ezcad3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_block.py
executable file
·72 lines (53 loc) · 1.47 KB
/
test_block.py
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
#!/usr/bin/env python
from EZCAD3 import *
class Block(Part):
def __init__(self, up, name):
""" *Block*: Initialize *Base* object (i.e. *self*) with a
parent of *up*.
"""
# Verify argument types:
assert isinstance(up, Part) or up == None
assert isinstance(name, str)
# Initialize the superclass:
Part.__init__(self, up, name)
def construct(self):
""" *Block*: Construct the *Plate* object (i.e. *self*). """
# Use *block* instead of *self*:
block = self
# Some constants:
zero = L()
# Specify *dx*, *dy*, and *dz*:
block.dx_l = dx = L(inch=4.0)
block.dy_l = dy = L(inch=4.0)
block.dz_l = dz = L(inch="1/2")
block.color_c = color = Color("blue")
block.material_m = material = Material("aluminum", "")
# Define the extra material to be add to the next block operation:
extra = L(inch="1/8")
block.extra_xyz(extra, extra, zero)
# Compute the *block* boundaries:
x1 = -dx
x2 = x1 + dx/4
x4 = zero
x3 = x4 - dx/4
y1 = -dy
y2 = y1 + dy/4
y4 = zero
y3 = y4 - dy/4
z1 = -dz
z2 = zero
z3 = dz
# Do the bottom block:
corner1 = P(x1, y1, z1)
corner2 = P(x4, y4, z2)
block.block("bottom block", material, color, corner1, corner2, "t", "t")
# Weld n the top block:
corner1 = P(x2, y2, z2)
corner2 = P(x3, y3, z3)
block.block("block", material, color, corner1, corner2, "t", "b")
def test_block():
ezcad = EZCAD3(0, directory="/tmp")
block = Block(None, "block")
block.process(ezcad)
if __name__== "__main__":
test_block()