0

I'm trying to query what animation layers are selected using Python.

MEL works fine:

treeView -query -selectItem ("AnimLayerTabanimLayerEditor")

However a similar Python command returns an error:

cmds.treeView(q=True, selectItem=[True, "AnimLayerTabanimLayerEditor"])

Error:

// Error: TypeError: file <maya console> line 1: Flag 'selectItem' must be passed a boolean argument when query flag is set //

The weird part is that selectItem asks for 2 arguments: a string, then a boolean (I've tried it in that order too). The MEL command works without a boolean (tried that in Python too).

john
  • 408
  • 9
  • 30
  • 1
    Try passing a tuple instead of a list for `selectItem`: `cmds.treeView(q=True, selectItem=(True, "AnimLayerTabanimLayerEditor"))` – Mad Physicist Nov 02 '15 at 16:54

1 Answers1

2

It looks like you forgot to invert the order: in python the first argument is the target of the command, and the keywords come after; in Mel the flags come first.

If you're querying you just want the query and selectItem flags both true in Python:

 selected = cmds.treeView (mytreeview, q=True, selectItem=True)

and setting looks like:

 cmds.treeView(mytreeview, e=True, selectItem = ('thingToSelect', True))
theodox
  • 12,028
  • 3
  • 23
  • 36