I forgot to include the part that actually answered your question about then removing from a list:
char_list = [c1, c2, mainChar] main_chars = [char for char in char_list if not isSubCharacter(char)] print main_chars # [u'parentCharacter'] On Tue, Jun 19, 2012 at 4:04 PM, Justin Israel <[email protected]>wrote: > characters derive from sets, and sets make use of connections between > nodes to establish membership. So you should be able to use listConnections > to determine if a set has a parent. > > Assuming your "main" character means a root level character, and "sub" > characters are simply characters of a character... > > c1 = cmds.character() > c2 = cmds.character() > mainChar = cmds.character( c1, c2, n='parentCharacter' ) > > cmds.listConnections(c1, s=False, d=True, type='character', > exactType=True) > # Result: [u'parentCharacter'] # > > I used exactType=True since it could also technically match an objectSet > being a parent, since character derives a set type. > > So you could simplify a test like this: > > def isSubCharacter(char): > return bool(cmds.listConnections(char, s=False, d=True, > type='character', exactType=True)) > > print isSubCharacter(c1) > # True > > On Tue, Jun 19, 2012 at 3:03 PM, David Alvarez <[email protected]> wrote: > >> Hi guys I'm trying to discard subcharacters sets from the a list, I tried >> through listrelatives command but they don't seem to be related to the main >> characters sets, so I don't know if there is an easy way to distinguish >> main characters from the subcharacters. >> I would really appreciate any help... >> >> Thanks in advance. >> >> -- >> view archives: http://groups.google.com/group/python_inside_maya >> change your subscription settings: >> http://groups.google.com/group/python_inside_maya/subscribe >> > > -- view archives: http://groups.google.com/group/python_inside_maya change your subscription settings: http://groups.google.com/group/python_inside_maya/subscribe
