The class to create, define, and register command objects.

This is a singleton class that manages all command registration and lookup functionality. Commands are organized into groups, with system commands (ACAD) and user commands (USER) being the default groups.

const commandStack = AcEdCommandStack.instance;
commandStack.addCommand('USER', 'MYCOMMAND', 'MYCOMMAND', myCommandInstance);
const command = commandStack.lookupGlobalCmd('MYCOMMAND');

Properties

DEFAUT_COMMAND_GROUP_NAME: string = 'USER'

The name of the default user command group

SYSTEMT_COMMAND_GROUP_NAME: string = 'ACAD'

The name of the system command group

Accessors

Methods

  • Adds a command to the specified command group.

    Parameters

    • cmdGroupName: string

      The name of the command group. If empty, uses the default group.

    • cmdGlobalName: string

      The global (untranslated) name of the command. Must be unique within the group.

    • cmdLocalName: string

      The local (translated) name of the command. Defaults to global name if empty.

    • cmd: AcEdCommand

      The command object to add to the stack.

    Returns void

    When the global name is empty or when a command with the same name already exists

    commandStack.addCommand('USER', 'LINE', 'ligne', new LineCommand());
    
  • Return an iterator that can be used to traverse all of command objects in this command stack (that is, the iterator iterates through all commands in all groups).

    Returns AcEdCommandIterator

    Return an iterator that can be used to traverse all of command objects in this command stack.

  • Search through all of the global and untranslated names in all of the command groups in the command stack starting at the top of the stack trying to find a match with cmdName. If a match is found, the matched AcEdCommand object is returned. Otherwise undefined is returned to indicate that the command could not be found. If more than one command of the same name is present in the command stack (that is, in separate command groups), then the first one found is used.

    Parameters

    • cmdName: string

      Input the command name to search for

    Returns undefined | AcEdCommand

    Return the matched AcEdCommand object if a match is found. Otherwise, return undefined.

  • Search through all of the local and translated names in all of the command groups in the command stack starting at the top of the stack trying to find a match with cmdName. If a match is found, the matched AcEdCommand object is returned. Otherwise undefined is returned to indicate that the command could not be found. If more than one command of the same name is present in the command stack (that is, in separate command groups), then the first one found is used.

    Parameters

    • cmdName: string

      Input the command name to search for

    Returns undefined | AcEdCommand

    Return the matched AcEdCommand object if a match is found. Otherwise, return undefined.

  • Remove the command with the global and untranslated name cmdGlobalName from the cmdGroupName command group. Return true if successful. Return false if no command with the global and untranslated name cmdGlobalName is found in the cmdGroupName command group.

    Parameters

    • cmdGroupName: string

      Input the name of the command group containing the command to be removed

    • cmdGlobalName: string

      Input the command name which is to be removed from cmdGroupName

    Returns boolean

    Return true if successful. Return false if no command with the global and untranslated name cmdGlobalName is found in the cmdGroupName command group.

  • Remove the command group with the name GroupName from the command stack and delete the command group dictionary object and all the AcEdCommand objects stored within it.

    Parameters

    • groupName: string

      Input the name of the command group to be removed from the command stack.

    Returns boolean

    Return true if successful. Return false if no command group is found with the name GroupName.