Home Technical Talk

Maya issue with Naming

I have a Maya scripting problem for those willing to look into it for me!
I have 3 group nodes in my scene with relatively similarly named objects. When I call the list I created, it gives me names like "group|name" for the majority of all of the objects in the group node. I have one or two objects that don't use the "group|name" so they literally show up as "name". Unfortunately, I need all of these objects in my scene and the tool I am writing is "group|name" dependent.

Here is my code:

import pymel.core as pm

test = pm.ls(orderedSelection = 1)
for sel in test:
print(sel)

Replies

  • DireWolf
    Options
    Offline / Send Message
    s = pc.ls(orderedSelection=1)
    for i in range(len(s)):
    ____if '|' in str(s):
    ________s = str(s)
    ________continue
    ____temp = [str(s)]
    ____while pc.listRelatives(temp[0], p=1, f=1):
    ________temp.insert(0, str(pc.listRelatives(temp[0], p=1, f=1)[0]))
    ____s = '|'.join(temp)
    print s

    ug the formatting is gone. Replace underscore _ with space.

    A little note that you'll only get the full hierarchy when you ls only if the object name is not unique. I personally think it's a better idea, if you have the control, to name everything properly and don't allow them to clash to begin with.
  • StephenWongTA
    Options
    Offline / Send Message
    That did the trick DireWolf. The name clash is from having multiple similar models (the look is different) and need to have the same names when we bring them into UE4 so they can be interchangeable.
  • DireWolf
    Options
    Offline / Send Message
    Ah I see. Thanks for clarification!
  • passerby
    Options
    Offline / Send Message
    passerby polycounter lvl 12
    DireWolf use the Code tags next time they will keep the proper indentation
Sign In or Register to comment.