Command System: Querying

From The Foundry MODO SDK wiki
Revision as of 21:05, 16 February 2012 by Jangell (Talk | contribs)

Jump to: navigation, search

Command arguments marked with a question mark can be queried. For example, the material.name command’s name argument can be queried for its value, returning the name of the selected materials. If multiple items are selected, multiple names are returned. Although multiple values can be returned by a query, only a single value can be set for a given argument.

Using the Command History’s Results Tab

Command History's Results tab, showing a disabled command, a failed command, a successful execution and a query.

The Results tab of the Command History shows the results of any command executed or queried from that viewport, including failures and any queried values. In the case of the material.name command, one name will show up under the command's row for each material that is selected. If no items were selected, the command is disabled and (none) is shown in the results list.

Performing a Query

To query a command, simply insert a ? in place of the value. Queries always return raw values without units, and any square brackets around the question mark are ignored. What kind of value is returned is determined by the argument’s datatype.

material.name ?
material.name name:?

Querying and the User Interface

The user interface makes heavy use of command queries through the Forms system. The forms system is managed through the Form Editor and the Forms Viewport. The Form Editor is a hierarchical tree of forms, where each form contains sub-forms and commands representing controls. The Forms Viewport uses these forms to display toolbars and properties sheets. Menus, pies and popovers are also created using the forms system.

Toggle/Tool Buttons

Every control in a form is a command. Commands without queries are simple buttons, such as the Cube tool:

tool.set prim.cube on

Because the Cube tool uses the ToggleValue command tool.set, a tool button is created. Similarly, the commands for Vertex, Polygon, Edge, Item and Material selections are also ToggleValue commands. The select.fromType command takes a list of selection types, which it tests to see if the first type in the list is the current one, and toggles that one on and off when the button is clicked.

select.fromType "vertex;polygon;edge;item;ptag" 1
select.fromType "polygon;vertex;edge;item;ptag" 1
select.fromType "edge;vertex;polygon;item;ptag" 1
select.fromType "item;vertex;polygon;edge;ptag" 1
select.fromType "ptag;vertex;polygon;edge;item" 1

When put into menus, those same commands are interpreted as checkmark menu items.