Remove unnecessary % (pipe sub) from KCL samples

This commit is contained in:
Adam Chalmers
2025-05-19 08:31:35 -05:00
parent b19acd550d
commit 7118f1284c
24 changed files with 87 additions and 87 deletions

View File

@ -29,4 +29,4 @@ bottleNeck = startSketchOn(bottleBody, face = END)
// Define a shell operation so that the entire body and neck are hollow, with only the top face opened
bottleShell = shell(bottleNeck, faces = [END], thickness = wallThickness)
|> appearance(%, color = "#0078c2")
|> appearance(color = "#0078c2")

View File

@ -40,7 +40,7 @@ bracketBody = startSketchOn(XZ)
|> xLine(length = thickness, tag = $seg05)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)], tag = $seg06)
|> close()
|> extrude(%, length = width)
|> extrude(length = width)
// Add mounting holes to mount to the shelf
shelfMountingHoles = startSketchOn(bracketBody, face = seg03)
@ -53,7 +53,7 @@ shelfMountingHoles = startSketchOn(bracketBody, face = seg03)
)
|> patternLinear2d(instances = 2, distance = -(extBendRadius + shelfMountingHolePlacementOffset) + shelfMountLength - shelfMountingHolePlacementOffset, axis = [-1, 0])
|> patternLinear2d(instances = 2, distance = width - (shelfMountingHolePlacementOffset * 2), axis = [0, 1])
|> extrude(%, length = -thickness - .01)
|> extrude(length = -thickness - .01)
// Add mounting holes to mount to the wall
wallMountingHoles = startSketchOn(bracketBody, face = seg04)
@ -65,7 +65,7 @@ wallMountingHoles = startSketchOn(bracketBody, face = seg04)
radius = wallMountingHoleDiameter / 2,
)
|> patternLinear2d(instances = 2, distance = width - (wallMountingHolePlacementOffset * 2), axis = [0, 1])
|> extrude(%, length = -thickness - 0.1)
|> extrude(length = -thickness - 0.1)
// Apply bends
fillet(bracketBody, radius = extBendRadius, tags = [getNextAdjacentEdge(seg03)])

View File

@ -24,13 +24,13 @@ lugHoles = startSketchOn(rotorBump, face = END)
instances = lugCount,
rotateDuplicates = true,
)
|> extrude(%, length = -(rotorInnerDiameterThickness + rotorSinglePlateThickness))
|> extrude(length = -(rotorInnerDiameterThickness + rotorSinglePlateThickness))
|> appearance(color = "#dbcd70", roughness = 90, metalness = 90)
// (update when boolean is available)
centerSpacer = startSketchOn(rotor, face = START)
|> circle(%, center = [0, 0], radius = .25)
|> extrude(%, length = spacerLength)
|> circle(center = [0, 0], radius = .25)
|> extrude(length = spacerLength)
secondaryRotorSketch = startSketchOn(centerSpacer, face = END)
|> circle(center = [0, 0], radius = rotorDiameter / 2)

View File

@ -44,7 +44,7 @@ copperTubePath = startSketchOn(offsetPlane(XY, offset = tubeDiameter))
// Create the profile for the inner and outer diameter of the hollow copper tube
tubeWall = startSketchOn(offsetPlane(YZ, offset = -7.35))
|> circle(center = [-bendRadius * 3, tubeDiameter], radius = tubeDiameter / 2)
|> subtract2d(%, tool = circle(center = [-bendRadius * 3, tubeDiameter], radius = tubeDiameter / 2 - wallThickness))
|> subtract2d(tool = circle(center = [-bendRadius * 3, tubeDiameter], radius = tubeDiameter / 2 - wallThickness))
|> sweep(path = copperTubePath)
|> appearance(color = "#b81b0a")

View File

@ -33,7 +33,7 @@ plateBody = startSketchOn(XY)
|> tangentialArc(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()
|> subtract2d(tool = circle(center = [0, 0], radius = centerHoleDiameter / 2 * 1.5))
|> extrude(%, length = plateThickness)
|> extrude(length = plateThickness)
// Function to create a countersunk hole
fn countersink(@holePosition) {

View File

@ -10,7 +10,7 @@ import * from "parameters.kcl"
// Model the center of the fan
fanCenter = startSketchOn(YZ)
|> circle(center = [0, 0], radius = fanHeight / 2, tag = $centerBend)
|> extrude(%, length = fanHeight)
|> extrude(length = fanHeight)
|> fillet(radius = 1.5, tags = [getOppositeEdge(centerBend)])
// Create a function for a lofted fan blade cross section that rotates about the center hub of the fan

View File

@ -38,10 +38,10 @@ lowerArm = startSketchOn(offsetPlane(XZ, offset = fanSize / 2 + 2))
// Create the profile of the mounting wire and sweep along the XZ path
wireProfile = startSketchOn(offsetPlane(XY, offset = 40 + fanSize / 2))
sweepUpperArm = circle(wireProfile, center = [-12, -fanSize / 2 - 2], radius = 1)
|> sweep(%, path = upperArm)
|> sweep(path = upperArm)
sweepLowerArm = circle(wireProfile, center = [-12, -fanSize / 2 - 2], radius = 1)
|> sweep(%, path = lowerArm)
|> sweep(path = lowerArm)
// Draw the XY components of the mounting wire path
upperHook = startSketchOn(offsetPlane(XY, offset = segEndY(seg07)))
@ -64,10 +64,10 @@ lowerHook = startSketchOn(offsetPlane(XY, offset = segEndY(seg08)))
// Sweep the wire profile around the hook-shaped segments of the mounting wire
hookProfile = startSketchOn(offsetPlane(YZ, offset = segEndX(seg07)))
sweepUpperHook = circle(hookProfile, center = [-fanSize / 2 - 2, segEndY(seg07)], radius = 1)
|> sweep(%, path = upperHook)
|> sweep(path = upperHook)
sweepLowerHook = circle(hookProfile, center = [-fanSize / 2 - 2, segEndY(seg08)], radius = 1)
|> sweep(%, path = lowerHook)
|> sweep(path = lowerHook)
// Union each piece of the wire into a single continuous sweep
[

View File

@ -46,23 +46,23 @@ valveStemSketch = startSketchOn(offsetPlane(XY, offset = valveHeadLength))
// Create the valve stem end
stepLength = stemHeadLength / 10
step1 = startSketchOn(valveStemSketch, face = END)
|> circle(%, center = [0, 0], radius = stemDiameter / 2 * 0.9)
|> extrude(%, length = stepLength * 2)
|> circle(center = [0, 0], radius = stemDiameter / 2 * 0.9)
|> extrude(length = stepLength * 2)
step2 = startSketchOn(step1, face = END)
|> circle(%, center = [0, 0], radius = stemDiameter / 2 * 0.8)
|> extrude(%, length = stepLength)
|> circle(center = [0, 0], radius = stemDiameter / 2 * 0.8)
|> extrude(length = stepLength)
step3 = startSketchOn(step2, face = END)
|> circle(%, center = [0, 0], radius = stemDiameter / 2 * 0.9)
|> extrude(%, length = stepLength)
|> circle(center = [0, 0], radius = stemDiameter / 2 * 0.9)
|> extrude(length = stepLength)
step4 = startSketchOn(step3, face = END)
|> circle(%, center = [0, 0], radius = stemDiameter / 2 * 0.8)
|> extrude(%, length = stepLength)
|> circle(center = [0, 0], radius = stemDiameter / 2 * 0.8)
|> extrude(length = stepLength)
step5 = startSketchOn(step4, face = END)
|> circle(%, center = [0, 0], radius = stemDiameter / 2 * 0.9)
|> extrude(%, length = stepLength)
|> circle(center = [0, 0], radius = stemDiameter / 2 * 0.9)
|> extrude(length = stepLength)
step6 = startSketchOn(step5, face = END)
|> circle(%, center = [0, 0], radius = stemDiameter / 2 * 0.8)
|> extrude(%, length = stepLength)
|> circle(center = [0, 0], radius = stemDiameter / 2 * 0.8)
|> extrude(length = stepLength)
step7 = startSketchOn(step6, face = END)
|> circle(
%,
@ -70,7 +70,7 @@ step7 = startSketchOn(step6, face = END)
radius = stemDiameter / 2 * 0.9,
tag = $seg02,
)
|> extrude(%, length = stepLength * 3, tagEnd = $capEnd001)
|> extrude(length = stepLength * 3, tagEnd = $capEnd001)
|> chamfer(
length = 0.5,
tags = [

View File

@ -49,4 +49,4 @@ bottomExtrusion = startSketchOn(flangeBase, face = START)
// Cut a hole through the entire body
pipeHole = startSketchOn(topExtrusion, face = END)
|> circle(center = [0, 0], radius = pipeDia / 2)
|> extrude(%, length = -(topTotalThickness + baseThickness + bottomThickness))
|> extrude(length = -(topTotalThickness + baseThickness + bottomThickness))

View File

@ -17,7 +17,7 @@ supportThickness = 3
// Main body of the PDU faceplate with integrated rack mounting flanges
faceplateShape = startSketchOn(offsetPlane(XY, offset = -faceplateHeight / 2))
|> startProfile(%, at = [-faceplateWidth / 2 - supportWidth, 0])
|> startProfile(at = [-faceplateWidth / 2 - supportWidth, 0])
|> yLine(length = supportThickness)
|> xLine(length = supportWidth)
|> yLine(length = faceplateDepth - supportThickness)
@ -53,7 +53,7 @@ leftSpacerPosition = leftSpacerWidth / 2 - (nestWidth / 2)
fn boxModuleFn(width) {
shape = startSketchOn(XZ)
|> startProfile(%, at = [-width / 2, moduleHeight / 2])
|> startProfile(at = [-width / 2, moduleHeight / 2])
|> xLine(length = width)
|> yLine(length = -moduleHeight)
|> xLine(length = -width)
@ -128,7 +128,7 @@ switchButtonBody = extrude(switchButtonShape, length = swtichButtonWidth)
y = 0,
z = 0,
)
|> appearance(%, color = "#ff0000")
|> appearance(color = "#ff0000")
// Spacer between switch and plug modules for layout alignment
secondSpacerWidth = moduleWidth / 2
@ -156,7 +156,7 @@ powerPlugBody = boxModuleFn(width = powerPlugWidth)
z = 0,
)
plugShape = startSketchOn(powerPlugBody, face = END)
|> circle(%, center = [0, 0], radius = 17)
|> circle(center = [0, 0], radius = 17)
|> translate(
%,
x = firstPowerPlugPosition,
@ -166,7 +166,7 @@ plugShape = startSketchOn(powerPlugBody, face = END)
plugBody = extrude(plugShape, length = -20)
plugHoleDistance = 20
plugHoleShape = startSketchOn(plugBody, face = START)
|> circle(%, center = [-plugHoleDistance / 2, 0], radius = 3)
|> circle(center = [-plugHoleDistance / 2, 0], radius = 3)
|> translate(
%,
x = firstPowerPlugPosition,

View File

@ -71,7 +71,7 @@ bearingUpper = startProfile(
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()
|> revolve(angle = 360, axis = Y)
|> appearance(%, color = "#121212")
|> appearance(color = "#121212")
bearingLower = startProfile(bearingBody, at = [bearingBoreDiameter / 2, 0.025])
|> xLine(length = 0.05)
@ -88,7 +88,7 @@ bearingLower = startProfile(bearingBody, at = [bearingBoreDiameter / 2, 0.025])
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()
|> revolve(angle = 360, axis = Y)
|> appearance(%, color = "#f0f0f0")
|> appearance(color = "#f0f0f0")
// Revolve the link sketch
revolve(linkSketch, axis = Y, angle = 360 / 16)

View File

@ -21,7 +21,7 @@ plateSketch = startSketchOn(XY)
|> close()
|> subtract2d(tool = circle(center = [0, 0], radius = bearingOuterDiameter / 2))
plateBody = extrude(plateSketch, length = stockThickness)
|> appearance(%, color = "#1e62eb")
|> appearance(color = "#1e62eb")
|> fillet(
radius = boltDiameter * 1 / 3,
tags = [

View File

@ -11,13 +11,13 @@ import pipeInnerDiameter, pipeOuterDiameter, pipeLength from "parameters.kcl"
export fn pipe() {
// Create the pipe base
pipeBase = startSketchOn(XZ)
|> circle(%, center = [0, 0], radius = pipeOuterDiameter / 2)
|> extrude(%, length = pipeLength)
|> circle(center = [0, 0], radius = pipeOuterDiameter / 2)
|> extrude(length = pipeLength)
// Extrude a hole through the length of the pipe
pipe = startSketchOn(pipeBase, face = END)
|> circle(center = [0, 0], radius = pipeInnerDiameter / 2)
|> extrude(%, length = -pipeLength)
|> extrude(length = -pipeLength)
|> appearance(color = "#a24ed0")
return pipe
}

View File

@ -11,7 +11,7 @@ import pipeDiameter, mountingHoleDiameter, mountingHolePlacementDiameter, flange
export fn flange() {
// Sketch the mounting hole pattern
mountingHoles = startSketchOn(XY)
|> circle(%, center = [0, mountingHolePlacementDiameter / 2], radius = mountingHoleDiameter / 2)
|> circle(center = [0, mountingHolePlacementDiameter / 2], radius = mountingHoleDiameter / 2)
|> patternCircular2d(
%,
instances = 4,
@ -22,23 +22,23 @@ export fn flange() {
// Create the flange base
flangeBase = startSketchOn(XY)
|> circle(%, center = [0, 0], radius = flangeDiameter / 2)
|> circle(center = [0, 0], radius = flangeDiameter / 2)
|> subtract2d(tool = mountingHoles)
|> extrude(%, length = flangeBaseThickness)
|> extrude(length = flangeBaseThickness)
// Create both the raised portions on the front and back of the flange base
flangeBack = startSketchOn(flangeBase, face = START)
|> circle(%, center = [0, 0], radius = flangeBackDiameter / 2)
|> extrude(%, length = flangeBackHeight)
|> circle(center = [0, 0], radius = flangeBackDiameter / 2)
|> extrude(length = flangeBackHeight)
flangeFront = startSketchOn(flangeBase, face = END)
|> circle(%, center = [0, 0], radius = flangeFrontDiameter / 2)
|> extrude(%, length = flangeFrontHeight)
|> circle(center = [0, 0], radius = flangeFrontDiameter / 2)
|> extrude(length = flangeFrontHeight)
// Create the circular cut in the center for the pipe
pipeCut = startSketchOn(flangeFront, face = END)
|> circle(%, center = [0, 0], radius = pipeDiameter / 2)
|> extrude(%, length = -flangeTotalThickness)
|> appearance(%, color = "#bab0b0")
|> circle(center = [0, 0], radius = pipeDiameter / 2)
|> extrude(length = -flangeTotalThickness)
|> appearance(color = "#bab0b0")
return pipeCut
}

View File

@ -9,11 +9,11 @@ import gasketOutsideDiameter, gasketInnerDiameter, gasketThickness from "paramet
// Create the base of the gasket
gasketBase = startSketchOn(XY)
|> circle(%, center = [0, 0], radius = gasketOutsideDiameter / 2)
|> extrude(%, length = gasketThickness)
|> circle(center = [0, 0], radius = gasketOutsideDiameter / 2)
|> extrude(length = gasketThickness)
// Extrude a circular hole through the gasket base
startSketchOn(gasketBase, face = END)
|> circle(%, center = [0, 0], radius = gasketInnerDiameter / 2)
|> extrude(%, length = -gasketThickness)
|> appearance(%, color = "#d0cb3e")
|> circle(center = [0, 0], radius = gasketInnerDiameter / 2)
|> extrude(length = -gasketThickness)
|> appearance(color = "#d0cb3e")

View File

@ -26,8 +26,8 @@ export fn hexNut() {
// Create the hole in the center of the hex nut
hexNut = startSketchOn(hexNutBase, face = END)
|> circle(center = [0, 0], radius = hexNutDiameter / 2)
|> extrude(%, length = -hexNutThickness)
|> appearance(%, color = "#4edfd5")
|> extrude(length = -hexNutThickness)
|> appearance(color = "#4edfd5")
return hexNut
}

View File

@ -17,8 +17,8 @@ export fn washer() {
// Extrude a hole through the washer
washer = startSketchOn(washerBase, face = END)
|> circle(center = [0, 0], radius = washerInnerDia / 2)
|> extrude(%, length = -washerThickness)
|> appearance(%, color = "#ee4f4f")
|> extrude(length = -washerThickness)
|> appearance(color = "#ee4f4f")
return washer
}

View File

@ -11,11 +11,11 @@ pipeLength = 6
// Create the pipe base
pipeBase = startSketchOn(XZ)
|> circle(%, center = [0, 0], radius = pipeOuterDiameter / 2)
|> extrude(%, length = pipeLength)
|> circle(center = [0, 0], radius = pipeOuterDiameter / 2)
|> extrude(length = pipeLength)
// Extrude a hole through the length of the pipe
pipe = startSketchOn(pipeBase, face = END)
|> circle(center = [0, 0], radius = pipeInnerDiameter / 2)
|> extrude(%, length = -pipeLength)
|> extrude(length = -pipeLength)
|> appearance(color = "#a24ed0")

View File

@ -112,7 +112,7 @@ stemLoftProfile6 = startSketchOn(plane006)
// Draw the third profile for the femoral stem
stemTab = clone(stemLoftProfile6)
|> extrude(%, length = 6)
|> extrude(length = 6)
// Loft the femur using all profiles in sequence

View File

@ -29,10 +29,10 @@ windowWidth = facadeWidth / windowCount
// Helper function: Creates a box from a center plane with given width and height
fn boxFn(plane, width, height) {
shape = startSketchOn(plane)
|> startProfile(%, at = [-width / 2, -width / 2])
|> line(%, end = [0, width])
|> line(%, end = [width, 0])
|> line(%, end = [0, -width])
|> startProfile(at = [-width / 2, -width / 2])
|> line(end = [0, width])
|> line(end = [width, 0])
|> line(end = [0, -width])
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close(%)
body = extrude(shape, length = height)
@ -50,44 +50,44 @@ fn transformFn(@i) {
// Create building base
baseThickness = 0.2
baseSlab = boxFn(plane = XY, width = slabWidth, height = -baseThickness)
|> appearance(%, color = "#dbd7d2")
|> appearance(color = "#dbd7d2")
// Create ground platform beneath the base
goundSize = 50
groundBody = boxFn(plane = offsetPlane(XY, offset = -baseThickness), width = goundSize, height = -5)
|> appearance(%, color = "#3a3631")
|> appearance(color = "#3a3631")
// Create a single slab with handrail height to be reused with pattern
slabAndHandrailGeometry = boxFn(plane = offsetPlane(XY, offset = floorHeight - slabThickness), width = slabWidth, height = slabThickness + handrailHeight)
slabVoidStart = -slabWidth / 2 + handrailThickness
slabVoidWidth = slabWidth - (handrailThickness * 2)
slabVoidShape = startSketchOn(slabAndHandrailGeometry, face = END)
|> startProfile(%, at = [slabVoidStart, slabVoidStart])
|> line(%, end = [0, slabVoidWidth])
|> line(%, end = [slabVoidWidth, 0])
|> line(%, end = [0, -slabVoidWidth])
|> startProfile(at = [slabVoidStart, slabVoidStart])
|> line(end = [0, slabVoidWidth])
|> line(end = [slabVoidWidth, 0])
|> line(end = [0, -slabVoidWidth])
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close(%)
// Generate and pattern slabs with voids across all floors
slabBody = extrude(slabVoidShape, length = -handrailHeight)
|> patternTransform(instances = floorCount, transform = transformFn)
|> appearance(%, color = "#dbd7d2")
|> appearance(color = "#dbd7d2")
// Create structural core of the tower
coreLength = 10
coreWidth = 8
core = startSketchOn(XY)
|> startProfile(%, at = [-coreLength / 2, -coreWidth / 2])
|> line(%, end = [0, coreWidth])
|> line(%, end = [coreLength, 0])
|> line(%, end = [-0.22, -coreWidth])
|> startProfile(at = [-coreLength / 2, -coreWidth / 2])
|> line(end = [0, coreWidth])
|> line(end = [coreLength, 0])
|> line(end = [-0.22, -coreWidth])
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close(%)
|> extrude(%, length = coreHeight)
|> extrude(length = coreHeight)
// Create facade panels for each floor
facadeStart = facadeWidth / 2
facadeGeometry = boxFn(plane = XY, width = facadeWidth, height = facadeHeight)
|> patternTransform(instances = floorCount, transform = transformFn)
|> appearance(%, color = "#151819")
|> appearance(color = "#151819")

View File

@ -37,7 +37,7 @@ fn tongueBlockFn() {
// Create top-side profile with tongues
tongueShape = startSketchOn(XY)
|> startProfile(%, at = [-insertLength / 2, insertThickness / 2])
|> startProfile(at = [-insertLength / 2, insertThickness / 2])
|> tongueBlockFn()
|> yLine(length = -insertThickness / 2)
|> xLine(length = -insertLength)

View File

@ -145,19 +145,19 @@ sinkBodyInside = startProfile(
// tap
tapPlate = startSketchOn(offsetPlane(XY, offset = tableHeight))
|> circle(%, center = [blockWidth / 2, tableDepth - 55], radius = 40)
|> circle(center = [blockWidth / 2, tableDepth - 55], radius = 40)
|> patternLinear2d(axis = [1, 0], instances = sinkCount, distance = sinkSpacing)
|> extrude(length = 5)
tapPillar = startSketchOn(offsetPlane(XY, offset = tableHeight))
|> circle(%, center = [blockWidth / 2, tableDepth - 55], radius = 15)
|> circle(center = [blockWidth / 2, tableDepth - 55], radius = 15)
|> patternLinear2d(axis = [1, 0], instances = sinkCount, distance = sinkSpacing)
|> extrude(length = 170)
tapNose = startSketchOn(offsetPlane(XZ, offset = 55 - tableDepth))
|> circle(%, center = [blockWidth / 2, tableHeight + 100], radius = 10)
|> circle(center = [blockWidth / 2, tableHeight + 100], radius = 10)
|> patternLinear2d(axis = [1, 0], instances = sinkCount, distance = sinkSpacing)
|> extrude(length = sinkWidth / 2.5)
tapHandle = startSketchOn(offsetPlane(XZ, offset = 55 - tableDepth))
|> circle(%, center = [blockWidth / 2, tableHeight + 150], radius = 4)
|> circle(center = [blockWidth / 2, tableHeight + 150], radius = 4)
|> patternLinear2d(axis = [1, 0], instances = sinkCount, distance = sinkSpacing)
|> extrude(length = 70)

View File

@ -14,7 +14,7 @@ body = startSketchOn(XZ)
|> yLine(length = -height, tag = $chamfer2)
|> xLine(length = -width, tag = $chamfer3)
|> close(tag = $chamfer4)
|> extrude(%, length = thickness)
|> extrude(length = thickness)
|> chamfer(
length = chamferLength,
tags = [

View File

@ -10,6 +10,6 @@ import width, thickness, height, knobDiameter, knobHeight, knobFilletRadius from
// Create the knob sketch and revolve
startSketchOn(XY)
|> circle(center = [0, 0], radius = knobDiameter / 2, tag = $knobBend)
|> extrude(%, length = knobHeight)
|> extrude(length = knobHeight)
|> fillet(radius = knobFilletRadius, tags = [getOppositeEdge(knobBend)])
|> appearance(%, color = "#afbf36")
|> appearance(color = "#afbf36")