Add experimental faceOf() stdlib function #9611
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Extracted from #9557.
Motivation
Problem 1. Right now, when you sketch a profile and tag an edge, then extrude, the tag is ambiguous. Does it refer to the edge or the wall face that it becomes? Our docs say that extruding morphs one into the other 🤦 So what happens to the edge? You can't refer to it anymore? This specifically came up in the design for GD&T where users may want to annotate arbitrary geometry, so we can't infer that they mean one or the other.
Problem 2. If you want to use the face for anything significant like sketching on it, the tag is lacking information. Ever notice how you must do
startSketchOn(mySolid, face = myTag)? Why isn't it juststartSketchOn(myTag)? Shouldn't that be enough to know what face you mean?Proposal: A new function that bundles up all the relevant information of a face on a solid. The signature looks like this:
fn faceOf(@solid: Solid, face: TaggedFace): Face. Basically, I'm trying to prevent new sketch blocks from inheriting the wonkiness of sketch v1. And for that, I'd like to be able to saysketch(on = something), where something is a face, notsketch(on = mySolid, face = myTag). But I also see this as a general way to disambiguate a face from an edge because we could makemyTagdefault to the edge. OTOH, if you want the face, then you can sayfaceOf(mySolid, face = myTag).In the future, we can make tags actually know about the solid they came from, and we could extend the function with an overload to allow
faceOf(myTag). It disambiguates from the edge. No breaking change.Implementation
The implementation already exists as a specific case of the legacy
startSketchOn(). Ever notice how that function returns aPlaneorFace? Weird, considering the name of the function. But it's exactly what we need for a sketch surface.The parameter naming is unfortunate.
faceOf(..., face = ...)We try to avoid the duplication. But we also try to follow the convention that a parameter namedtagis only for creating a tag. This mirrors the signature of the legacystartSketchOn(solid1, face = tag1).