0

I am wondering if there is a way to check if a give point (x y z) in a scene lies on the surface of any mesh object in that scene using Python script?

I mean, the point should lie on the mesh surface, not inside (maybe not exactly should be close enough if exact accuracy is impossible). So if the scene contains 1 cylinder of radius 1 centered at the origin, then the origin is not counted, but the points (1, 0, 0) or (0, 1, 0) are.

Duarte Farrajota Ramos
  • 59,425
  • 39
  • 130
  • 187
AugLe
  • 437
  • 5
  • 19
  • I'd better make it clear, it is not inside but on a mesh... – AugLe Feb 20 '17 at 16:19
  • It does indeed sound like a different problem, not a duplicate, though not sure if the same method may be used to solve this problem. – Duarte Farrajota Ramos Feb 20 '17 at 17:21
  • 1
    @DuarteFarrajotaRamos, I think https://docs.blender.org/api/blender_python_api_2_74_5/bpy.types.Object.html?highlight=closest%20point#bpy.types.Object.closest_point_on_mesh given in the answer is a solution for this question also – lemon Feb 20 '17 at 17:33
  • For all purposes, this closest_point_on_mesh may be costly. So you can check objects' bounding before – lemon Feb 20 '17 at 18:38
  • Do you mean the ray_cast method on the given link? Thanks for your suggestion anyway – AugLe Feb 20 '17 at 18:42
  • The solution for the dupe is effectively the same, the key is raycasting in both these cases. The first paragraph of the answer where it details the results of that method provide all the info needed (it returns the intersecting fact and point of intersection). – Sazerac Feb 21 '17 at 00:08

0 Answers0