How to programmatically find faces which define the entry and exits for a hole?
I am working on a featurescript to add internal bosses to threaded holes (this is an evolution of a 3D-printed "tapless" threading posted on youtube).
Script: https://cad.onshape.com/documents/1e451ed1452487dd6118fbbe/w/76456d124ce9039290f2b923/e/d5a5f79d9a758c2c8ecf5ab6
Basic concept: https://cad.onshape.com/documents/1e451ed1452487dd6118fbbe/w/76456d124ce9039290f2b923/e/563cebf95d941c41ce150e75
I'm trying to figure out how to use FS to merge with the cylinder walls. This would be really easy to work out on a case-by-case basis where I could control the start and stop points, but I admit to being at a bit of a loss for how to programmatically do UP TO FACE extrusions. Specifically, how do I identify the top and bottom faces which border the in-question cylinder face, in order to use them as the start and end faces?
Comments
-
There are two queries that might help you:
qHoleFaces(seed); → this will filter a query of faces to those that belong to a hole
qAdjacent() → this will take a seed query and find the faces that are adjacent to all of the given entities.
If you take your hole faces and find the adjacent faces, those are the "boundary" faces.www.smartbenchsoftware.com --- Renaissance --- Kestrel -- SmartLink
Experts in Onshape Automation - Custom Features and Integrated Applications1 -
@Caden_Armstrong oh, those look awesome, thanks for pointing them out. I'll give a look and see if I can figure out how to make them work.
0 -
@Caden_Armstrong That was definitely it, thanks!
In case anyone wants more info about how I did this, here's the code snippet:
// Find the faces which connect to the hole var adjacentFaces = evaluateQuery(context, qAdjacent(cylinder, AdjacencyType.EDGE, EntityType.FACE)); // Loop over each face for (var face in adjacentFaces) { // Visualize the face debug(context, face, DebugColor.MAGENTA); }1

