3

For any SolidWorks generated CAD file, such as Part, IGES, STEP, ACIS, etc., is there a relatively simple way to know if a 3D point intersects a complex 3D shape? I do not need to display the object in my application.

Any suggestion would be appreciated.

P.S. My question is quite similar to this one, but I am not using Java nor PLY file.

Community
  • 1
  • 1
Mehdi
  • 2,194
  • 2
  • 25
  • 39
  • 1
    In a stl file (for example), you can iterate through all faces and do some triangulation. http://tutorial.math.lamar.edu/Classes/CalcII/EqnsOfPlanes.aspx . Hope this help. – Hugues Paquet Blanchette Dec 06 '15 at 16:09
  • Thanks a lot for your useful comment. You said "for example", so is there any other format I can work with? Do you believe that STL is the simplest format one may utilize? – Mehdi Dec 06 '15 at 23:56
  • I don't know others formats, but .stl can be in clear text file: https://en.wikipedia.org/wiki/STL_%28file_format%29 . Processing time will take a lot of time – Hugues Paquet Blanchette Dec 07 '15 at 02:03
  • 1
    Oh, I see. I wrote a simple code that loads an STL file. As you said, the format is quite clear but it can be pretty time consuming to determine whether a point is inside the shape or not, especially that the process should be repeated for a large number of points. – Mehdi Dec 07 '15 at 06:02
  • Have you checked the SolidWorks API? By intersect, do you mean the point is located on edge, surface, vertex or the 3D point or inside the 3D shape? – Amen Jlili Dec 09 '15 at 08:29
  • No, I haven't because I needed to do it in my application. Yes, by intersect I meant almost all the situations you've mentioned. I already wrote a code which loads an STL file and detects if any arbitrary point is located on an edge or face, or if it's placed inside/outside the shape. – Mehdi Dec 09 '15 at 12:08
  • actually your application will use the solidworks interop assemblies to figure that out and return the result to your application, so technically speaking you're doing inside application – Amen Jlili Dec 20 '15 at 13:50
  • Well, could you please post a code snippet showing how one may utilize those assemblies? I am mostly using C#, however, any other programming language would be fine. – Mehdi Dec 21 '15 at 00:35

1 Answers1

0

The easiest would be to connect to solidworks instance and use RayIntersections method from their API. Shoot your ray in any direction, if number of intersections is odd - your point is located within the body.

Vlad
  • 793
  • 6
  • 15
  • i tired to use it, that api is making a crash can you please give samle code like how to use it – V01 Jun 30 '20 at 08:28
  • That'll take considerably more time than I'm willing to commit. But if you share your code and tell me where and how it crashes I may be able to help. – Vlad Jun 30 '20 at 19:50
  • up to you. Create a new SO question and paste a link here. OR add code to pastebin/github and paste link here. Don't forget to mention what exception you're getting and on what line. – Vlad Jul 02 '20 at 19:00