Unzip the folder where are all the settings of the machine, the default
~/linuxcnc-dev/configs/sim/gmoccapy

Connecting in .ini file:

[DISPLAY]
...
EMBED_TAB_NAME = my_new_panel
EMBED_TAB_LOCATION = box_custom_2
EMBED_TAB_COMMAND = gladevcp -x {XID} -u compensation_z.py -H compensation_z.hal compensation_z.glade


Compensation Z addition to the interface Gmoccapy used to track accurately the height difference of the workpiece in Z in such operations as surface engraving, routing paths PCBs and other cases where it is necessary to 'repeat' the uneven surface of the part and can not be cut too much. 
The process consists of two parts.
1.	Scanning the surface.
2.	Milling with enabled Compensation Z.
1. Scanning is done with a probe, usually installed in the spindle, and program G-code of this type

o<compensation_map> call [50] [50] [1] [1] [4] [25] [1] [2] [0.1] [0]
M02
%

Parameters from left to right:
[50] – width of the part on X
[50] – width of the part on Y
[1] – X left near the corner details
[1] – Y left near the corner details 
[4]- grid scan
[25]-probe speed
[1]-latch speed, =0 if you do not have to latch, >0 to move forward, <0 to reverse course
[2]-safe movement in Z plane
[0.1] –climb up Z between grid steps
[0]- level to Z search.
After running the program formed filename.txt file with surface map .
X and Y coordinates are recorded absolute (machine). Reading and use in milling process also in absolute coordinates, so if you specify indents X and Y by G92 (and will not move part), the program will work properly tracking the new coordinate system.
Indent Z to do so after the tool 0 got on the same plane, which was zero during the scan. I recommend this to use a special probe for putting tool 0.
2.Milling.
Attention!!! When you turn on Compensation Z, if the spindle is over scanning area, then Z is automatically set to a corrected position.
Attention!!! Delta Z is not tracked by machine, follow that (Z abs + Δ Z) did not go beyond. (Z abs + Δ Z) drawn on digital indicator of Compensation Z.
Press «Open», then «Play». Automatic compensation is enabled. Run your g-code program on the treatment of the surface .
You can on/off compensation directly from the g-code program:
M64 P0  - on
M65 P0  - off
Reopen the newly scanned filename.txt:
M64 P1 
G4 P1
M65 P1
G4 P4
Attention!!! When you turn off Compensation Z is automatically set to the original position Δ Z = 0. 

