-
Notifications
You must be signed in to change notification settings - Fork 0
/
flange-xy.kcl
85 lines (77 loc) · 2.4 KB
/
flange-xy.kcl
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
// Flange with XY coordinates
// A flange is a flat rim, collar, or rib, typically forged or cast, that is used to strengthen an object, guide it, or attach it to another object. Flanges are known for their use in various applications, including piping, plumbing, and mechanical engineering, among others.
// Define constants in inches (in)
mountingHoleDia = .625
baseDia = 4.625
pipeDia = 1.25
thickness = .625
totalThickness = 0.813
topTotalDiameter = 2.313
bottomThickness = 0.06
bottomTotalDiameter = 2.5
mountingHolePlacementDiameter = 3.5
baseThickness = .625
topTotalThickness = totalThickness - (bottomThickness + baseThickness)
holeLocator = baseDia - 8
nHoles = 4
// Add assertion so nHoles are always greater than 1
assertGreaterThan(nHoles, 1, "nHoles must be greater than 1")
// Create the flange base and the six mounting holes
flangeBase = startSketchOn('XY')
|> circle({
center = [0, 0],
radius = baseDia / 2
}, %)
|> hole(circle({
center = [mountingHolePlacementDiameter / 2, 0],
radius = mountingHoleDia / 2
}, %), %)
|> hole(circle({
center = [0, mountingHolePlacementDiameter / 2],
radius = mountingHoleDia / 2
}, %), %)
|> hole(circle({
center = [-mountingHolePlacementDiameter / 2, 0],
radius = mountingHoleDia / 2
}, %), %)
|> hole(circle({
center = [0, -mountingHolePlacementDiameter / 2],
radius = mountingHoleDia / 2
}, %), %)
|> hole(circle({
center = [0, 0],
radius = pipeDia / 2
}, %), %)
|> extrude(baseThickness, %)
// Plane for top face
topFacePlane = {
plane = {
origin = { x = 0, y = 0, z = baseThickness },
xAxis = { x = 1, y = 0, z = 0 },
yAxis = { x = 0, y = 1, z = 0 },
zAxis = { x = 0, y = 0, z = 1 }
}
}
// Create the extrusion on the top of the flange base
topExtrusion = startSketchOn(topFacePlane, 'end')
|> circle({
center = [0, 0],
radius = topTotalDiameter / 2
}, %)
|> hole(circle({
center = [0, 0],
radius = pipeDia / 2
}, %), %)
|> extrude(topTotalThickness, %)
// Create the extrusion on the bottom of the flange base
bottomExtrusion = startSketchOn("XY")
|> circle({
center = [0, 0],
radius = bottomTotalDiameter / 2
}, %)
|> hole(circle({
center = [0, 0],
radius = pipeDia / 2
}, %), %)
|> extrude(-bottomThickness, %)
// https://www.mcmaster.com/44685K193/