Skip to content

Conversation

adamchalmers
Copy link
Contributor

@adamchalmers adamchalmers commented Oct 10, 2025

Add a new hole module with countersink, counterbore etc holes. This has been ready for two months or so, but I got distracted by constraint solvers. Clearly the ML team has found workarounds for converting holes in other CAD programs, but we should just add this as an experimental library and let people test it out in prod.

@adamchalmers adamchalmers requested a review from a team as a code owner October 10, 2025 23:09
Copy link

vercel bot commented Oct 10, 2025

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

Project Deployment Preview Comments Updated (UTC)
modeling-app Ready Ready Preview Comment Oct 15, 2025 3:54am

Copy link

codspeed-hq bot commented Oct 10, 2025

CodSpeed Performance Report

Merging #8530 will not alter performance

Comparing achalmers/hole-lib (e3325e1) with main (cff54a4)1

Summary

✅ 139 untouched
⏩ 92 skipped2

Footnotes

  1. No successful run was found on main (9dbca34) during the generation of this report, so cff54a4 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 92 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.

@adamchalmers adamchalmers requested a review from a team as a code owner October 10, 2025 23:40
@adamchalmers adamchalmers force-pushed the achalmers/hole-lib branch 2 times, most recently from 7f11d1f to 4faa15d Compare October 11, 2025 00:22
@adamchalmers adamchalmers changed the base branch from main to achalmers/no-empty-modules-in-sim-tests October 11, 2025 00:22
@adamchalmers adamchalmers force-pushed the achalmers/no-empty-modules-in-sim-tests branch from f7cd818 to df4831d Compare October 11, 2025 00:32
Base automatically changed from achalmers/no-empty-modules-in-sim-tests to main October 11, 2025 00:49
@adamchalmers adamchalmers changed the title KCL: hole support KCL: new 'hole' module for mech-eng Oct 11, 2025
@adamchalmers adamchalmers enabled auto-merge (squash) October 11, 2025 01:09
Copy link
Contributor

@jtran jtran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that this isn't marked as experimental. Reminder that that's an option.

/// From the hole's parts (bottom, middle, top), cut the hole into the given solid,
/// at each of the given 2D positions on the given face.
/// Basically like function `hole` but it takes multiple 2D positions in `cutsAt`.
export fn holes(@solid, face, holeBottom, holeBody, holeType, cutsAt) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is having both the singular and plural to make KCL read nicely?

I almost don't want to remind anyone because I absolutely hate this feature, but if you add the parameter types and use an array, any single value will be automatically wrapped in an array. Part of the reason we made the automatic coercion to array was to address this exact use case where a function can take either a single thing or an array, without duplication.

That said, if you'd rather be explicit, and avoid all that terrible automatic coercion, I support it, but wonder if the singlular hole() flavored fn is necessary.


/// End the hole flat.
export fn flat() {
return { drillBitAngle = 179.99deg }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this leftover from the engine bug that didn't allow 180deg? I thought it was fixed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's actually a logic error, as tan(180) is 0 and somewhere in the math I divide by tan(drillBitAngle), so I kept it as 179.99

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems strange to me to hardcode such a weird value. It's a form of a tolerance. It means that if anyone uses { drillBitAngle = 180deg } directly, without going through flat(), we'll needlessly fail.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should move the check into sketchHoleProfile().

/// Place the given holes in a line.
/// Basically like function `hole` but cuts multiple holes in a line.
/// Works like linear patterns.
export fn holesLinear(@solid, face, holeBottom, holeBody, holeType, cutAt, instances, distance, axis) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add parameter types? They would show up in the docs, and I think they're generally helpful to users.

holeType,
/// Where to place the cut on the given face of the solid.
/// This controls how far up/down/left/right the hole is placed.
cutAt: [number(Length); 2],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamchalmers I know this is still experimental so we don't have to handle that case today, IMO it'd be really convenient to be able to select a sketch point here instead of giving relative coords to the face. One we have sketch v2 this would all integrate nicely with constraints!

Copy link
Contributor Author

@adamchalmers adamchalmers Oct 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, the docs are actually wrong, it's actually absolute position. I'm opening up a PR to fix. #8560

}
}

// Bodies
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Through holes aren't implemented now, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct

@adamchalmers adamchalmers merged commit ca50eb0 into main Oct 15, 2025
77 checks passed
@adamchalmers adamchalmers deleted the achalmers/hole-lib branch October 15, 2025 14:58
@pierremtb pierremtb linked an issue Oct 15, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generic hole stdlib functions

3 participants