CommandDefinitions.addButtonDefinition Method

Parent Object: CommandDefinitions
Defined in namespace "adsk::core" and the header file is <Core/UserInterface/CommandDefinitions.h>

Description

Creates a new command definition that can be used to create a button control and handle the response when the button is clicked.

Syntax

"commandDefinitions_var" is a variable referencing a CommandDefinitions object.
# Uses no optional arguments.
returnValue = commandDefinitions_var.addButtonDefinition(id, name, tooltip)

# Uses optional arguments.
returnValue = commandDefinitions_var.addButtonDefinition(id, name, tooltip, resourceFolder)
"commandDefinitions_var" is a variable referencing a CommandDefinitions object.

#include <Core/UserInterface/CommandDefinitions.h>

// Uses no optional arguments.
returnValue = commandDefinitions_var->addButtonDefinition(id, name, tooltip);

// Uses optional arguments.
returnValue = commandDefinitions_var->addButtonDefinition(id, name, tooltip, resourceFolder);

Return Value

Type Description
CommandDefinition Returns the created CommandDefinition object or null if the creation failed.

Parameters

Name Type Description
id string The unique identifier for this command definition. It must be unique with respect to all other command definitions and is limited to the following set of characters, [A-Z][a-z][0-9] and _.
name string The name displayed in the UI for the associated button control.
tooltip string The full description of the command as seen in the extended tooltip in the user interface. Using the returned CommandDefinition you can also optionally set the toolClipFilename property to show an image the extended tooltip.

The width of all tooltips is limited to 300 pixels. Word wrapping is enabled, so Fusion will automatically break the line and flow your text to the next line. However, if you include a long word that exceeds 300 pixels, it doesn't wrap and the right portion will be clipped. This is common when displaying paths or URL's. If a single word is longer than 300 pixels there are a couple of options to avoid the clipping.

The first option is to insert one or more zero width space characters within the word to define where the word should be broken. The UNICODE character '\u200b' defines a zero width space. This is not displayed is only used to designate a possible break point.

The second option is to shorten the word by removing a section. For example, if the word is a full path to a file and a portion of the path is common you can remove that portion and replace it with the ellipsis character to indicate there is some missing text. There is a single UNICODE character you can use the ellipsis. It is '\u2026'.
resourceFolder string Specifies the folder where the resources for this command are located. These are various sizes and styles of PNG files that are used for the button image. To fully support all potential options you should create files with the following names and sizes: 16x16.png , 32x32.png, 64x64.png (used for high-res displays), 16x16-dark.png, 32x32-dark.png, 64x64-dark.png The dark images are used when the command is highlighted and can contain lighter lines to contrast better with the blue highlighting. If you don't provide dark images Fusion will use the regular images when highlighting the button.

This is an optional argument and if not provided a default icon will be used.

This is an optional argument whose default value is "".

Samples

Name Description
Command Inputs API Sample

Creates a command dialog that demonstrates all of the available command inputs.

To use the sample, create a new Python or C++ script and copy and paste this code, replacing the default code. You also need to unpack this zip file which contains a resource folder into the same folder where the source code file (.py or .cpp) is.

Selection Events API Sample The sample demos how to use selection events of a command.

Version

Introduced in version August 2014