Another approach is to at the "#" into your naming schema. this will
increment to the next unique number for that name.
then the name will not have a collision with other objects in your scene

for x in range(10):
    grp = pm.group(em=True)
    t = pm.spaceLocator(n='*test#*')  # add the pound symbol to get
next unique number.
    pm.parent(t, grp)



On Thu, Mar 5, 2015 at 10:52 AM, Chris Lesage <chris.g.les...@gmail.com>
wrote:

> Oh sorry, that was your workaround. :)
>
> On Thu, Mar 5, 2015 at 7:51 PM, Chris Lesage <chris.g.les...@gmail.com>
> wrote:
>
>> It's because when there are more than one nodes that have the same
>> non-unique name, Maya sees them as this:
>>
>> |group1|test
>> |group2|test
>> |group3|test
>>
>> So it can't find "test" anymore. Even though you are casting it as a
>> variable, there is some bug. This bug only seems to occur for locators.
>>
>> Is there a reason you aren't using unique names?
>>
>> If you do need non-unique names, then this works: Rename the locator
>> after creation.
>>
>> for x in range(10):
>> grp = pm.group(em=True)
>> t = pm.spaceLocator()
>> pm.rename(t, 'test')
>> pm.parent(t, grp)
>>
>>
>> On Thu, Mar 5, 2015 at 6:37 PM, Marcus Ottosson <konstrukt...@gmail.com>
>> wrote:
>>
>>> I had a good look at this, and it looks to be quite the interesting
>>> quirk. :)
>>>
>>> Here’s the same problem in maya.cmds.
>>>
>>> from maya import cmds
>>> for x in range(2):
>>>     grp = cmds.group(em=True)
>>>     t = cmds.polySphere(n='test')[0]
>>>     assert isinstance(grp, unicode)
>>>     assert isinstance(t, unicode)
>>>     cmds.parent(t, grp)
>>>
>>> Merely replacing polySphere with spaceLocator causes the error for me
>>> in Maya 2015, and I have no idea why.
>>>
>>> Good find!
>>> ​
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Python Programming for Autodesk Maya" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to python_inside_maya+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODHPmSgwZkj-uh8%3DswwjnZjL9jR8wXXu0EvsEbXRXwp9Q%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODHPmSgwZkj-uh8%3DswwjnZjL9jR8wXXu0EvsEbXRXwp9Q%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to python_inside_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAHUba0KynD8USgVOKg6ohOx8c7EA0WXfHccDRt%3Dd5kgWbLY0%2Bg%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAHUba0KynD8USgVOKg6ohOx8c7EA0WXfHccDRt%3Dd5kgWbLY0%2Bg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CABPXW4iOuL%3DFZ05t6gqHyZaNsAjqRHLLAb-LhE8fSFycB3-9FQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to