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.

  • $\begingroup$ I'd better make it clear, it is not inside but on a mesh... $\endgroup$
    – AugLe
    Feb 20, 2017 at 16:19
  • $\begingroup$ 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. $\endgroup$ Feb 20, 2017 at 17:21
  • 1
    $\begingroup$ @DuarteFarrajotaRamos, I think docs.blender.org/api/blender_python_api_2_74_5/… given in the answer is a solution for this question also $\endgroup$
    – lemon
    Feb 20, 2017 at 17:33
  • $\begingroup$ For all purposes, this closest_point_on_mesh may be costly. So you can check objects' bounding before $\endgroup$
    – lemon
    Feb 20, 2017 at 18:38
  • $\begingroup$ Do you mean the ray_cast method on the given link? Thanks for your suggestion anyway $\endgroup$
    – AugLe
    Feb 20, 2017 at 18:42


Browse other questions tagged .