Skip to content

Remove unnecessary % (pipe sub) from KCL samples #7062

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion public/kcl-samples/bottle/main.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
6 changes: 3 additions & 3 deletions public/kcl-samples/bracket/main.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)])
Expand Down
6 changes: 3 additions & 3 deletions public/kcl-samples/car-wheel-assembly/car-rotor.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion public/kcl-samples/cold-plate/main.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion public/kcl-samples/countersunk-plate/main.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion public/kcl-samples/cpu-cooler/fan.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions public/kcl-samples/cpu-cooler/mounting-wire.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand All @@ -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
[
Expand Down
26 changes: 13 additions & 13 deletions public/kcl-samples/engine-valve/main.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -46,31 +46,31 @@ 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(
%,
center = [0, 0],
radius = stemDiameter / 2 * 0.9,
tag = $seg02,
)
|> extrude(%, length = stepLength * 3, tagEnd = $capEnd001)
|> extrude(length = stepLength * 3, tagEnd = $capEnd001)
|> chamfer(
length = 0.5,
tags = [
Expand Down
2 changes: 1 addition & 1 deletion public/kcl-samples/flange/main.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -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))
10 changes: 5 additions & 5 deletions public/kcl-samples/pdu-faceplate/main.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions public/kcl-samples/pillow-block-bearing/ball-bearing.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion public/kcl-samples/pillow-block-bearing/block.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
6 changes: 3 additions & 3 deletions public/kcl-samples/pipe-flange-assembly/1120t74-pipe.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
20 changes: 10 additions & 10 deletions public/kcl-samples/pipe-flange-assembly/68095k348-flange.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
}
10 changes: 5 additions & 5 deletions public/kcl-samples/pipe-flange-assembly/9472k188-gasket.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
4 changes: 2 additions & 2 deletions public/kcl-samples/pipe-flange-assembly/95479a127-hex-nut.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
4 changes: 2 additions & 2 deletions public/kcl-samples/pipe-flange-assembly/98017a257-washer.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
6 changes: 3 additions & 3 deletions public/kcl-samples/pipe/main.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
2 changes: 1 addition & 1 deletion public/kcl-samples/prosthetic-hip/main.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading
Loading