AutoLISP
Developer's Guide > Using the AutoLISP
Language > Using AutoLISP to
Communicate with AutoCAD > Device Access and
Control >

Calibrating Tablets

*Command Reference* for a description of
this command). The *tablet* function enables
applications to manage calibration by setting the calibrations
directly and by saving those settings for future use.

*tablet* function is an integer
*code*.
If *code*
is equal to 0, the function returns the current calibration. If
*code* is
equal to 1, the calibration is set according to the remaining
arguments. Calibrations are expressed as four 3D points (in
addition to the *code*). The first three
pointsâ€”*row1*, *row2*, and
*row3*â€”are the three rows of the tablet's
transformation matrix. The fourth point, *direction*, is a vector that is normal to the plane in
which the tablet's surface is assumed to lie (expressed in WCS, the
World Coordinate System). When the calibration is set with the
TABLET command, the tablet's surface is assumed to lie in the
*XY* plane of the current UCS.

NoteThe TABMODE
system variable controls whether Tablet mode is turned on (1) or
off (0). You can control it by using the *setvar*
function.

tcal:

The following sample routine retrieves the current tablet calibration and stores it in the variable(defun C:TABGET ( )

(setq tcal (tablet 0))

(if tcal

(princ

(strcat "\nConfiguration saved, "

"use TABSET to retrieve calibration.")

)

(princ "\nCalibration not obtainable ")

)

(princ)

)

tcal now contains the list returned by the tablet function. This list might appear as follows:

If the preceding routine was successful, the symbol(1 (0.00561717 -0.000978942 -7.5171)

(0.000978942 0.00561717 -9.17308)

(0.0 0.0 1.0)

(0.0 0.0 1.0)

)

*C:TABSET* routine, as follows:

(defun C:TABSET ( )

(if (not (apply 'tablet tcal))

(princ "\nUnable to reset calibration. ")

(progn

(princ "\nTablet calibration reset. ")

(setvar "tabmode" 1)

(if (= (getvar "tabmode") 0)

(princ "\nUnable to turn on tablet mode ")

)

)

)

(princ)

)

*row1*,
*row2*, and *row3* is a 3W3
transformation matrix that is meant to transform a 2D point. The 2D
point is expressed as a column vector in homogeneous coordinates
(by appending 1.0 as the third element), so the transformation
looks like this:

The calculation of a point is similar to the 3D case. AutoCAD transforms the point by using the following formulas:

To turn the resulting vector back into a 2D point, the first two components are divided by the third component (the scale factor D') yielding the point (X'/D',Y'/D').

*tablet* does the
full calculation. But for affine and orthogonal transformations,
M_{20} and M_{21} are both 0, so D' would be 1.0.
The calculation of D' and the division are omitted; the resulting
2D point is simply (X',Y').

_{20} and M_{21} zero, but M_{00}
= M_{11} and M_{10} = -M_{01}.

NoteWhen you set
a calibration, the list returned does not equal the list provided
if the *direction* isn't normalized. AutoCAD
normalizes the direction vector before it returns it. Also, it
ensures the third element in the third column (*row3*[Z]) is equal to 1. This
situation should not arise if you set the calibration by using
values retrieved from AutoCAD by means of *tablet*. However,
it can happen if your program calculates the transformation
itself.