Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. 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_HooverAaron_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:

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

Best Answer

Answers

  • konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 1,221 ✭✭✭✭✭
    seems like qEverything returns two additional sketch faces
    use faces owned by the solid bodies instead
  • Aaron_HooverAaron_Hoover Member Posts: 35 EDU
    That doesn't entirely square with what I'm seeing, though. While there is a sketch face coincident with the large face of the grey part above, there's no sketch face coincident with the small face of the blue part, and yet that face is returned twice as well. 

    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?

  • konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 1,221 ✭✭✭✭✭
    As you can see when I select the sketch two faces of two sketch regions become highlighted - exactly two more additional faces you are looking for. Sketch is a feature which creates bodies - wire bodies when you draw lines and sheet bodies when closed contours appear. So these additional faces are owned by sheet bodies made by sketch feature. One more thing - sketch inherits underlying contour of the planar face it is made on, so you may have a sketch with no new entites added by yourself but still it will contain inhereted contours.
  • Aaron_HooverAaron_Hoover Member Posts: 35 EDU
    Thanks @konstantin_shiriazdanov and @Jake_Rosenfeld. I have a better understanding of bodies and the ownership hierarchy now. 

    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! 
  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,310
    @Aaron_Hoover it’s been a while but I think my mortise & tenon and pocket holes scripts do what you are asking for onshape.com/featurescript 
    Senior Director, Technical Services, EMEAI
Sign In or Register to comment.