Maya - 2 questions (channel box attributes and getting outliner contents)

Hey! Two Maya questions!

1)Can you display a string attribute in the channel box (not enum)? (so a user can type any string value in the channel box view, instead of going to the extra-attributes section of the Attribute Editor). It seems pretty much anything will display there EXCEPT for normal string attributes.

2)How can you get a list of what’s normally displayed in the Outliner. It seems like a simple command/flag would exist. (only list top node, dag, non-shapes.) Example: There’s a skeleton hierarchy and a mesh in a scene. Is there a simple way of getting those two objects? Thought there would be a flag like “ls(outliner = True)”, or am I missing something? Maybe there’s a good reason that flag doesn’t exist…

Thanks!

Not sure about the first one. need to fiddle around, but I think it’s probably a no.

the second one, you can just use select all, and refine your selection to transforms. select all grabs the top level transforms in your scene.

so:

import maya.cmds as cmds
cmds.select(all = True)
cmds.ls(selection = True, transforms = True)

and that should do it.

  1. Oh, now that you mention it, I wish I could do that too!
  2. You can’t say “what displays in the outliner” because you can change what the outliner shows. Also you can simplify jeremy’s line to get all transforms:
    cmds.ls(’*’, transforms = True)

[edit]: dag or dagObjects=True is a valid flag as well, but it returns shapes as well, which may or may not be what you want.

And those supposed diva antics? Well, those were apparently a bunch of nonsense as well. “There has been no drama and no diva demands,” TMZ states, citing one source familiar with the negotiations as saying that “It’s been typical negotiating.”

Well
answer of 2nd the second one, you can just use select all, and refine your selection to transforms. select all grabs the top level transforms in your scene.

so:

import maya.cmds as cmds
cmds.select(all = True)
cmds.ls(selection = True, transforms = True)

and that should do it.
Thanks.

you really don’t need to select everything, also, those solutions will get all transforms, not just top level ones.

import pymel.core as pmc
nodes  = []
xforms = pmc.ls(typ='transform')
for node in xforms:
    if not node.getParent():
        nodes.append(node)

[node for node in pmc.ls(type=‘transform’) if not node.getParent()]
or
filter(lambda node: not node.getParent(), pmc.ls(type=‘transform’)

Comon, Tyler, write code like a man!

lol, oh the trolling.

Look at rob getting all pythonic! what’s wrong with c#ish code?!?!!? :wink:

once you go py…

Actually the syntax is far better in C#:
pmc.ls(type=‘transform’).Where(node => node.getParent != null)