Skip to content

Statically transpile sketch and extrude in a pipeline, inside a function#10358

Draft
jtran wants to merge 2 commits intomainfrom
jtran/static-transpile
Draft

Statically transpile sketch and extrude in a pipeline, inside a function#10358
jtran wants to merge 2 commits intomainfrom
jtran/static-transpile

Conversation

@jtran
Copy link
Contributor

@jtran jtran commented Mar 8, 2026

#9278

This is a proof of concept of a different approach that doesn't require execution. In particular, this works on the angle-gauge sample, where the sketch is inside a function, never assigned to a variable.

The transpile binary learned a new option --static to call this new approach.

// Angle Gauge
// Simple angle gauge function to generate a gauge given an angle
// Categories: Construction

// Set units in inches (in)
@settings(defaultLengthUnit = in, experimentalFeatures = allow)

// Define parameters
cutoutEdgeLength = 2
cutoutWidth = 0.52
cutoutAngle = 10 // degrees
cutoutDepth = 1
cutoutBaseDepth = 0.5
totalWidth = 1.25
blockEdgeLength = 0.5
flip = 0

fn gauge(cutoutAngle, N, startX, startY, deltaX, deltaY) {
  sketch1 = sketch(on = XY) {
    line1 = line(start = [var 0, var 0], end = [var 1, var 0])
    horizontal(line1)
    distance([line1.start, line1.end]) == cutoutDepth + cutoutBaseDepth
    point1 = point(at = [
      blockEdgeLength + startX + deltaX * N,
      startY + deltaY * N
    ])
    coincident([point1, line1.start])
    line2 = line(start = [var 0, var 0], end = [var 0, var 1])
    vertical(line2)
    distance([line2.start, line2.end]) == (totalWidth - cutoutWidth) / 2 - ((1 - flip) * cutoutDepth * sin(units::toRadians(cutoutAngle)))
    coincident([line1.end, line2.start])
    line3 = line(start = [var 0, var 0], end = [var 1, var 0])
    angle([line2, line3]) == 180 - ((1 - flip) * cutoutAngle)
    horizontalDistance([line3.start, line3.end]) == cutoutDepth
    coincident([line2.end, line3.start])
    line4 = line(start = [var 0, var 0], end = [var 0, var 1])
    vertical(line4)
    distance([line4.start, line4.end]) == cutoutWidth
    coincident([line3.end, line4.start])
    line5 = line(start = [var 0, var 0], end = [var 1, var 0])
    angle([line4, line5]) == flip * cutoutAngle
    horizontalDistance([line5.start, line5.end]) == cutoutDepth
    coincident([line4.end, line5.start])
    line6 = line(start = [var 0, var 0], end = [var 0, var 1])
    vertical(line6)
    coincident([line5.end, line6.start])
    line7 = line(start = [var 0, var 0], end = [var 1, var 0])
    horizontal(line7)
    distance([line7.start, line7.end]) == -1 * (cutoutDepth + cutoutBaseDepth)
    coincident([line6.end, line7.start])
    coincident([line7.end, line1.start])
  }
  region1 = region(segments = [sketch1.line1, sketch1.line2])
  gaugeSketch = extrude(region1, length = 0.05)
  return gaugeSketch
}

startX = 0
startY = 0
xSpacing = 2
angleSpacing = 5
gauge(
  cutoutAngle = 8,
  N = 0,
  startX = startX,
  startY = startY,
  deltaX = xSpacing,
  deltaY = 0,
)
gauge(
  cutoutAngle = 14,
  N = 1,
  startX = startX,
  startY = startY,
  deltaX = xSpacing,
  deltaY = 0,
)
gauge(
  cutoutAngle = 15,
  N = 2,
  startX = startX,
  startY = startY,
  deltaX = xSpacing,
  deltaY = 0,
)

@jtran jtran added the sketch-solve PRs changing sketch-solve functionality only. label Mar 8, 2026
@vercel
Copy link

vercel bot commented Mar 8, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
modeling-app Ready Ready Preview, Comment Mar 13, 2026 7:10pm

Request Review

@codspeed-hq
Copy link

codspeed-hq bot commented Mar 8, 2026

Merging this PR will not alter performance

✅ 167 untouched benchmarks
⏩ 93 skipped benchmarks1


Comparing jtran/static-transpile (0f4a8f5) with main (517b27c)

Open in CodSpeed

Footnotes

  1. 93 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

jtran added 2 commits March 13, 2026 14:53
In particular, this works on the angle-gauge sample.

Change default to be the old execution way
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sketch-solve PRs changing sketch-solve functionality only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant