Closed raphaelsetin closed 3 years ago
Maybe you could find all faces that have a normal "downwards". You could use methods like .Faces
and normalAt
.
Hey @adam-urbanczyk, thank you for the suggestion! I was able to solve this by developing an algorithm myself using the ThreeJS ray tracing API. However, I would like to do this within CADQuery itself, especially for performance and simplicity reasons.
I wasn't able to find any ray tracing functions in the CADQuery docs, so I would like to check with you if there are any ray tracing capabilities accessible within CADQuery.
so I would like to check with you if there are any ray tracing capabilities accessible within CADQuery.
There are not raytracing capabilities within CadQuery. Since CadQuery is just Python, the closest you can get is to find a way to use a Python ray tracing package with CadQuery to do what you want. https://pypi.org/project/raytracing/
@jmwright I didn't know about that package, but I was reading it now, and didn't find any relation with CADQuery, which makes me wonder how could I import a model in it and then do ray tracing.
Anyways, I know that CADQuery uses PythonOCC in the back end (correct me if I am wrong) as you guys moved away from the FreeCAD implementation some months ago, so would you know if PythonOCC has any ray tracing capabilities that maybe I could explore?
but I was reading it now, and didn't find any relation with CADQuery
It's not associated with CadQuery but it's a Python package so you should be able to use it and CadQuery together in your own Python scripts.
I know that CADQuery uses PythonOCC in the back end (correct me if I am wrong)
CadQuery actually uses its own set of Python bindings called OCP instead of PythonOCC. I don't know if PythonOCC has raytracing capabilities within it, but OCP does not.
That's good to know, thank you so much for the quick feedback 😃
I am trying to find a way of obtaining the "obscured" volumes/solids of a part supposing we were to ray cast it from a specific direction, for instance Z axis. By ray casting on Z axis, I would want to get the computed volume of the cavities as solids, which is also known as
undercuts
in 3D modeling.Explaining is more confusing than showing, so here is an example: Download the STEP file here: undercut example.zip
Original Model
Volumes (in yellow) that I want to obtain (ray casting on Z axis)
I read the entire documentation, went through all examples, and even tried some functions to see if maybe I was misunderstanding their functionality. I still wasn't able to find a way in CADQuery to do this. I know you are here to share CADQuery answers, but if any of you know a way of doing this using another software, please let me know too, I am open to suggestions.
As of now, I am using
ThreeJS
to render the model on the webpage, and though their library is extensive and flexible, I didn't find a simple way of doing this.Lastly, here is some documentation if the above is still not enough: