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 get all faces that meet at an edge with FeatureScript?
Aaron_Hoover
Member Posts: 35 EDU
I'm experiencing some weirdness in a FeatureScript that's supposed to get all faces that meet at an edge. I've got two thin, rectangular parts butted together at 90 degrees, and I want the user to be able to select an edge of the joint in order to automatically generate pockets and drills for cabinet fastening hardware.
I'm using the following line to get all the "adjacent" faces:
I would expect this query to return 4 faces (the four that touch that edge), but it's returning 6.
It appears to be returning the large and small vertical faces twice. When I query for the owner body of the first instance of the large vertical face, I get this:
Which just seems super bizarre to me. When I query for the owner body of the second instance of the large vertical face, I get this which is what I would expect:
What am I doing wrong/how should I interpret the results of the first query?
The problematic code is in the function getFaces() in this FeatureScript: https://cad.onshape.com/documents/3926df9f5f87e416bc920f0b/w/cac04c63becd1cb085f1f257/e/33ce2903c2aaa4feb4a6f9be.
I'm using the following line to get all the "adjacent" faces:
var edgeAdjacentFaces = qClosestTo(qEverything(EntityType.FACE), params.jointLine.origin);
I would expect this query to return 4 faces (the four that touch that edge), but it's returning 6.
It appears to be returning the large and small vertical faces twice. When I query for the owner body of the first instance of the large vertical face, I get this:
Which just seems super bizarre to me. When I query for the owner body of the second instance of the large vertical face, I get this which is what I would expect:
What am I doing wrong/how should I interpret the results of the first query?
The problematic code is in the function getFaces() in this FeatureScript: https://cad.onshape.com/documents/3926df9f5f87e416bc920f0b/w/cac04c63becd1cb085f1f257/e/33ce2903c2aaa4feb4a6f9be.
Tagged:
0
Best Answer
-
Jake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,646@Aaron_Hoover
Every piece of topology in Onshape (vertices, edges, faces, and bodies themselves) belongs to a single body. Bodies are analogous to the "Parts, "Surfaces", and "Curves" that appear in your parts list on the left side of the screen (although some bodies, like sketch bodies and construction planes, do not show up in that list).
Bodies come in the following flavors:- Solid: A set of faces connected by edges and vertices that encloses a single solid region
- Sheet: A set of faces connected by edges and vertices that does not enclose a region
- Wire: A set of edges connected by vertices
- Point: A single vertex
So, the edge that you are seeing would not have two owner bodies, it is only owned by the body that it is a part of. Just because the edge touches two bodies does not mean that it belongs to both, both of those bodies just happen to have a matching edge there. The sketch is its own set of wire and sheet bodies (specifically an independent wire body for each sketched edge, and sheet bodies representing the grey faces of the sketch).
If you want your query to work out, you can probably get away with this:qClosestTo(qBodyType(qEverything(EntityType.FACE), BodyType.SOLID), params.jointLine.origin);
Although, I think that qContainsPoint is probably a better choice than qClosestTo, and generally it may be a better idea to have the user select the parts they care about than making an everything query.
Jake Rosenfeld - Modeling Team5
Answers
Also, is a sketch also considered a body? Wouldn't then any edge of an extruded solid coincident with the sketch plane have two owner bodies - the solid body and the sketch?
Every piece of topology in Onshape (vertices, edges, faces, and bodies themselves) belongs to a single body. Bodies are analogous to the "Parts, "Surfaces", and "Curves" that appear in your parts list on the left side of the screen (although some bodies, like sketch bodies and construction planes, do not show up in that list).
Bodies come in the following flavors:
- Solid: A set of faces connected by edges and vertices that encloses a single solid region
- Sheet: A set of faces connected by edges and vertices that does not enclose a region
- Wire: A set of edges connected by vertices
- Point: A single vertex
A "part" is a solid body. A "surface" is a sheet body. A "curve" is a wire body. The origin of the part studio is a point body.So, the edge that you are seeing would not have two owner bodies, it is only owned by the body that it is a part of. Just because the edge touches two bodies does not mean that it belongs to both, both of those bodies just happen to have a matching edge there. The sketch is its own set of wire and sheet bodies (specifically an independent wire body for each sketched edge, and sheet bodies representing the grey faces of the sketch).
If you want your query to work out, you can probably get away with this:
Although, I think that qContainsPoint is probably a better choice than qClosestTo, and generally it may be a better idea to have the user select the parts they care about than making an everything query.
As for having the user select the parts they care about, I was hoping to allow the user to select multiple edges along which to put fasteners. The process of selecting parts seemed to make that logic quite a bit more unwieldy, so I was trying to build more of the "smarts" into my FeatureScript logic.
Thanks for your help!