Commandservice

From The Foundry MODO SDK wiki
Jump to: navigation, search

commandservice

querying the commandservice Script query interface reveals three root attributes and two attribute groups:

  • commands
  • command.???
  • categories
  • category.???
  • currentExecDepth

commands

commands requires no selection. It simply returns a full list of all available commands.

Specific categories of commands can be obtained using the "categories" and "category" attributes.

commands

Get a list of all available commands

Datatype: string

Example:

query commandservice commands ?

Result:
[list of all commands]

command.???

command.??? attributes are used to obtain information about specific commands. These all require that a specific command be selected by providing its internal name as the fourth argument to query.

As these are queries against prototype commands (as opposed to instanced commands with their arguments set), these cannot provide dynamic states that would be otherwise modified by the argument values or environment.

command.username

Get a command’s human-readable name.

Datatype: string

Example:

query commandservice command.username ? poly.setMaterial

Result:
Set Material


command.desc

Get a command’s description, which provides a string describing how to use the command.

Datatype: string

Example:

query commandservice command.desc ? poly.setMaterial

Result:
Assign a new or existing material to the selected polygons.


command.usage

Get a usage string, similar to that saved by cmds.saveList.

Datatype: string

Example:

query commandservice command.usage ? poly.setMaterial

Result:
poly.setMaterial name:string <color:percent3> <diffuse:percent> <specular:percent> <smoothing:integer> <default:integer>


command.example

An example of how the command and its arguments are used.

Datatype: string

Example:

query commandservice command.example ? select.typeFrom

Result:
select.typeFrom "vertex;edge;polygon;item" 1


command.tooltip

The default tooltip shown when the user hovers the mouse pointer over a button on the interface.

Datatype: string

Example:

query commandservice command.tooltip ? app.load

Result:
Open file


command.help

The URL to the specific help for this file, if available, relative to the help directory.

Datatype: string

Example:

query commandservice command.help ? poly.boolean

Result:
pages/Boolean.html ----

command.icon

Get the name of the default icon for the command. Often this will simply be the name of the command. This name is used to look up the icon in the config, which references a rectangular region within an image.

Datatype: string

Example:

query commandservice command.icon ? poly.boolean

Result:
poly.boolean


command.flags

Get the command’s default flags. See Appendix A.1 for a list of flags. note that the flags may change at execution time depending on the values of the arguments.

Datatype: integer  Example:

query commandservice command.flags ? poly.boolean

Result:
6291456 [in hexadecimal, this is: 0x00600000]


command.toggleArg

Index of the toggle argument, if available. See the section on Command Arguments earlier in this guide for more information on ToggleValue commands. Indices start from 0.

Datatype: integer

Example:

query commandservice command.toggleArg ? tool.set

Result:
1


command.argNames

Internal names of all of the command’s arguments. These can be used to set the value of an argument by name, with the syntax name:value. See the section on Command Arguments earlier in this guide for more information on using named arguments.

Datatype: string

Example:

query commandservice command.argNames ? tool.set

Result:
preset
mode
task


command.argUsernames

Human-readable names of all of the command’s arguments. These are presented in the command arguments dialog instead of the internal names.

Datatype: string

Example:

query commandservice command.argUsernames ? tool.set

 Result:
Tool Preset
Tool Set Mode
Tool Task Value


command.argDescs

Descriptions of all of the command’s arguments.

Datatype: string

Example:

query commandservice command.argDescs ? tool.set

Result:
Name of the material.
Assign the material to the polygon.


command.argExamples

Examples of all of the command’s arguments.

Datatype: string

Example:

query commandservice command.argExamples ? material.new

Result:
[empty string; no example for argument 0]
[empty string; no example for argument 1]


command.argTypes

Simple type of all the arguments. This is 0 for generic objects, 1 for integers, 2 for floats an 3 for strings.

Datatype: integer

Example:

query commandservice command.argTypes ? poly.setMaterial

Result:
3
0
2
2
1


command.argTypeNames

Datatypes of all of the command’s arguments.  Datatype: string  Example:

query commandservice command.argTypeNames ? poly.setMaterial

Result:
string
percent3
percent
percent
integer
integer


command.argflags

Flags defining the argument. See Appendix A.2 below for more information.  Datatype: integer  Example:

query commandservice command.argFlags ? poly.setMaterial

Result:
0 [in hexadecimal, this is: 0x00000000]
1 [in hexadecimal, this is: 0x00000001]
1 [in hexadecimal, this is: 0x00000001]
1 [in hexadecimal, this is: 0x00000001]
1 [in hexadecimal, this is: 0x00000001]


command.isAlias

Returns 1 if the command is an alias. See the section above on Command Aliases for more information.

Datatype: integer

Example:

query commandservice command.isAlias ? material.name

Result:
0

categories

categories requires no selection. It simply returns a full list of all root-level command categories. Specific categories and commands within can be obtained using the category.??? attributes.

There are three special command categories: Containers contains all command containers, Uncategorized contains commands not in any other categories, and All contains every command.

categories

Get a list of all root-level command categories.

Datatype: string

Example:

query commandservice commands ?

Result: [list of all root-level command categories]

category.???

category.??? attributes are used to get a list of categories or commands within a category.

Categories may contain sub-categories as well as commands.

All of the category.??? attributes take the category name as the query selector argument.

category.categories

Get a list of sub-categories within a category.

Datatype:

string

Example:

query commandservice category.categories ? "Command System"

Result:

[list of all categories inside the Command System category]


category.commands

Get a list of commands within a category.

Datatype: string

Example:

query commandservice category.commands ? Macros

Result:

[list of all commands inside the Macros category]

currentExecDepth

This attribute returns the current execution depth of a command. This can be used to tell if a command is being executed as a root-level command or a sub-command.

If no commands are currently executing, this will be –1, while root-level command executions will return 0, and sub-command executions will be 1 or higher.

Note that the value only changes when ommands execute, not when they are queried; thus, using the query example below will return –1 when executed as a root-level command.

Similarly, querying this attribute from within a script will return the execution depth of the script, not the depth of the query command, as it is not executing.