cmd_get_name()

Retrieves the canonical command name corresponding to a given command ID.

Syntax

planetcnc.cmd_get_name(cmd_id)

Parameters

Parameter Type Description
cmd_id int The unique identifier of the command.

Return Value

Examples

#! /usr/bin/env python
 
import planetcnc
 
def list_all_commands():
    # Get the tuple of command names from the C module.
    cmds = planetcnc.cmd_list()
 
    if not isinstance(cmds, tuple):
        print("cmd_list did not return a tuple!")
        return
 
    # Enumerate over the tuple and call cmd_get_id for each command name.
    for name in cmds:
        try:
            cmd_id = planetcnc.cmd_get_id(name)
            cmd_name = planetcnc.cmd_get_name(cmd_id)
            cmd_displayname = planetcnc.cmd_get_displayname(cmd_id)
 
            print(f"Command '{name}', ID: {cmd_id}, Name: {cmd_name}, DisplayName: {cmd_displayname}")
 
        except Exception as e:
            print(f"Failed to get ID for command '{name}': {e}")
 
 
list_all_commands()

See also

cmd_list
cmd_count
cmd_get_id
cmd_get_name
cmd_get_displayname
cmd_is_enabled
cmd_is_checked
cmd_exec