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.

Is it possiible to verify a point is inside a body (via API is better)?

atsushi_kuno075atsushi_kuno075 Member Posts: 2

Hello, everyone,

I am a graduate student working on robotics research. My research is about robot learning to make manipulators work on various objects. The learning part is conducted on Ubuntu, while the modelling of the objects is performed on Autodesk Inventor on Windows. I always got frustrated with switching the OSes (I do not like to use WSL…). The reason why I have used Inventor is this API function (https://help.autodesk.com/view/INVNTOR/2022/ENU/?guid=SurfaceBody_IsPointInside), verifying whether a point is inside an object's sub-body or not. I have to want to read the object's data point-wise. The Inventor was the only app that provided such functionality among major CAD software when I googled them.

I have found this app, OnShape, and am considering migrating to it since it looks like it is working nicely on Ubuntu. However, I am not sure that the aforementioned functionality is equipped with this app, as I glanced at the documentation. Does anybody know there is a way to check the point containment? Performing it via the API is better but not limited to it.

Thanks a lot in advance!

Atsushi

Comments

  • Jed_YeiserJed_Yeiser Member Posts: 37 PRO

    @atsushi_kuno075 - I'd imagine that there are excellent API endpoints that can do this. Not having worked with the OS API. I can't confirm that. There are two two possible ways I can think of going about a SIMILAR calculation using Featurescript - though they both may lack the accuracy/elegance you're looking for.

    1. use evBox3D to calculate the bounding box of a body. Testing if a point (vector) falls within that box is straightforward.
    2. use evCollision to test if one body is inside another. To do this you'd need to create a small 'point body'. I have never done this, but it should work. This method feels a bit like a clunky work-around. If I'm reading the docs on evCollision correctly (a big IF !), you can't pass a vector to the method, you need to provide a query for both the Tool and Target. You could get around this by either creating a very small solid body centered at the point you'd like to test OR create a wire body (opFitSpline using the origin as the first point and the desired test point as the second point) and query the vertex at the point of interest.

    I hope that helps!

    -j

  • Caden_ArmstrongCaden_Armstrong Member Posts: 173 PRO

    If you are using featurescript, all you need is qContainsPoint(queryToFilter, point)
    If you give it a single body, and then check if this query is empty afterwards (isQueryEmpty), you know if the body does or does not contain the point.

    www.smartbenchsoftware.com --- fs.place --- Renaissance
    Custom FeatureScript and Onshape Integrated Applications
Sign In or Register to comment.