ScriptQuery Interface 701 Updates

This article includes updates to the SQ interfaces, mostly so that we remember to add them to the SDK wiki when 701 ships. Where possible, most of these sections should be able to be dropped right into the SDK wiki. Thus seemingly broken links to other pages may in fact be to valid pages in the SDK wiki.

CommandService

{{SQAttributeTable |command.category|Get the path of the category that the command belongs to. The username of each component of the path can be resolved with MessageService Reference for more information on using these message tables. |string |query commandservice command.category ? attr.formPopover |’’attr/display’’ }}

{{SQAttributeTable |command.argArgTypes|Get the Argument Types]] associated with each of the command’s arguments. Argument types can be resolved into usernames and descriptions through [[MessageService Reference’s argtype and argtypeoption attributes. Arguments that don’t use argument types have empty strings in their place. |string |query commandservice command.argArgTypes ? select.item |’’ select-mode ‘’ }}

MessageService

NOTE: Also update Argument Types]] to point to [[MessageService Reference on the SDK wiki.

In modo 701, ‘’msgfind’’, msgsub and msgcompose have been renamed to ‘’msg.find’’, msg.sub and msg.compose for clarity. The old attribute names still work in order to avoid breaking old scripts.

Argument Types

In this context, ‘’argument types’’ provide user names for command arguments that use TextValueHints]] when they are presented in popups. This is done automatically by the [[Command System, but it is also possible to directly read out these user strings through this service.

Argument types each have their own usernames and descriptions, which are read with the argtype attributes. Each option also has its own username and description, which is obtained with the argtypeoption attributes.

argtype Attributes

The argtype attributes are used to get the username and description of the argument type itself. The selector is the name of the argument type, usually obtained from a TextValueHint or a command.

{{SQAttributeTable |argtype.username|Get the username of an argument type. |string |query messageservice argtype.username ? select-mode |’’Selection Mode Specifier’’ }}

{{SQAttributeTable |argtype.desc|Get the description of an argument type. |string |query messageservice argtype.desc ? select-mode |’’Modes modify selection commands to perform different actions.’’ }}

argtypeoptions Attributes

The argtypeoptions attributes are used to get the username and description of a single option in an argument type. An argument type must have been previously “selected” with an argtype attribute. The selector is the internal name of the option, and is usually an entry from a TextValueHint.

{{SQAttributeTable |argtypoptione.username|Get the description of an argument type option. |string |query messageservice argtypeoption.username ? set |’’Set’’ }}

{{SQAttributeTable |argtypoptione.desc|Get the description of an argument type option. |string |query messageservice argtypeoption.desc ? set |’’The element becomes the primary selected element.’’ }}

SceneService

New Item Queries

These new queries apply to all item types, so <item> could be ‘mesh’ or ‘locator’ or any item query or type.

{{SQAttributeTable |<item>.isDeformer|Is item a deformer type. |integer |query sceneservice <item>.isDeformer ? |Check whether item type is a deformer }}

{{SQAttributeTable |<item>.deformers|Get list of deformers and influences. |string |query sceneservice <item>.deformers ? |Return a list of deformers applied to the item (typically a mesh or locator). For deformers, this query returns the deformer hierarchy. }}

{{SQAttributeTable |<item>.groups|List of groups item is a member of |string |query sceneservice <item>.groups ? |Return a list of all the group items in which the current item is a member. }}

Group Queries

Groups of different types are used to organize render passes, actors, assemblies, shaders, presets, and more. They can be queried like other items using the ‘group’ query. Type-specific group queries have also been added, so all the actor groups, for example, can be listed and queried as if they were their own item type. For these queries, the .current query does not take a type, but returns the current group of that type. These queries specific to groups have been added:

{{SQAttributeTable |group.types|List of group types available |string |query sceneservice group.types ? |Return a list of all the group types available. Use these types for the group.current query. this overrides the standard types query for items. }}

{{SQAttributeTable |group.current|Return current group of given type, if any. |string |query sceneservice group.current ? <type> |Return the current group of the given type. Use a value for <type> from the group.types query }}

{{SQAttributeTable |group.isCurrent|Is this group ‘current’. |integer |query sceneservice group.isCurrent ? |Check the this group is the ‘current’ (active, user-selected) group. }}

{{SQAttributeTable |group.itemMembers|Members of this group’s item graph. |string |query sceneservice group.itemMembers ? |Return the list of members of this group’s item graph. }}

{{SQAttributeTable |group.chanMembers|Members of this group’s channel graph. |string |query sceneservice group.chanMembers ? |Return the list of members of this group’s channel graph in the form <item>:<channel index>. }}

{{SQAttributeTable |pass.current|Return current render pass group, if any. |string |query sceneservice pass.current ? <type> |Return the current render pass group. }}

{{SQAttributeTable |pass.isCurrent|Is this group ‘current’. |integer |query sceneservice pass.isCurrent ? |Check the this group is the ‘current’ (active, user-selected) group. }}

{{SQAttributeTable |pass.itemMembers|Members of this group’s item graph. |string |query sceneservice pass.itemMembers ? |Return the list of members of this group’s item graph. Pass items should be actionClip type items which can be queried using the actionItem queries. }}

{{SQAttributeTable |pass.chanMembers|Members of this group’s channel graph. |string |query sceneservice pass.chanMembers ? |Return the list of members of this group’s channel graph in the form <item>:<channel index>. }}

{{SQAttributeTable |actor.current|Return current actor group, if any. |string |query sceneservice actor.current ? <type> |Return the current render pass group. }}

{{SQAttributeTable |actor.isCurrent|Is this group ‘current’. |integer |query sceneservice actor.isCurrent ? |Check the this group is the ‘current’ (active, user-selected) group. }}

{{SQAttributeTable |actor.itemMembers|Members of this group’s item graph. |string |query sceneservice actor.itemMembers ? |Return the list of members of this group’s item graph. }}

{{SQAttributeTable |actor.chanMembers|Members of this group’s channel graph. |string |query sceneservice actor.chanMembers ? |Return the list of members of this group’s channel graph in the form <item>:<channel name>. }}

ActionItem Queries

ActionItem queries provide special queries for items of type ‘actionClip’. The ‘actionClip’ query functions as a normal item query for these items, so a different query name, ‘actionItem’, is needed for specialized results. Action clips contain lists of items and channels which store settings for things like render passes and poses. Use these queries on them:

{{SQAttributeTable |actionItem.N|Number of actionClips available |string |query sceneservice actionItem.N ? |Return the number of all the actionItems. }}

{{SQAttributeTable |actionItem.name|Return name of item. |string |query sceneservice actionItem.name ? <item> |Return the name of the current item. }}

{{SQAttributeTable |actionItem.name|Return name of item. |string |query sceneservice actionItem.name ? <item> |Return the name of the current item. }}

{{SQAttributeTable |actionItem.id|Return id of item. |string |query sceneservice actionItem.id ? <item> |Return the id of the current item. }}

{{SQAttributeTable |actionItem.type|Return type of item. |string |query sceneservice actionItem.type ? <item> |Return the action type (pose or clip) of the current item. }}

{{SQAttributeTable |actionItem.items|Return the list of items in the current action item. |string |query sceneservice actionItem.items ? <item> |Return the list of items in the current action item. }}

{{SQAttributeTable |actionItem.channels|Return the list of channels in the current action item. |string |query sceneservice actionItem.channels ? <item> |Return the list of channels in the current action item. Channels are returned in the form <itemId>:<channelName> }}

{{SQAttributeTable |actionItem.chanValue|Return value of channel. |string |query sceneservice actionItem.chanValue ? <itemId>:<channelName> |Return value of given channel. }}

{{SQAttributeTable |actionItem.group|Return group containing current action item. |string |query sceneservice actionItem.group ? <item> |Return group containing current action item. }}

Here’s a short example of these queries in action:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# python
n = lx.eval('query sceneservice group.N ? ""')
for i in range(n):  # enumerate ALL groups in scene
        g = lx.eval('query sceneservice group.name ? %d' % i)
        t = lx.eval('query sceneservice group.type ? %d' % i)
        lx.out('%d: "%s"  %s' % (i, g, t))

types = lx.evalN('query sceneservice group.types ?')
for t in types: # enumerate types in scene then elements in current group of each type
        g = lx.eval('query sceneservice group.current ? %s' % t)
        lx.out('Current %s Group: %s' % (t, g))
        if (g != None):
                nm = lx.eval('query sceneservice group.name ? %s' % g)
                lx.out('Current %s Group: %s %s' % (t, g, nm))
                mems = lx.evalN('query sceneservice group.itemMembers ? %s' % g)
                for m in mems:
                        t = lx.eval('query sceneservice item.type ? %s' % m)
                        lx.out('      item --> %s (%s)' % (m,t))
                mems = lx.evalN('query sceneservice group.chanMembers ? %s' % g)
                for m in mems:
                        lx.out('      channel --> %s' % (m))

n = lx.eval('query sceneservice actionItem.N ? ""')
for i in range(n):  # enumerate ALL actionclips in scene
        g = lx.eval('query sceneservice actionItem.name ? %d' % i)
        p = lx.eval('query sceneservice actionItem.group ? %d' % i)
        s = lx.eval('query sceneservice actionItem.type ? %d' % i)
        chns = lx.evalN('query sceneservice actionItem.channels ? %d' % i)
        for c in chns:
                t = lx.eval('query sceneservice actionItem.chanValue ? "%s"' % c)
                lx.out('%d: "%s of %s: %s" %s = %s' % (i, g,p,s, c, t))

Graph Queries

Graphs are used to build and store connections between items and/or channels. For example the scene parenting hierarchy is stored in the ‘parent’ graph. Graph queries work on the current sceneservice item and scene. If an item is part of a graph it will have a link to another item (or channel). This is a forward link. that other item will have a link back to the original item. That is the reverse link. The forward and reverse links for an item are stored in separate lists which you can query to determine a graph’s structure.

{{SQAttributeTable |graph.N|Get the number of graphs in scene. |integer |query sceneservice graph.N ? |Number of graphs in scene }} {{SQAttributeTable |graph.name|Get the name of a graph. |string |query sceneservice graph.name ? i |Name of graph i }}

{{SQAttributeTable |graph.type|Get the type of a graph. |string |query sceneservice graph.type ? i |Type of graph i, either “item” or “channel” }}

{{SQAttributeTable |graph.flags|Get the flags for a graph. |integer |query sceneservice graph.flags ? i |Flags for graph i }}

{{SQAttributeTable |graph|Get the possible graph queries. |string |query sceneservice graph ? |”graph.N, graph.name, graph.type,graph.flags” }}

Here’s a small example that exercises the graph queries:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# python
n = lx.eval('query sceneservice graph.N ? ""')
for i in range(n):
        g = lx.eval('query sceneservice graph.name ? %d' % i)
        t = lx.eval('query sceneservice graph.type ? %d' % i)
        #lx.out('%d: "%s"  %s' % (i, g, t))


sel = [0,1]
# lx.evalN('query sceneservice mesh ?')
lx.out(sel)
for i in range(n):
        g = lx.eval('query sceneservice graph.name ? %d' % i)
        for item in sel:
                nm = lx.eval('query sceneservice item.name ? %d' % item)
                lx.out('%s:' % g)
                lx.out(' item %s linked to:\n' % nm)
                #t = lx.eval('query sceneservice graph.type ? parent')
                t = lx.eval('query sceneservice fwdLink.N ? ')
                for link in range(t):
                        fwd = lx.eval('query sceneservice fwdLink.item ? %d' % link)
                        lx.out('\t--> %s\n' % fwd)

lx.out('fini %d' % n)

Proxy Queries

Proxy item queries have also been extended with some convenient specific queries

{{SQAttributeTable |proxy.scene|Proxy reference scene path. |string |query sceneservice proxy.scene ? i |Get the file path for the proxy’s reference scene }}

{{SQAttributeTable |proxy.render|Proxy render item. |string |query sceneservice proxy.render ? i |Return the proxy’s render item }}

{{SQAttributeTable |proxy.preview|Proxy preview item. |string |query sceneservice proxy.preview ? i |Return the proxy’s preview item }}

{{SQAttributeTable |proxy.bounds|Proxy’s bounding box. |float |query sceneservice proxy.bounds ? i |Return the proxy’s bounding box in form ‘’{minX,minY,minZ,maxX,maxY,maxZ}’’ }}