The osnap function can find a point by using one of the AutoCAD Object Snap modes.
You pass the function a three element list that represents a 3D point; if you want to specify a 2D point, set the Z axis to a value of 0 (zero). Snap modes are specified using a string value; multiple Snap modes can be specified by using a comma delimiter.
The following example code looks for the midpoint of an object near pt1:
(setq pt2 (osnap pt1 "_midp"))
The following example code looks for the midpoint, the endpoint, or the center of an object nearest pt1:
(setq pt2 (osnap pt1 "_midp,_endp,_center"))
In both examples, pt2 is set to the snap point if one is found that fulfills the osnap requirements. If more than one snap point fulfills the requirements, the point is selected based on the setting of the AutoCAD SORTENTS system variable. Otherwise, pt2 is set to nil.