The osnap function can find a point by using one of the AutoCAD Object Snap modes. The Snap modes are specified in a string argument.
osnap looks for the midpoint of an object near pt1:
The following call to(setq pt2 (osnap pt1 "midp"))
pt1:
The following call looks for the midpoint, the endpoint, or the center of an object nearest(setq pt2 (osnap pt1 "midp,endp,center"))
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 SORTENTS system variable. Otherwise, pt2 is set to nil.
In both examples,