API

API (Application Programming Interfaces) in the Extension Builder offer developers tools and functions to create custom scripts or automate tasks. They can be used to define methods and properties for interacting with the application's environment, manipulating data, and performing actions. They can enable developers to extend the functionality of their extensions, automate tasks, and build customized solutions.

You can look for existing APIs from the Script Editor and choose to incorporate them into the script by automatically adding the necessary import code.

Note that there are multiple ways for code to reference elements within Discovery, providing developers with a range of coding options. The following example code demonstrates several methods for referencing a Combo Box and a Tool.


ScriptApi.GetTool("myTool").ToolOptions[0]
ScriptApi.GetTool("myTool").ComboBoxes[0]
ScriptApi.GetTool("myTool").GetComboBox("myCombo")

ScriptApi.GetRibbonButton("myButton").Tool.ToolOptions[0]
ScriptApi.GetRibbonButton("myButton").Tool.ComboBoxes[0]
ScriptApi.GetRibbonButton("myButton").Tool.GetComboBox("myCombo")  
        

The tool options Text Box, Toggle, Color Palette, Slider, List Box, Combo Box, and Sub Options all have .Name, .Visible, and .Enabled properties.

The Text Box value can be a double, quantity, or string. It should be noted that the .GetQuantity property was added to facilitate intellisense, but it's not necessary. The Toggle control has a .Toggled property that's a boolean representing the toggle's state. The Slider control has .MaximumValue and .MinimumValue settings. The List Box and Combo Box tool options have two properties: .Value and .Items. .Value gets or sets the currently selected value, while .Items gets all the available values.