cmd_exec()

Executes a command by parsing Python arguments and dispatching to the internal command execution system.

Syntax

planetcnc.cmd_exec(cmd_id)
planetcnc.cmd_exec(cmd_id, str)
planetcnc.cmd_exec(cmd_id, val)
planetcnc.cmd_exec(cmd_id, num, val)
planetcnc.cmd_exec(cmd_id, num, val, val2)

Parameters

Parameter Type Description
cmd_id int The unique identifier of the command.
val float Float value.
val2 float Float value.
num int Integer value.

Return Value

* True, if command was executes successfully, otherwise False.

Examples

#! /usr/bin/env python
 
import planetcnc
 
# Open file open dialog
id = planetcnc.cmd_get_id("File.Open_...")
if not planetcnc.cmd_exec(id):
    print("Failed to execute command")
#! /usr/bin/env python
 
import planetcnc
 
# Open G-Code
id = planetcnc.cmd_get_id("File.Open_Code")
if not planetcnc.cmd_exec(id, "G00 X0 Y0\nG01 X20 Y0\nG01 X20 Y20\nG01 X0 Y20\nG01 X0 Y0"):
    print("Failed to execute command")
#! /usr/bin/env python
 
import planetcnc
 
# Open camera window
id = planetcnc.cmd_get_id("Machine.Camera.Show")
if not planetcnc.cmd_exec(id, 10000):
    print("Failed to execute command")
#! /usr/bin/env python
 
import time
import planetcnc
 
# Set machine position 
id = planetcnc.cmd_get_id("Machine.Machine_Position.To_Value_...")
 
if not planetcnc.cmd_exec(id, 0, 10):
    print("Failed to execute command")
 
time.sleep(0.1)
if not planetcnc.cmd_exec(id, 1, 20):
    print("Failed to execute command")
 
time.sleep(0.1)
if not planetcnc.cmd_exec(id, 2, 30):
    print("Failed to execute command")

See also

cmd_list
cmd_count
cmd_get_id
cmd_get_name
cmd_get_displayname
cmd_is_enabled
cmd_is_checked
cmd_exec