fusion_addin_framework.AddinCommand

class fusion_addin_framework.AddinCommand(parent: Optional[Union[fusion_addin_framework.wrapper.Control, List[fusion_addin_framework.wrapper.Control]]] = None, id: str = 'random', name: str = 'random', resourceFolder: Union[str, pathlib.Path] = 'lightbulb', tooltip: str = '', toolClipFileName: Optional[Union[str, pathlib.Path]] = None, isEnabled: bool = True, isVisible: bool = True, isChecked: bool = True, listControlDisplayType: int = adsk.core.ListControlDisplayTypes.RadioButtonlistType, **eventHandlers: Callable)

Wraps around Fusions CommandDefinition object and its ControlDefintion attribute. Besides the documented attributes and methods on this page all attributes and methods of the wrapped classes can be accessed with the same attribute and method names as in the wrapped classes. The atributes of the commandDefintion object will be looked up first.

This class does NOT wrap around Fusions Command class. (Thats why its called ‘AddinCommand’ and not ‘Command’ only.)

If an Id of an existing CommandDefintion is provided, all parameters except parent and id will be ignored.

This class also encapsulates the concepts of the event handlers of the Fusion API. Using this class you do not need to connect a handler to the created event of the commandDefintion. Instead of connecting handlers, you simply pass a function as an arguments to this wrapper class. The argument name must correspond to a event name of Fusions Command class or ‘commandCreated’ for the commandCreatedEventHandler. The passed function will get executed as the notify method of the corresponding handler. Also the same argument will get passed to this function (e.g. CommandCreatedEventArgs for a function passed to the argument onCommandCreated). Therfore the signature of the passed (notify-)functions must accept exactly one positional argument (which can be used within the fucntion).

See the example section for some use cases. Checking out the examples should make the concept od using function-arguments instead of handlers understandable in no time.

Parameters
  • parent (Union[Control, List[Control]], optional) – The parent Control this command is connected to. You can also pass a list of controls. In this case the same command/functionality getx connected to multiple controls. If a list of controls is passed you must ensure that all controls are of the same controlType and that all of them are in distinct panels. Defaults to a ComanndControl with the default properties.

  • id (str, optional) – The unique id of the commandDefintion with respect to all other existing commandDefintions. Defaults to a random id.

  • name (str, optional) – The visible name of the command as seen in the user interface. This will also be set as the name of the controlDefintione attribute. Defaults to a random name.

  • resourceFolder (Union[str, Path], optional) – Directory that contains any additional files associated with this command. These are typically the image files that will be used for a button and the HTML files for a tool clip or helps and tips. Alternatively you can provide the name of one of the available default images. Defaults to “lightbulb”.

  • tooltip (str, optional) – The tooltip string. This is always shown for commands. If the tooltip description and/or tool clip are also specified then the tooltip will progressively display more information as the user hovers the mouse over the control. Defaults to “”.

  • toolClipFileName (Union[str, Path], optional) – The full filename of the image file (PNG) used for the tool clip. The tooltip is always shown but as the user hovers over the control it will progressively display the tool clip along with the tooltip text. Alternatively you can provide the name of one of the available default images. Defaults to None (no toolclip image is used).

  • isEnabled (bool, optional) – Sets if this ControlDefinition is enabled or not. This has the effect of enabling and disabling any associated (parental) controls. Defaults to True.

  • isVisible (bool, optional) – Sets if this ControlDefinition is visible or not. This has the effect of making any associated (parental) controls visible or invisible in the user interface. Defaults to True.

  • isChecked (bool, optional) – Will be ignored if controlType of the parental Control is not ‘checkbox’. Sets whether the check box of the parental controlDefintions is checked. Changing this will result in changing any associated (parental) controls and will execute the associated command. Defaults to True.

  • listControlDisplayType (int, optional) – Will be ignored if the controlType of the paerntal Control is not ‘list’. Sets how the parental list control will be displayed; as a standard list, a list of check boxes, or a list of radio buttons. Possible Values can be found in the ListControlDisplayType enumerator. Defaults to RadioButtonListType (1).

  • **eventHandlers (Callable, optional) – The notify functions of the command handlers. All of these arguments are in the form “eventName”. Available events for which a Callable can be passed are: {activate, deactivate, destroy, execute, executePreview, inputChanged, keyDown, keyUp, mouseClick, mouseDoubleClick, mouseDown, mouseDrag, mouseDragBegin, MouseDragEnd, mouseMove, mouseUp, mouseWheel, preSelect, preSelectEnd, preSelectMouseMove, select, unselect, validateInputs, commandCreated}.

addParentControl(parentControl)

Adds an additional control for acticvating this command.

The control should be of the same control type as the other controls of this command.

Parameters

parent (Control) – The additional control for the command.

__getattr__(attr)

Tries to find the attribute in the commandDefintion object first and in the commandDefintion.controlDefintion object second on which this class is wrapped around. This will only get called if no attribute is found in the AddinCommand wrapper object itself.

Parameters

attr – The attribute name.

Returns

The attribute value.

Return type

Any

__setattr__(name, value)

Tries to set an attribute on the commandDefintion first and on the commandDefintion.controlDefintion object second on which this wrapper is wrapped around. If the attribute is not found it will be set on the wrapper object.

Parameters
  • name – The name of the attribute to set.

  • value – The value of the attribute to set.

Summary

Methods

addParentControl(parentControl)

Adds an additional control for acticvating this command.

Attributes

addin

The addin instance which manages this instance.

parent

The parent wrapper-instance of this wrapper-instance.

uiLevel

The level this instance is in the user interface hierachy.