0
$\begingroup$

In the mathutils.geometry, I have found a few functions that return intersections of spheres, planes, etc., but none for a line (or Vector) and a mesh. Is there a way to do this?

The mesh in question is actually constructed of several meshes, and I suppose I would have to check each individual mesh for intersection with my line in Python. Perhaps I can combine them.

I know in advance there will be only one point of intersection with only one of the meshes due to the design of the meshes and the orientation of the lines involved.

$\endgroup$

1 Answer 1

1
$\begingroup$

I'm pretty sure that you need Ray cast:

ray_cast(origin, direction, distance=1.70141e+38, depsgraph=None)

Cast a ray onto evaluated geometry, in object space (using context’s or provided depsgraph to get evaluated mesh if needed)

https://docs.blender.org/api/current/bpy.types.Object.html?highlight=ray%20cast#bpy.types.Object.ray_cast

https://docs.blender.org/api/current/bpy.types.Scene.html?highlight=ray%20cast#bpy.types.Scene.ray_cast

$\endgroup$
2
  • $\begingroup$ YES! That sounds perfect. $\endgroup$
    – WillDotson
    Aug 11, 2021 at 19:12
  • $\begingroup$ Can you tell me anything about the differences between the two versions? One seems to require a "depsgraph" parameter, for the other it's optional. But what is a "depsgraph"? My ultimate goal is to convert a Blender drawing to a proprietary file format, and I need this to take measurements. The drawing is made up of about a dozen meshes, but I assume I could "unify" them somehow if necessary. $\endgroup$
    – WillDotson
    Aug 11, 2021 at 19:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .