# AutoFocus

The AutoFocus function Functions are tools that are available in Spreadsheet for processing and analyzing acquisitions or other results. You can add functions to your Spreadsheet job to create tool chains and produce results for specific applications. enables an automatic focus operation. You can use the function for working with parts of differing heights or if the vision system is moving.

When Offline, executing the AutoFocus function issues a trigger after the AutoFocus completes.

When Online, executing the AutoFocus function does not issue a trigger after the AutoFocus completes.

Note: Executing AutoFocus blocks the spreadsheet. This means the spreadsheet does not run, and triggers are not executed or show up as missed triggers if they are issued while AutoFocus is in progress. After AutoFocus completes, the spreadsheet is unblocked and runs normally.
Inputs

Parameter | Description
Image | This argument must reference a spreadsheet cell that contains a valid Image data structure. By default, the cell referenced is cell A0, containing the Image data structure returned by the AcquireImage function.
Region | Specifies the image coordinates of the Region to be plotted.
X | The X coordinate of the origin of the region.
Y | The Y coordinate of the origin of the region.
Width | The region width.
Height | The region height.
AutoFocus Event | Specifies the spreadsheet event on which to read data. This parameter needs to be a reference to any event with a timestamp, for example, one of the following: A cell containing an Event function. A cell containing a Button function. Note: The Event argument to the AutoFocus function must not be an AutoFocus Complete Event or an Acquisition Acquisition is the process or result of the vision system acquiring a new image. Event as these could cause an infinite loop. See Event.
Show | Specifies the display mode for the graphic overlay on the image.
0 = OFF | The graphic is hidden, except when the cell containing the function is highlighted in the spreadsheet.
1 = ON (default) | The graphic is displayed at all times.

Outputs

Returns | An AutoFocus structure, which can be referenced by the AutoFocus getters, GetAutoFocusPosition and GetAutoFocusDistance.