Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- Be respectful, on topic and if you see a problem, Flag it.
If you would like to contact our Community Manager personally, feel free to send a private message or an email.
Featurescript: Select all outer faces adjacent to a seed face
mahir
Member, Developers Posts: 1,307 ✭✭✭✭✭
I've tried all sorts of variations of qLoopBoundedFaces, qFaceOrEdgeBoundedFaces, and qEdgeAdjacent... no cigar. For example, given the start face of an extruded ring, what combination of queries will retrieve the cylindrical outer surface? It seems whatever I try ends up with all the surfaces of the extrusion. This would would extend to the 4 outer surfaces of an extruded square channel and so on.Below is the closest I've gotten so far. I'm not sure what edge I'm selecting either. I guess that's another question worth answering. How to select the outer boundary of a face? Thanks for the help.
var outerFaces =
qFaceOrEdgeBoundedFaces(
qUnion([
qEntityFilter(qCapEntity(id + "extrude1", true), EntityType.FACE),
qNthElement(qCreatedBy(id + "extrude1", EntityType.EDGE), 0)
])
);
or
or
var outerFaces =
qLoopBoundedFaces(
qUnion([
qEntityFilter(qCapEntity(id + "extrude1", true), EntityType.FACE),
qNthElement(qCreatedBy(id + "extrude1", EntityType.EDGE), 0)
])
);
Tagged:
0
Comments
As far as I've been able to determine, to find the outer loop you need to actually partition all adjacent edges/faces to the selected face and then go through the connected components and figure out which is the outside one. Intuitively, you could probably get the bounding box of each connected component and look for the largest, and that's your outer loop (this is almost definitely not the most efficient way).
PhD, Mechanical Engineering, Stanford University
I haven't implemented it yet, but I've thought about creating a more useful version of qLoopBoundedFaces that will at least let you toggle between inner/outer bounding surfaces, even if I can't figure out which is which without visual feedback. It would start with qEdgeAdjacent(face, EntityType.FACE), then select the first face and get all connected non-seed faces that were in the original query. If that doesn't work, change it to start from the last face instead.
Any input from OnShape?
PhD, Mechanical Engineering, Stanford University
Once you have one of the outer faces, you can either get the rest the same way (as a qUnion of a bunch of sketchEntityQueries), or use qFaceOrEdgeBoundedFaces, with the input being as a qUnion of:
- The seed face above
- The extrude's end cap face
- The extrude's start cap face
None of this is specific to the "outside", it's just a robust way of referencing geometry you've created from an underlying sketch. With this method you can specify any contiguous loop of faces on the extrude using different sketch ids.PhD, Mechanical Engineering, Stanford University