Repository navigation
Expand file tree
/
Copy pathfastener-data.js
More file actions
103 lines (92 loc) · 2.8 KB
/
Copy pathfastener-data.js
File metadata and controls
103 lines (92 loc) · 2.8 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
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
function round(value, decimals = 3) {
return Number(value.toFixed(decimals));
}
function createFastenerSize(diameter, pitch, threadPerInch) {
const clearance = diameter < 6 ? 0.3 : 0.4;
const panHeadDiameter = diameter * 2 + 0.6;
const socketCapDiameter = diameter * 1.8 + 0.4;
const flatHeadDiameter = diameter * 2.1 + 1;
const hexHeadDiameter = diameter * 1.75;
const data = {
diameter: round(diameter),
coarsePitch: round(pitch),
heads: {
pan: { headDiameter: round(panHeadDiameter), headHeight: round(diameter * 0.75 + 0.2) },
socketCap: { headDiameter: round(socketCapDiameter), headHeight: round(diameter * 1 + 0.4) },
flat: { headDiameter: round(flatHeadDiameter), headHeight: round(Math.max(1, diameter * 0.55)) },
hex: { headDiameter: round(hexHeadDiameter), headHeight: round(diameter * 0.8 + 0.2) }
},
nut: {
widthAcrossFlats: round(diameter * 1.7),
thickness: round(Math.max(1.2, diameter * 0.8))
},
washer: {
innerDiameter: round(diameter + clearance),
outerDiameter: round(Math.max(diameter * 2.2, diameter + 4)),
thickness: round(Math.max(0.5, Math.min(2.5, diameter * 0.25)))
}
};
if (threadPerInch) {
data.threadPerInch = threadPerInch;
}
return data;
}
const metricThreadSeries = [
['M2', 2, 0.4],
['M2.5', 2.5, 0.45],
['M3', 3, 0.5],
['M4', 4, 0.7],
['M5', 5, 0.8],
['M6', 6, 1.0],
['M8', 8, 1.25],
['M3x0.5', 3, 0.5],
['M4x0.7', 4, 0.7],
['M5x0.8', 5, 0.8],
['M6x1.0', 6, 1.0],
['M7x1.0', 7, 1.0],
['M8x1.0', 8, 1.0],
['M8x1.25', 8, 1.25],
['M10x1.0', 10, 1.0],
['M10x1.25', 10, 1.25],
['M10x1.5', 10, 1.5],
['M12x1.25', 12, 1.25],
['M12x1.5', 12, 1.5],
['M12x1.75', 12, 1.75]
];
export const metricFastenerData = Object.fromEntries(
metricThreadSeries.map(([size, diameter, pitch]) => [size, createFastenerSize(diameter, pitch)])
);
const saeThreadSeries = [
['6-40', 3.505, 40],
['6-32', 3.505, 32],
['8-32', 4.166, 32],
['10-24', 4.826, 24],
['10-32', 4.826, 32],
['1/4-20', 6.35, 20],
['1/4-28', 6.35, 28],
['5/16-18', 7.938, 18],
['5/16-24', 7.938, 24],
['3/8-16', 9.525, 16],
['3/8-24', 9.525, 24],
['7/16-14', 11.112, 14],
['7/16-20', 11.112, 20],
['1/2-13', 12.7, 13],
['1/2-20', 12.7, 20]
];
export const saeFastenerData = Object.fromEntries(
saeThreadSeries.map(([size, diameter, tpi]) => [size, createFastenerSize(diameter, 25.4 / tpi, tpi)])
);
export const fastenerDataByStandard = {
metric: metricFastenerData,
sae: saeFastenerData
};
export function getFastenerData(standard = 'metric') {
return fastenerDataByStandard[standard] || metricFastenerData;
}
export function getDefaultSizeForStandard(standard = 'metric') {
const defaults = {
metric: 'M6x1.0',
sae: '1/4-20'
};
return defaults[standard] || 'M6x1.0';
}