Skip to content

Commit 5150ad6

Browse files
committed
Merge branch 'dev'
2 parents 1345adb + 3a26d1d commit 5150ad6

13 files changed

+67
-67
lines changed

Package.resolved

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ let package = Package(
1010
.executable(name: "Helical-Demo", targets: ["Demo"]),
1111
],
1212
dependencies: [
13-
.package(url: "https://github.com/tomasf/Cadova.git", .upToNextMinor(from: "0.1.1")),
13+
.package(url: "https://github.com/tomasf/Cadova.git", .upToNextMinor(from: "0.1.2")),
1414
],
1515
targets: [
1616
.target(

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import Helical
2727
Helical simplifies the process of creating threaded shapes, making it easier to incorporate threaded holes into your models. It also provides a selection of standard bolts, nuts, and corresponding holes. Creating a typical M8x30 hex head bolt is simple:
2828

2929
```swift
30-
Bolt.hexHead(.m8, length: 20, shankLength: 5)
30+
Bolt.hexHead(.m8, length: 20, unthreadedLength: 5)
3131
```
3232

3333
This generates a standard [DIN 931](https://www.fasteners.eu/standards/DIN/931/) bolt, as expected.
@@ -63,8 +63,8 @@ let thread = ScrewThread(
6363
let customBolt = Bolt(
6464
thread: thread,
6565
length: 15,
66-
shankLength: 3,
67-
shankDiameter: 5,
66+
unthreadedLength: 3,
67+
unthreadedDiameter: 5,
6868
headShape: .countersunk(angle: 80°, topDiameter: 10, boltDiameter: 5),
6969
socket: .slotted(length: 10, width: 1, depth: 1.4)
7070
)

Sources/Demo/main.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ let customThread = ScrewThread.square(majorDiameter: 8, pitch: 2, starts: 2)
88
let customBolt = Bolt(
99
thread: customThread,
1010
length: boltLength,
11-
shankLength: 0,
11+
unthreadedLength: 0,
1212
leadinChamferSize: 1.0,
1313
headShape: PolygonalBoltHeadShape(sideCount: 8, widthAcrossFlats: 12, height: 3, chamferAngle: 40°),
1414
socket: PolygonalBoltHeadSocket(sides: 4, acrossWidth: 5, depth: 2)
1515
)
1616

1717
let bolts = [
1818
("Hex head, M8", Bolt.hexHead(.m8, length: boltLength)),
19-
("Hex socket head cap, M6", Bolt.hexSocketHeadCap(.m6, length: boltLength, shankLength: 10)),
19+
("Hex socket head cap, M6", Bolt.hexSocketHeadCap(.m6, length: boltLength, unthreadedLength: 10)),
2020
("Phillips cheese head, M5", Bolt.phillipsCheeseHead(.m5, length: boltLength)),
2121
("Hex socket countersunk, M5", Bolt.hexSocketCountersunk(.m5, length: boltLength)),
2222
("Phillips countersunk, M5", Bolt.phillipsCountersunk(.m8, length: boltLength)),
23-
("Phillips raised countersunk, M4", Bolt.phillipsCountersunk(.m4, raised: true, length: boltLength, shankLength: 7)),
23+
("Phillips raised countersunk, M4", Bolt.phillipsCountersunk(.m4, raised: true, length: boltLength, unthreadedLength: 7)),
2424
("Slotted countersunk, M5", Bolt.slottedCountersunk(.m5, length: boltLength)),
2525
("Raised slotted countersunk, M3", Bolt.slottedCountersunk(.m3, raised: true, length: boltLength)),
2626
("Hex socket set screw, dog point, M6", Bolt.setScrew(.m6, socket: .hexSocket, point: .dog, length: boltLength)),

Sources/Helical/Bolt/Bolt.swift

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@ import Cadova
44
public struct Bolt: Shape3D {
55
public let thread: ScrewThread
66
public let length: Double
7-
public let shankLength: Double
8-
public let shankDiameter: Double
7+
public let unthreadedLength: Double
8+
public let unthreadedDiameter: Double
99
public let headShape: any BoltHeadShape
1010
public let socket: (any BoltHeadSocket)?
1111
public let point: (any BoltPoint)?
1212

1313
public init(
1414
thread: ScrewThread,
1515
length: Double,
16-
shankLength: Double,
17-
shankDiameter: Double? = nil,
16+
unthreadedLength: Double,
17+
unthreadedDiameter: Double? = nil,
1818
headShape: any BoltHeadShape,
1919
socket: (any BoltHeadSocket)? = nil,
2020
point: (any BoltPoint)? = nil
2121
) {
2222
self.thread = thread
2323
self.length = length
24-
self.shankLength = shankLength
25-
self.shankDiameter = shankDiameter ?? thread.majorDiameter
24+
self.unthreadedLength = unthreadedLength
25+
self.unthreadedDiameter = unthreadedDiameter ?? thread.majorDiameter
2626
self.headShape = headShape
2727
self.socket = socket
2828
self.point = point
@@ -31,17 +31,17 @@ public struct Bolt: Shape3D {
3131
public init(
3232
thread: ScrewThread,
3333
length: Double,
34-
shankLength: Double = 0,
35-
shankDiameter: Double? = nil,
34+
unthreadedLength: Double = 0,
35+
unthreadedDiameter: Double? = nil,
3636
leadinChamferSize: Double,
3737
headShape: any BoltHeadShape,
3838
socket: (any BoltHeadSocket)? = nil
3939
) {
4040
self.init(
4141
thread: thread,
4242
length: length,
43-
shankLength: shankLength,
44-
shankDiameter: shankDiameter,
43+
unthreadedLength: unthreadedLength,
44+
unthreadedDiameter: unthreadedDiameter,
4545
headShape: headShape,
4646
socket: socket,
4747
point: ProfiledBoltPoint(chamferSize: leadinChamferSize)
@@ -59,8 +59,8 @@ public struct Bolt: Shape3D {
5959
self.init(
6060
thread: .none(diameter: solidDiameter),
6161
length: 0,
62-
shankLength: length,
63-
shankDiameter: solidDiameter,
62+
unthreadedLength: length,
63+
unthreadedDiameter: solidDiameter,
6464
headShape: headShape,
6565
socket: socket,
6666
point: point
@@ -69,28 +69,28 @@ public struct Bolt: Shape3D {
6969

7070
public var body: any Geometry3D {
7171
let baseLevel = headShape.height - headShape.consumedLength
72-
let threadLength = length - shankLength - (point?.consumedLength ?? 0)
72+
let threadLength = length - unthreadedLength - (point?.consumedLength ?? 0)
7373

7474
@Environment(\.tolerance) var tolerance
7575

7676
headShape
7777
.adding {
78-
// Shank
79-
Cylinder(diameter: shankDiameter - tolerance, height: shankLength)
78+
// Unthreaded part
79+
Cylinder(diameter: unthreadedDiameter - tolerance, height: unthreadedLength)
8080
.translated(z: baseLevel)
8181

8282
// Threads
8383
Screw(thread: thread, length: threadLength)
84-
.translated(z: baseLevel + shankLength)
84+
.translated(z: baseLevel + unthreadedLength)
8585

8686
// Point
87-
point?.translated(z: baseLevel + shankLength + threadLength)
87+
point?.translated(z: baseLevel + unthreadedLength + threadLength)
8888
}
8989
.subtracting {
9090
headShape.negativeBody
9191
socket?.translated(z: -0.01)
9292
point?.negativeBody
93-
.translated(z: baseLevel + shankLength + threadLength)
93+
.translated(z: baseLevel + unthreadedLength + threadLength)
9494
}
9595
.withThread(thread)
9696
}

Sources/Helical/Bolt/Standards/Bolt+HexHead.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Cadova
77

88
public extension Bolt {
99
/// Standard DIN 931 configuration
10-
static func hexHead(_ size: ScrewThread.ISOMetricSize, length: Double, shankLength: Double = 0) -> Bolt {
10+
static func hexHead(_ size: ScrewThread.ISOMetricSize, length: Double, unthreadedLength: Double = 0) -> Bolt {
1111
let headHeight: Double // k
1212
let widthAcrossFlats: Double // s
1313

@@ -35,17 +35,17 @@ public extension Bolt {
3535
}
3636

3737
assert(headHeight > 0, "\(size) isn't a valid size for DIN 931 bolts")
38-
return hexHead(.isoMetric(size), headWidth: widthAcrossFlats, headHeight: headHeight, length: length, shankLength: shankLength)
38+
return hexHead(.isoMetric(size), headWidth: widthAcrossFlats, headHeight: headHeight, length: length, unthreadedLength: unthreadedLength)
3939
}
4040

4141
/// Custom configuration
42-
static func hexHead(_ thread: ScrewThread, headWidth: Double, headHeight: Double, length: Double, shankLength: Double = 0) -> Bolt {
42+
static func hexHead(_ thread: ScrewThread, headWidth: Double, headHeight: Double, length: Double, unthreadedLength: Double = 0) -> Bolt {
4343
let head = PolygonalBoltHeadShape(
4444
sideCount: 6,
4545
widthAcrossFlats: headWidth,
4646
height: headHeight,
4747
chamferAngle: 30°
4848
)
49-
return .init(thread: thread, length: length, shankLength: shankLength, headShape: head)
49+
return .init(thread: thread, length: length, unthreadedLength: unthreadedLength, headShape: head)
5050
}
5151
}

Sources/Helical/Bolt/Standards/Bolt+HexSocketCountersunk.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Cadova
77

88
public extension Bolt {
99
/// Standard ISO 10642 configuration
10-
static func hexSocketCountersunk(_ size: ScrewThread.ISOMetricSize, length: Double, shankLength: Double = 0) -> Bolt {
10+
static func hexSocketCountersunk(_ size: ScrewThread.ISOMetricSize, length: Double, unthreadedLength: Double = 0) -> Bolt {
1111
let headDiameter: Double // dk
1212
let socketWidth: Double // s, socket width across flats
1313
let socketDepth: Double // t
@@ -29,15 +29,15 @@ public extension Bolt {
2929
}
3030

3131
assert(headDiameter > 0, "\(size) isn't a valid size for ISO 10642 bolts")
32-
return hexSocketCountersunk(.isoMetric(size), headDiameter: headDiameter, socketWidth: socketWidth, socketDepth: socketDepth, length: length, shankLength: shankLength)
32+
return hexSocketCountersunk(.isoMetric(size), headDiameter: headDiameter, socketWidth: socketWidth, socketDepth: socketDepth, length: length, unthreadedLength: unthreadedLength)
3333
}
3434

3535
/// Custom configuration
36-
static func hexSocketCountersunk(_ thread: ScrewThread, headDiameter: Double, socketWidth: Double, socketDepth: Double, length: Double, shankLength: Double = 0) -> Bolt {
36+
static func hexSocketCountersunk(_ thread: ScrewThread, headDiameter: Double, socketWidth: Double, socketDepth: Double, length: Double, unthreadedLength: Double = 0) -> Bolt {
3737
.init(
3838
thread: thread,
3939
length: length,
40-
shankLength: shankLength,
40+
unthreadedLength: unthreadedLength,
4141
headShape: .standardCountersunk(topDiameter: headDiameter, boltDiameter: thread.majorDiameter),
4242
socket: .standardHex(width: socketWidth, depth: socketDepth)
4343
)

Sources/Helical/Bolt/Standards/Bolt+HexSocketHeadCap.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Cadova
77

88
public extension Bolt {
99
/// Standard DIN 912 configuration
10-
static func hexSocketHeadCap(_ size: ScrewThread.ISOMetricSize, length: Double, shankLength: Double = 0) -> Bolt {
10+
static func hexSocketHeadCap(_ size: ScrewThread.ISOMetricSize, length: Double, unthreadedLength: Double = 0) -> Bolt {
1111
let headDiameter: Double // dk
1212
let socketWidth: Double // s, socket width across flats
1313

@@ -36,11 +36,11 @@ public extension Bolt {
3636
}
3737

3838
assert(headDiameter > 0 && socketWidth > 0, "\(size) isn't a valid size for DIN 912 bolts")
39-
return hexSocketHeadCap(.isoMetric(size), headDiameter: headDiameter, socketWidth: socketWidth, length: length, shankLength: shankLength)
39+
return hexSocketHeadCap(.isoMetric(size), headDiameter: headDiameter, socketWidth: socketWidth, length: length, unthreadedLength: unthreadedLength)
4040
}
4141

4242
/// Custom configuration
43-
static func hexSocketHeadCap(_ thread: ScrewThread, headDiameter: Double, socketWidth: Double, length: Double, shankLength: Double = 0) -> Bolt {
43+
static func hexSocketHeadCap(_ thread: ScrewThread, headDiameter: Double, socketWidth: Double, length: Double, unthreadedLength: Double = 0) -> Bolt {
4444
let head = CylindricalBoltHeadShape(
4545
diameter: headDiameter,
4646
height: thread.majorDiameter,
@@ -55,7 +55,7 @@ public extension Bolt {
5555
return .init(
5656
thread: thread,
5757
length: length,
58-
shankLength: shankLength,
58+
unthreadedLength: unthreadedLength,
5959
headShape: head,
6060
socket: socket
6161
)

Sources/Helical/Bolt/Standards/Bolt+PhillipsCheeseHead.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Cadova
77

88
public extension Bolt {
99
/// Standard configuration
10-
static func phillipsCheeseHead(_ size: ScrewThread.ISOMetricSize, length: Double, shankLength: Double = 0) -> Bolt {
10+
static func phillipsCheeseHead(_ size: ScrewThread.ISOMetricSize, length: Double, unthreadedLength: Double = 0) -> Bolt {
1111
let headDiameter: Double // dk
1212
let headThickness: Double // k
1313
let headTopRadius: Double // rf
@@ -37,7 +37,7 @@ public extension Bolt {
3737
socketWidth: socketWidth,
3838
phillipsSize: phillipsSize,
3939
length: length,
40-
shankLength: shankLength
40+
unthreadedLength: unthreadedLength
4141
)
4242
}
4343

@@ -50,7 +50,7 @@ public extension Bolt {
5050
socketWidth: Double,
5151
phillipsSize: PhillipsSize,
5252
length: Double,
53-
shankLength: Double = 0
53+
unthreadedLength: Double = 0
5454
) -> Bolt {
5555
let head = CylindricalBoltHeadShape(
5656
diameter: headDiameter,
@@ -61,8 +61,8 @@ public extension Bolt {
6161
return .init(
6262
thread: thread,
6363
length: length,
64-
shankLength: shankLength,
65-
shankDiameter: thread.pitchDiameter,
64+
unthreadedLength: unthreadedLength,
65+
unthreadedDiameter: thread.pitchDiameter,
6666
headShape: head,
6767
socket: socket
6868
)

Sources/Helical/Bolt/Standards/Bolt+PhillipsCountersunk.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Cadova
1111

1212
public extension Bolt {
1313
/// Standard configuration
14-
static func phillipsCountersunk(_ size: ScrewThread.ISOMetricSize, raised: Bool = false, length: Double, shankLength: Double = 0) -> Bolt {
14+
static func phillipsCountersunk(_ size: ScrewThread.ISOMetricSize, raised: Bool = false, length: Double, unthreadedLength: Double = 0) -> Bolt {
1515
let headDiameter: Double // dk
1616
let phillipsSize: PhillipsSize
1717
let socketWidth: Double // m
@@ -38,7 +38,7 @@ public extension Bolt {
3838
socketWidth: socketWidth,
3939
phillipsSize: phillipsSize,
4040
length: length,
41-
shankLength: shankLength
41+
unthreadedLength: unthreadedLength
4242
)
4343
}
4444

@@ -50,20 +50,20 @@ public extension Bolt {
5050
socketWidth: Double,
5151
phillipsSize: PhillipsSize,
5252
length: Double,
53-
shankLength: Double = 0
53+
unthreadedLength: Double = 0
5454
) -> Bolt {
5555
let head = CountersunkBoltHeadShape(
5656
countersink: .init(angle: 90°, topDiameter: headDiameter),
5757
boltDiameter: thread.majorDiameter - thread.depth,
5858
lensHeight: lensHeight
5959
)
6060
let socket = PhillipsBoltHeadSocket(size: phillipsSize, width: socketWidth)
61-
let effectiveShankLength = max(head.consumedLength + thread.majorDiameter / 10, shankLength)
61+
let effectiveunthreadedLength = max(head.consumedLength + thread.majorDiameter / 10, unthreadedLength)
6262
return .init(
6363
thread: thread,
6464
length: length,
65-
shankLength: effectiveShankLength,
66-
shankDiameter: thread.pitchDiameter,
65+
unthreadedLength: effectiveunthreadedLength,
66+
unthreadedDiameter: thread.pitchDiameter,
6767
headShape: head,
6868
socket: socket
6969
)

0 commit comments

Comments
 (0)