Find face containing point.

jack_white396
jack_white396 Member Posts: 7 EDU
I am very new to featurescript and to coding as a whole, so I imagine this problem has an easy solution. I need to let the user select a point, which I know how to do, but then I need the feature to decide what face contains that point and then use it as the face for a sketch. How would I do this? Thank you so much for any help. This is my current code in case it helps-https://cad.onshape.com/documents/dd9b41942bbf9f447e9d9d6d/w/2b64a0a98ab7927062949adf/e/7a70e61408d6be428a6f3ba7

Answers

  • EvanReese
    EvanReese Member, Mentor Posts: 3,100 PRO
    If the point they select is always a sketch point, you can use evOwnerSketchPlane and get a plane there. If that works for you, you could also change your filter in the UI so user's can only pick sketch points. Something like this:
    annotation { "Name" : "Point", "Filter" : EntityType.VERTEX && SketchObject.YES, "MaxNumberOfPicks" : 1 }
           definition.center is Query;
    If you don't want to limit to sketch points I'm not 100% sure, but without trying any of them, maybe qAdjacent or qContainsPoint, and failing those, you could brute force it by querying all of the model faces and then getting the closest one with qClosestTo
    Evan Reese
    The Onsherpa | Reach peak Onshape productivity
    www.theonsherpa.com