I have this set in a button script,  get the value of X/Y positions and write them to my X/Y Cam Offset DROs and write them to # Vars 5201 & 5202  which are Mach work shift vars. for droMScopeXOffset & droMScopeYOffset  I created Instance Registers in Mach Register Plugin,  and set the persistence check box so values are retained. 
here are is a screen shot of my setup which is working well for me right now. 
local inst = mc.mcGetInstance();
local Xpos = mc.mcAxisGetPos(inst, 0)  
local Ypos = mc.mcAxisGetPos(inst, 1)
scr.SetProperty('droMScopeXOffset', 'Value', tostring(Xpos))
scr.SetProperty('droMScopeYOffset', 'Value', tostring(Ypos))
mc.mcCntlSetPoundVar(inst,5201, Xpos)  --WORK SHIFT X    #5201
mc.mcCntlSetPoundVar(inst,5202, Ypos) -- WORK SHIFT Y    #5202
Bob