Execute actions in simCNC from a hardware button, wired into the CSMIO controller.
- Open the settings and navigate to PyActions
- Click „add“ to add a new action
- Give it a meaningful name
- Set event to „IO Change“
- Select a port from your CSMIO, MPG module or extension module. If the button is wired correctly, the LED will light up if you press the selected button.
- Press the document icon next to „script name“
- A popup will open. Add the code from the below section
- Press „save as“
This is the most simple setup possible for the task.
In this more complete example we will first check if the machine is in idle state (i.e. not in emergency stop), before we start GCode execution.
if ( d.getState( ) == State.Idle ) ): d.StartTrajectory()
- When testing your button, make sure that the machine is in idle state (i.e. connected). Otherwise the controller will not execute any action.