Remarks on the AutoLevel feature in simCNC v3.600 beta 1
The AutoLevel feature is enabled/disabled by default using the M151 and M150 commands. They are implemented via the M150.py and M151.py macros. These macros will be automatically added to the newly created configuration profile.
For an existing profile, they can be copied from: “<program installation path>/python/defaultScripts/scripts”, or created manually.
M150.py – macro for the command that disables AutoLevel
d.setAutoLevelingState( AutoLevelingState.Off )
print("AutoLeveling Correction: OFF")
M151.py – macro for the command that enables AutoLevel
d.setAutoLevelingState( AutoLevelingState.On )
print("AutoLeveling Correction: ON")
An example macro for scanning a grid of points is being prepared and will be included with the beta-2 release. For now, you can experiment with supplying data to the function on your own. Below is an example macro that creates a grid of points (a tilted surface), sends it to the controller, and enables AutoLevel.
d.setAutoLevelingState( AutoLevelingState.Off )
time.sleep(0.5)
rows = 10
cols = 10
# Initialize the matrix with zeros
matrix: List[List[float]] = [[0.0 for _ in range(cols)] for _ in range(rows)]
def fn_surface(x: int, y: int)->float:
a = 0.1
b = 0.2
c = 1.0
return (a * x + b * y + c)
for y in range(rows):
for x in range(cols):
v = fn_surface(x, y)
matrix[x][y] = v
d.setAutoLevelingGridData( matrix )
d.setAutoLevelingGridStep( 25.0, 25.0 )
d.setAutoLevelingOrigin( d.getCurrentWorkOffset( ) )
time.sleep(0.5)
d.setAutoLevelingState( AutoLevelingState.On )
The following commands are used to operate the AutoLevel function from a Python macro:
- setAutoLevelingState (AutoLevelingState)
Enable/disable the AutoLevel function - getAutoLevelingState()
Read the current AutoLevel state - setAutoLevelingGridData( <2D float array>)
Transfer Z correction data – a 10×10 point grid as a 2D array of Z correction values - setAutoLevelingGridStep(<xStep>, <yStep>)
Distance between grid points in X and Y - setAutoLevelingOrigin( <abs coords> )
Set the position of the grid’s “0/0” point – machine coordinates
The following machine parameters have also been implemented:
-
#9100
Information on the AutoLevel function state -
#9101
Current AutoLevel “Z” correction – value from the grid interpolator. When the AutoLevel function is disabled, the correction value = 0.
⚠️ Notes
- The AutoLevel function operates transparently on the CSMIO/IP controller side. This means you will not see the Z-axis value change on the screen as the correction changes. Parameter #9101 is used to monitor the correction value; it is used in the program’s default interface. If a custom interface project is used, you can add a widget displaying the correction. Widget input: “Machine Param” and set number #9101.
- The AutoLevel function does not limit axis speed/acceleration. By design, it is intended to introduce minor corrections for surface imperfections. Setting up a grid with significant height differences between points may cause Z-axis speed/acceleration limits to be exceeded and, in extreme cases, result in a PID controller error on the Z axis. Appropriate data verification, e.g., after scanning, should be performed by the Python script before calling d.setAutoLevelingGridData.
- The AutoLevel function operates in machine coordinates, so changing the work offset/workpiece zero does not shift the point grid. For that purpose, use the d.setAutoLevelingOrigin function.



