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 choose which body to select in feature script

CAD_SSPCAD_SSP Member Posts: 45 PRO
I am trying to use the selection of 2 faces on one part to reliably select another part alongside it, and if there are 2 parts adjoining it then I want to be able to select which one I want using a boolean input.

To my way of thinking the example below does not work as I would expect it to, both of the "Hinge" features select the part nearest the "back" but I would have thought it more logical if one selected the back one and the other the front...

example:  https://cad.onshape.com/documents/7e271c1b4713b16b58063150/w/582c06d1a4c282d4bf39b5e8/e/aa474d081cdf011d56ad7571

I have been through all the queries I can think of to try and determine which part I want without any success, I can successfully get a coordinate system that works as I would expect it to:

utilising the Normal to face on the side faces - evSurfaceDefinition(context, {"face" : definition.sideFace}).normal and creating a coordinate system based on that, But I have no idea how to use this to determine which of the side panels I want it to select.

Any help much appreciated.

Tagged:

Best Answer

  • ilya_baranilya_baran Posts: 888
    Accepted Answer
    Have you tried using qFarthestAlong with the normal direction (or the negative normal direction, depending on your boolean flag)?  Make sure that what you pass to qFarthestAlong is a query that resolves to your two candidate bodies (and nothing else).
    Ilya Baran \ Director of FeatureScript \ Onshape Inc

Answers

  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 888
    Accepted Answer
    Have you tried using qFarthestAlong with the normal direction (or the negative normal direction, depending on your boolean flag)?  Make sure that what you pass to qFarthestAlong is a query that resolves to your two candidate bodies (and nothing else).
    Ilya Baran \ Director of FeatureScript \ Onshape Inc
  • CAD_SSPCAD_SSP Member Posts: 45 PRO
    @ilya_baran Thanks very much for that, worked a treat, have updated the example and will leave it for anyone else who needs it.
Sign In or Register to comment.