Thanks Chris,

One of the reasons that I like to use PyMel is that when you create an 
object you get a reference to that object and you are not dependent of the 
name when you want to find the object. 

When I was doing MEL scripting I ran into this issue many times. As you now 
we can have multiple objects with the same name as long as they have unique 
dag paths. So if we have one object called test parented under grp1 ( 
'|grp1|test' ) and one object called test at the root level ( '|test' ) I 
could use '|test' to find the one at root level. This is also true if you 
use maya.cmds.

But since I am using PyMel in this case I got a bit surprised by this.

Yup, it seems like I will use the rename trick :)


On Thursday, March 5, 2015 at 7:52:21 PM UTC+1, Chris Lesage 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 <[email protected] 
> <javascript:>> 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 [email protected] <javascript:>.
>> 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/e5d757fe-2ed5-4f47-b87e-7b16a2c3a9f1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to