Object Snap

AutoCAD AutoLISP & Visual LISP

 
Object Snap
 
 
 

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.

The following call to osnap looks for the midpoint of an object near pt1:

(setq pt2 (osnap pt1 "midp"))

The following call 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 SORTENTS system variable. Otherwise, pt2 is set to nil.

NoteThe APERTURE system variable determines the allowable proximity of a selected point to an object when you use Object Snap.