Get closest polygon by point location

Hi!
How I can get closest polygon by point location?
Or if point in polygon, then how I can get index this polygon?

This code is similar to your question, with some tweaking, it will work for your case:
https://blender.stackexchange.com/questions/96315/position-an-objects-origin-point-to-the-face-below-python

There is no solution for this link

Bvhtree can do this, and is very easy to build using python / depsgraph.

I am on my phone but have a example ony pc.

Please write an example later

I found tis code, but it’s works with errors

obj.closest_point_on_mesh(point_location)
max = 10

point = obj.closest_point_on_mesh(point_location, max)

If I do this, then I get error:

TypeError: Object.closest_point_on_mesh(): required parameter "distance" to be a keyword argument!

And if do this

human_obj.closest_point_on_mesh(point_location, distance=10)

then get

(False, Vector((0.0, 0.0, 0.0)), Vector((0.0, 0.0, 0.0)), -1)
If distance=30 then I get wrong result, in 2 point I get one index polygon

I move my main object in point 0, 0 , 0 and then it’s functional normal work

Ah you need to put your close point into object space

Point = object.matrix_world.inverted() @ worldPoint