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.

Get distance between midpoint of face and edge

Lee_HeskethLee_Hesketh Member, Developers Posts: 148 ✭✭✭
Hi there. How would I get the distance between the midpoint of a selected face and an adjacent edge?
There are 10 types of people in the world. Those who know binary, those who don't and those who didn't expect base 3!

Comments

  • viruviru Member, Developers Posts: 619 ✭✭✭✭
    edited September 2016
    @LeeH, Kindly refer below video and image which will be helpful to you. X=Red, Y=Green, Z=Blue show color coding for measurement lines as shown in below video and image.



    Distance from hole center will be given in all X, Y and Z directions when hole and edge point is selected as below.



    When the mouse cursor is moved on the area highlighted in red box, it will show the dimensions from hole center.



  • Lee_HeskethLee_Hesketh Member, Developers Posts: 148 ✭✭✭
    @viru Sorry for not explaining properly, I meant to be able to get that distance using feature script.
    There are 10 types of people in the world. Those who know binary, those who don't and those who didn't expect base 3!
  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,210
    Here's an example that does this, assuming a few things:
    1. "Midpoint of a face" means the midpoint of the parameter bounding box (as opposed to, say, the center of mass or center of world-space bounding box, both of which might not be on the face, or the point on the face farthest from an edge, which is not very easy to compute)
    2. "Distance" means Euclidean "as-a-bird-flies" distance as opposed to geodesic "as-an-ant-crawls" distance.
    3. You want the distance to the closest edge, rather than a specific one.

    When the face is a rectangle, assumptions 1 and 2 don't matter.

    https://cad.onshape.com/documents/fffbc3565708909ab42410db/w/0c483ba6fd7e4ceff4da1009/e/8ae7bec3cb524dbee06327a7
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
  • Lee_HeskethLee_Hesketh Member, Developers Posts: 148 ✭✭✭
    @ilya_baran Thank you very much for the example. It's greatly appreciated. How could I modify it so that it finds the other edge, not the closest?
    There are 10 types of people in the world. Those who know binary, those who don't and those who didn't expect base 3!
  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,210
    You can specify the edge in evDistance with a query -- for instance, you could iterate over the adjacent faces and call evDistance on each one.
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
  • billy2billy2 Member, OS Professional, Mentor, Developers, User Group Leader Posts: 2,068 PRO
    Euclidean "as-a-bird-flies"


    Geodesic "as-an-ant-crawls":




Sign In or Register to comment.