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.
How to Identify Faces Directly Created from Sketch Edges in an Extruded Part (FeatureScript)?

Hi everyone,
I’m working with FeatureScript in Onshape and I have a question regarding extrusion operations. I’ve created a part by extruding a sketch, and now I need to identify which faces of the resulting solid are directly created from the edges of the sketch (i.e., the side faces that are the result of extruding the sketch lines, not the top or bottom faces).
As shown in the figure, I extruded a cylinder from a circle in a sketch. The bottom face of the cylinder directly overlaps with the circle in the sketch. Using the qCreatedBy()
function, I queried the cylinder with the featured of extrude and obtained the IDs of three faces. How can I determine which of these faces was directly extruded from the circle in the sketch (i.e., the cylindrical side face) and which face is the bottom face that overlaps with the sketch?
Has anyone dealt with this before or have any insights on how to identify these side faces directly created from sketch edges?
Thanks in advance for any help or suggestions!
Best Answer
-
Caden_Armstrong Member Posts: 271 PRO
You are looking for qCapEntity or qNonCapEntity
This will query for either the end faces or the side faces created by extrudes, revolve, sweep, loft, thicken.
www.smartbenchsoftware.com --- fs.place --- Renaissance
Custom FeatureScript and Onshape Integrated Applications3
Answers
Once you find the 'side' faces, what are you hoping to do? Does your FS always involve extruded cylinders like your example? Is the extrusion direction always the same, or is this configurable in the feature?
Ultimately, all of the faces of the extruded solid are created by the sketch lines, but you can use a few different approaches to 'filter' your faces so that you just get the side faces, but the final approach you go with does depend a bit on what you're trying to do at the end.
The absolute simplest solution here would just to extrude a surface rather than a solid, that way you know that the extruded body/face is the one you are looking for. If you need the top/bottom surfaces, you could then query your newly created surface body, find the correct edges on the top/bottom of the body, and use them to perform your next operations.
Depending on the complexity of the extruded shapes and extrusion directions, you may be able to evaluate face normal vectors to determine if you're 'looking' at the correct face. Assuming your extrude is in either the +/- Z direction , you'd want to keep faces with a normal direction (I'd recommend using the center of the face - or (0,5, 0.5) in parameter space) that have no Z component [normal vector = (anyXval, anyYval, 0)]. I threw together this quick FS to illustrate this approach. This FS puts any face with a normal direction parallel to the extrude direction into an array called "unwantedFaces" and any other face into "wantedFaces". It also colors unwanted faces red and wanted faces green.
[EDIT]:
Use Caden's method below.
https://cad.onshape.com/FsDoc/library.html#qNonCapEntity-Id-EntityType
You are looking for qCapEntity or qNonCapEntity
This will query for either the end faces or the side faces created by extrudes, revolve, sweep, loft, thicken.
Custom FeatureScript and Onshape Integrated Applications