The xcursor of and ycursor of functions can be applied to any object. The values returned are the coordinates of the graphics cursor in the specified object, and are expressed in the object's own coordinates.
The following example saves the cursor position into a pair of variables, so that the cursor can be put back to that position after the pattern is drawn.
response to AddDot
copy (xcursor of Z) to SaveX
copy (ycursor of Z) to SaveY
add to Z
pattern Dot
move to SaveX SaveY