Skip to content

Change samples to call startProfile() with explicit sketch parameter #7884

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
8 changes: 4 additions & 4 deletions public/kcl-samples/axial-fan/fan-housing.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * from "parameters.kcl"
// Model the housing which holds the motor, the fan, and the mounting provisions
// Bottom mounting face
bottomFaceSketch = startSketchOn(XY)
|> startProfile(at = [-fanSize / 2, -fanSize / 2])
bottomFaceSolid = startProfile(bottomFaceSketch, at = [-fanSize / 2, -fanSize / 2])
|> angledLine(angle = 0, length = fanSize, tag = $rectangleSegmentA001)
|> angledLine(angle = segAng(rectangleSegmentA001) + 90, length = fanSize, tag = $rectangleSegmentB001)
|> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001), tag = $rectangleSegmentC001)
Expand Down Expand Up @@ -48,7 +48,7 @@ bottomFaceSketch = startSketchOn(XY)
|> extrude(length = 4)

// Add large openings to the bottom face to allow airflow through the fan
airflowPattern = startSketchOn(bottomFaceSketch, face = END)
airflowPattern = startSketchOn(bottomFaceSolid, face = END)
|> startProfile(at = [fanSize * 7 / 25, -fanSize * 9 / 25])
|> angledLine(angle = 140, length = fanSize * 12 / 25, tag = $seg01)
|> tangentialArc(radius = fanSize * 1 / 50, angle = 90)
Expand All @@ -70,7 +70,7 @@ airflowPattern = startSketchOn(bottomFaceSketch, face = END)
// Create the middle segment of the fan housing body
housingMiddleLength = fanSize / 3
housingMiddleRadius = fanSize / 3 - 1
bodyMiddle = startSketchOn(bottomFaceSketch, face = END)
bodyMiddle = startSketchOn(bottomFaceSolid, face = END)
|> startProfile(at = [
housingMiddleLength / 2,
-housingMiddleLength / 2 - housingMiddleRadius
Expand Down Expand Up @@ -130,7 +130,7 @@ topHoles = startProfile(topFaceSketch, at = [-fanSize / 2, -fanSize / 2])
|> extrude(length = 4)

// Create a housing for the electric motor to sit
motorHousing = startSketchOn(bottomFaceSketch, face = END)
motorHousing = startSketchOn(bottomFaceSolid, face = END)
|> circle(center = [0, 0], radius = 11.2)
|> extrude(length = 16)

Expand Down
4 changes: 2 additions & 2 deletions public/kcl-samples/axial-fan/fan.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import * from "parameters.kcl"

// Model the center of the fan
fanCenter = startSketchOn(XZ)
|> startProfile(at = [-0.0001, fanHeight])
fanCenterSketch = startSketchOn(XZ)
fanCenter = startProfile(fanCenterSketch, at = [-0.0001, fanHeight])
|> xLine(endAbsolute = -15 + 1.5)
|> tangentialArc(radius = 1.5, angle = 90)
|> yLine(endAbsolute = 4.5)
Expand Down
17 changes: 10 additions & 7 deletions public/kcl-samples/ball-bearing/main.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ insideWall = extrude(insideWallSketch, length = overallThickness)

// Create the sketch of one of the balls
ballsSketch = startSketchOn(XY)
|> startProfile(at = [shaftDia / 2 + wallThickness, 0.001])
ballsProfile = startProfile(ballsSketch, at = [shaftDia / 2 + wallThickness, 0.001])
|> arc(angleStart = 180, angleEnd = 0, radius = sphereDia / 2)
|> close()

// Revolve the ball to make a sphere and pattern around the inside wall
balls = revolve(ballsSketch, axis = X)
balls = revolve(ballsProfile, axis = X)
|> patternCircular3d(
arcDegrees = 360,
axis = [0, 0, 1],
Expand All @@ -42,17 +42,20 @@ balls = revolve(ballsSketch, axis = X)

// Create the sketch for the chain around the balls
chainSketch = startSketchOn(XY)
|> startProfile(at = [
shaftDia / 2 + wallThickness + sphereDia / 2 - (chainWidth / 2),
0.125 * sin(60)
])
chainProfile = startProfile(
chainSketch,
at = [
shaftDia / 2 + wallThickness + sphereDia / 2 - (chainWidth / 2),
0.125 * sin(60)
],
)
|> arc(angleStart = 120, angleEnd = 60, radius = sphereDia / 2)
|> line(end = [0, chainThickness])
|> line(end = [-chainWidth, 0])
|> close()

// Revolve the chain sketch
chainHead = revolve(chainSketch, axis = X)
chainHead = revolve(chainProfile, axis = X)
|> patternCircular3d(
arcDegrees = 360,
axis = [0, 0, 1],
Expand Down
4 changes: 2 additions & 2 deletions public/kcl-samples/bone-plate/main.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
boltSize = 4.5

// Revolve the profile of a compression plate designed to fit a bone
plateRevolve = startSketchOn(YZ)
|> startProfile(at = [22.9, 0])
plateSketch = startSketchOn(YZ)
plateRevolve = startProfile(plateSketch, at = [22.9, 0])
|> arc(angleStart = 180, angleEnd = 176, radius = 120)
|> arc(angleStart = -60, angleEnd = 54, radius = 5)
|> arc(angleStart = 180, angleEnd = 176, radius = 120)
Expand Down
4 changes: 2 additions & 2 deletions public/kcl-samples/bottle/main.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ neckDiameter = 45
wallThickness = 4

// Create a rounded body for the bottle
bottleBody = startSketchOn(XY)
|> startProfile(at = [-bottleLength / 2, 0])
bottleSketch = startSketchOn(XY)
bottleBody = startProfile(bottleSketch, at = [-bottleLength / 2, 0])
|> yLine(length = bottleWidth / 3)
|> arc(endAbsolute = [bottleLength / 2, bottleWidth / 3], interiorAbsolute = [0, bottleWidth / 2])
|> yLine(endAbsolute = 0)
Expand Down
4 changes: 2 additions & 2 deletions public/kcl-samples/bracket/main.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ assert(width, isGreaterThanOrEqual = shelfMountingHoleDiameter * 5.5, error = "H
assert(width, isGreaterThanOrEqual = wallMountingHoleDiameter * 5.5, error = "Holes not possible. Either decrease hole diameter or increase width")

// Create the body of the bracket
bracketBody = startSketchOn(XZ)
|> startProfile(at = [0, 0])
bracketSketch = startSketchOn(XZ)
bracketBody = startProfile(bracketSketch, at = [0, 0])
|> xLine(length = shelfMountLength - thickness, tag = $seg01)
|> yLine(length = thickness, tag = $seg02)
|> xLine(length = -shelfMountLength, tag = $seg03)
Expand Down
13 changes: 8 additions & 5 deletions public/kcl-samples/car-wheel-assembly/brake-caliper.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ import caliperTolerance, caliperPadLength, caliperThickness, caliperOuterEdgeRad

// Sketch the brake caliper profile
brakeCaliperSketch = startSketchOn(XY)
|> startProfile(at = [
rotorDiameter / 2 + caliperTolerance,
0
])
brakeCaliperProfile = startProfile(
brakeCaliperSketch,
at = [
rotorDiameter / 2 + caliperTolerance,
0
],
)
|> line(end = [
0,
rotorTotalThickness + caliperTolerance - caliperInnerEdgeRadius
Expand Down Expand Up @@ -56,5 +59,5 @@ brakeCaliperSketch = startSketchOn(XY)
|> close()

// Revolve the brake caliper sketch
revolve(brakeCaliperSketch, axis = Y, angle = -70)
revolve(brakeCaliperProfile, axis = Y, angle = -70)
|> appearance(color = "#c82d2d", metalness = 90, roughness = 90)
4 changes: 2 additions & 2 deletions public/kcl-samples/car-wheel-assembly/car-tire.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import tireInnerDiameter, tireOuterDiameter, tireDepth, bendRadius, tireTreadWid

// Create the sketch of the tire
tireSketch = startSketchOn(XY)
|> startProfile(at = [tireInnerDiameter / 2, tireDepth / 2])
tireProfile = startProfile(tireSketch, at = [tireInnerDiameter / 2, tireDepth / 2])
|> line(
endAbsolute = [
tireOuterDiameter / 2 - bendRadius,
Expand Down Expand Up @@ -41,5 +41,5 @@ tireSketch = startSketchOn(XY)
|> close()

// Revolve the sketch to create the tire
carTire = revolve(tireSketch, axis = Y)
carTire = revolve(tireProfile, axis = Y)
|> appearance(color = "#0f0f0f", roughness = 80)
15 changes: 8 additions & 7 deletions public/kcl-samples/cold-plate/main.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ wallThickness = 0.080
bendRadius = 1

// Create the cold plate with indentions to secure each pass of the brazed copper tube
coldPlate = startSketchOn(YZ)
|> startProfile(at = [0, tubeDiameter * 2])
coldPlateSketch = startSketchOn(YZ)
coldPlate = startProfile(coldPlateSketch, at = [0, tubeDiameter * 2])
|> xLine(length = bendRadius - (tubeDiameter / 2))
|> yLine(length = -tubeDiameter)
|> tangentialArc(angle = 180, radius = tubeDiameter / 2)
Expand All @@ -31,8 +31,8 @@ coldPlate = startSketchOn(YZ)
|> extrude(length = 10, symmetric = true)

// Sketch the path for the copper tube to follow
copperTubePath = startSketchOn(offsetPlane(XY, offset = tubeDiameter))
|> startProfile(at = [-7.35, -bendRadius * 3])
copperTubeSketch = startSketchOn(offsetPlane(XY, offset = tubeDiameter))
copperTubePath = startProfile(copperTubeSketch, at = [-7.35, -bendRadius * 3])
|> xLine(length = 14.13, tag = $seg05)
|> tangentialArc(angle = 180, radius = bendRadius, tag = $seg02)
|> angledLine(angle = tangentToEnd(seg02), length = 13.02, tag = $seg06)
Expand All @@ -42,15 +42,16 @@ copperTubePath = startSketchOn(offsetPlane(XY, offset = tubeDiameter))
|> angledLine(angle = tangentToEnd(seg04), length = segLen(seg05))

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

// Model a brazed cap to cover each tube. Constrain the caps using the walls of the plate
brazedCap = startSketchOn(YZ)
|> startProfile(at = segEnd(seg07))
brazedCapSketch = startSketchOn(YZ)
brazedCap = startProfile(brazedCapSketch, at = segEnd(seg07))
|> arc(interiorAbsolute = [bendRadius * 3, tubeDiameter * 1.85], endAbsolute = segEnd(seg08))
|> yLine(endAbsolute = segStartY(seg08))
|> arc(
Expand Down
4 changes: 2 additions & 2 deletions public/kcl-samples/counterdrilled-weldment/main.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ blockWidth = boltSpacingY + boltDiameter * 6

// Draw the base plate
plateSketch = startSketchOn(XY)
|> startProfile(at = [-blockLength / 2, -blockWidth / 2])
plateProfile = startProfile(plateSketch, at = [-blockLength / 2, -blockWidth / 2])
|> angledLine(angle = 0, length = blockLength, tag = $rectangleSegmentA001)
|> angledLine(angle = segAng(rectangleSegmentA001) + 90, length = blockWidth, tag = $rectangleSegmentB001)
|> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001), tag = $rectangleSegmentC001)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)], tag = $rectangleSegmentD001)
|> close()
|> subtract2d(tool = circle(center = [0, 0], radius = tubeInnerDiameter / 2))
plateBody = extrude(plateSketch, length = stockThickness)
plateBody = extrude(plateProfile, length = stockThickness)
|> chamfer(
length = boltDiameter * 2,
tags = [
Expand Down
6 changes: 3 additions & 3 deletions public/kcl-samples/countersunk-plate/main.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ d = boltSpacing / 2
tangentAngle = asin((r1 - r2) / d)
tangentLength = (r1 - r2) / tan(tangentAngle)

plateBody = startSketchOn(XY)
// Use polar coordinates to start the sketch at the tangent point of the larger radius
|> startProfile(at = polar(angle = 90 - tangentAngle, length = r1))
plateSketch = startSketchOn(XY)
// Use polar coordinates to start the sketch at the tangent point of the larger radius
plateBody = startProfile(plateSketch, at = polar(angle = 90 - tangentAngle, length = r1))
|> angledLine(angle = -tangentAngle, length = tangentLength)
|> tangentialArc(radius = r2, angle = (tangentAngle - 90) * 2)
|> angledLine(angle = tangentAngle, length = -tangentLength)
Expand Down
8 changes: 4 additions & 4 deletions public/kcl-samples/cpu-cooler/fan-housing.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * from "parameters.kcl"
// Model the housing which holds the motor, the fan, and the mounting provisions
// Bottom mounting face
bottomFaceSketch = startSketchOn(YZ)
|> startProfile(at = [-fanSize / 2, -fanSize / 2])
bottomFaceSolid = startProfile(bottomFaceSketch, at = [-fanSize / 2, -fanSize / 2])
|> angledLine(angle = 0, length = fanSize, tag = $rectangleSegmentA001)
|> angledLine(angle = segAng(rectangleSegmentA001) + 90, length = fanSize, tag = $rectangleSegmentB001)
|> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001), tag = $rectangleSegmentC001)
Expand Down Expand Up @@ -48,7 +48,7 @@ bottomFaceSketch = startSketchOn(YZ)
|> extrude(length = 4)

// Add large openings to the bottom face to allow airflow through the fan
airflowPattern = startSketchOn(bottomFaceSketch, face = END)
airflowPattern = startSketchOn(bottomFaceSolid, face = END)
|> startProfile(at = [fanSize * 7 / 25, -fanSize * 9 / 25])
|> angledLine(angle = 140, length = fanSize * 12 / 25, tag = $seg01)
|> tangentialArc(radius = fanSize * 1 / 50, angle = 90)
Expand All @@ -70,7 +70,7 @@ airflowPattern = startSketchOn(bottomFaceSketch, face = END)
// Create the middle segment of the fan housing body
housingMiddleLength = fanSize / 3
housingMiddleRadius = fanSize / 3 - 1
bodyMiddle = startSketchOn(bottomFaceSketch, face = END)
bodyMiddle = startSketchOn(bottomFaceSolid, face = END)
|> startProfile(at = [
housingMiddleLength / 2,
-housingMiddleLength / 2 - housingMiddleRadius
Expand Down Expand Up @@ -130,7 +130,7 @@ topHoles = startProfile(topFaceSketch, at = [-fanSize / 2, -fanSize / 2])
|> extrude(length = 4)

// Create a housing for the electric motor to sit
motorHousing = startSketchOn(bottomFaceSketch, face = END)
motorHousing = startSketchOn(bottomFaceSolid, face = END)
|> circle(center = [0, 0], radius = 11.2)
|> extrude(length = 16)

Expand Down
4 changes: 2 additions & 2 deletions public/kcl-samples/cpu-cooler/heat-sink.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ baseUpper = startProfile(coolerBase, at = [0, 10])
|> extrude(length = 2 * segLen(seg02) * 3 / 4, symmetric = true)

// Create a flexible mounting bracket to secure the heat sink to the motherboard once adhered
mountingBracket = startSketchOn(XZ)
|> startProfile(at = [-10, 16])
mountingBracketSketch = startSketchOn(XZ)
mountingBracket = startProfile(mountingBracketSketch, at = [-10, 16])
|> xLine(length = -20)
|> tangentialArc(angle = 20, radius = bendRadius)
|> angledLine(angle = -160, length = 14, tag = $seg09)
Expand Down
4 changes: 2 additions & 2 deletions public/kcl-samples/cpu-cooler/removable-sticker.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
@settings(defaultLengthUnit = mm)

// Create a simple body to represent the removable warning sticker. Brightly color the sticker so that the user will not forget to remove it before installing the device
removableSticker = startSketchOn(-XY)
|> startProfile(at = [-12, -12])
removableStickerSketch = startSketchOn(-XY)
removableSticker = startProfile(removableStickerSketch, at = [-12, -12])
|> angledLine(angle = 0, length = 24, tag = $rectangleSegmentA001)
|> angledLine(angle = segAng(rectangleSegmentA001) + 90, length = 24, tag = $rectangleSegmentB001)
|> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001), tag = $rectangleSegmentC001)
Expand Down
25 changes: 12 additions & 13 deletions public/kcl-samples/enclosure/main.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ wallThickness = 3
holeDia = 4

// Model a box with base enclosure dimensions
sketch001 = startSketchOn(XY)
|> startProfile(at = [0, 0])
boxSketch = startSketchOn(XY)
boxProfile = startProfile(boxSketch, at = [0, 0])
|> angledLine(angle = 0, length = width, tag = $rectangleSegmentA001)
|> angledLine(angle = segAng(rectangleSegmentA001) + 90, length, tag = $rectangleSegmentB001)
|> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001), tag = $rectangleSegmentC001)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)], tag = $rectangleSegmentD001)
|> close()
extrude001 = extrude(sketch001, length = height)
box = extrude(boxProfile, length = height)
|> fillet(
radius = wallThickness * 4,
tags = [
Expand All @@ -39,17 +39,16 @@ fn function001(@originStart) {
plane001 = {
origin = [0.0, 0.0, wallThickness],
xAxis = [1.0, 0.0, 0.0],
yAxis = [0.0, 1.0, 0.0],
zAxis = [0.0, 0.0, 1.0]
yAxis = [0.0, 1.0, 0.0]
}

// Create a pillar with a fasterner hole at the center
sketch002 = startSketchOn(plane001)
pillarProfile = startSketchOn(plane001)
|> circle(center = [originStart[0], originStart[1]], radius = holeDia + wallThickness)
|> subtract2d(tool = circle(center = [originStart[0], originStart[1]], radius = holeDia))
extrude002 = extrude(sketch002, length = height - wallThickness)
pillar = extrude(pillarProfile, length = height - wallThickness)

return extrude002
return pillar
}

// Place the internal pillar at each corner
Expand All @@ -71,8 +70,8 @@ function001([
])

// Define lid position and outer surface
sketch003 = startSketchOn(XY)
|> startProfile(at = [width * 1.2, 0])
lidOuterSketch = startSketchOn(XY)
lidOuterProfile = startProfile(lidOuterSketch, at = [width * 1.2, 0])
|> angledLine(angle = 0, length = width, tag = $rectangleSegmentA002)
|> angledLine(angle = segAng(rectangleSegmentA001) + 90, length, tag = $rectangleSegmentB002)
|> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001), tag = $rectangleSegmentC002)
Expand Down Expand Up @@ -106,7 +105,7 @@ sketch003 = startSketchOn(XY)
],
radius = holeDia,
))
extrude003 = extrude(sketch003, length = wallThickness)
lidOuter = extrude(lidOuterProfile, length = wallThickness)
|> fillet(
radius = wallThickness * 4,
tags = [
Expand All @@ -118,7 +117,7 @@ extrude003 = extrude(sketch003, length = wallThickness)
)

// Define lid inner and sealing surfaces
sketch004 = startSketchOn(extrude003, face = END)
lidInnerProfile = startSketchOn(lidOuter, face = END)
|> startProfile(at = [
width * 1.2 + wallThickness,
wallThickness
Expand Down Expand Up @@ -156,7 +155,7 @@ sketch004 = startSketchOn(extrude003, face = END)
],
radius = holeDia + wallThickness,
))
extrude004 = extrude(sketch004, length = wallThickness)
lid = extrude(lidInnerProfile, length = wallThickness)
|> fillet(
radius = wallThickness * 3,
tags = [
Expand Down
6 changes: 3 additions & 3 deletions public/kcl-samples/exhaust-manifold/main.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ fn primaryTube(n, angle001, length001, length002, length003) {
|> angledLine(angle = tangentToEnd(arc02), length = length003)

// Create the cross section of each tube and sweep them
sweepProfile = startSketchOn(XY)
|> circle(center = [pos001, 0], radius = primaryTubeDiameter / 2)
sweepSketch = startSketchOn(XY)
tube = circle(sweepSketch, center = [pos001, 0], radius = primaryTubeDiameter / 2)
|> subtract2d(tool = circle(center = [pos001, 0], radius = primaryTubeDiameter / 2 - wallThickness))
|> sweep(path = sweepPath)

Expand Down Expand Up @@ -73,7 +73,7 @@ primaryTube(

// Create the mounting flange for the header
flangeSketch = startSketchOn(XY)
|> startProfile(at = [3 + 1.3, -1.25])
flangeProfile = startProfile(flangeSketch, at = [3 + 1.3, -1.25])
|> xLine(length = -2.6, tag = $seg01)
|> tangentialArc(radius = .3, angle = -40)
|> tangentialArc(radius = .9, angle = 80)
Expand Down
Loading
Loading