-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboxplate
More file actions
77 lines (65 loc) · 2.1 KB
/
boxplate
File metadata and controls
77 lines (65 loc) · 2.1 KB
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
def plate(width as Number height as Number x as Number y as Number radius as Number isFront as Number) = {
#BOUNDARY
line(x y x y + height)
line(x y x + width y)
line(x + width y x + width y + height)
if(isFront < 1){ #this line is not on front plates
line(x y + height x + width y + height)
}
#ALTERNATIVE FRONT PLATE TOP
if(isFront > 0){ #this line is not on front plates
def factor = width / 4
line(x y + height x + factor y + height)
line(x + width - factor y + height x + width y + height)
arc(x + (width / 2) y + height factor 0 3.14)
}
#BOTTOM AND TOP HOLES
def bottomTopHoles(offset as Number) = {
def yMargin as Number = 10
def yTop as Number = y - yMargin
#LEFT SIDE HOLES
if(isFront < 1){ #this hole is not on front plates
circle(x + offset yTop + height radius)
}
circle(x + offset y + yMargin radius)
#RIGHT SIDE HOLES
def rightSide = x + width
if(isFront < 1){#this hole is not on front plates
circle(rightSide - offset yTop + height radius)
}
circle(rightSide - offset y + yMargin radius)
# CENTER HOLES
if (width > 200) {
def center = width / 2
if(isFront < 1){#this hole is not on front plates
circle(center + x yTop + height radius)
}
circle(center + x y + yMargin radius)
}
}
#LEFT AND RIGHT HOLES
def sideHoles(offset as Number) = {
def xMargin as Number = 10
def xTop as Number = x - xMargin
#BOTTOM END HOLES
circle(xTop + width y + offset radius)
circle(x + xMargin y + offset radius)
#TOP END HOLES
def topEnd = y + height
circle(xTop + width topEnd - offset radius)
circle(x + xMargin topEnd - offset radius)
# CENTER HOLES
if (height > 180) {
def center = height / 2
circle(xTop + width center + y radius)
circle(x + xMargin center + y radius)
}
}
# CALL THE TWO FUNCTIONS ABOVE TO DRAW HOLES:
bottomTopHoles(30)
sideHoles(30)
}
#TEST
#call the function plate
#the last parameter determines if it is a front plate (1) or not (0)
plate(180 140 10 30 3 1)