# polyCube, works finefor x in range(10): grp = pm.group(em=True) t = pm.polySphere(n='test', ch=False)[0] pm.parent(t, grp)
# Error: MayaNodeError: Maya Node does not exist (or is not unique):: u'test'for x in range(10): grp = pm.group(em=True) t = pm.spaceLocator(n='test') pm.parent(t, grp)
# workaroundfor x in range(10): grp = pm.group(em=True) t = pm.spaceLocator() pm.parent(t, grp) t.rename('test')
i show my code, and you can find differentiation.
i think you should not set name when you create object(locator)
import pymel.core as pm
for x in range(10):
grp = pm.group(em=True)
t = pm.polySphere(n='test', ch=False)[0
]
t.setParent(grp)
for x in range(10):
grp = pm.group(em=True
)
loc = pm.spaceLocator()
loc.rename('test')
Good luck.
--
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/777f2425-3929-4364-a42e-594e1bb9bf94%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
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_m...@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.
Well, as a quirk, it’s interesting (and odd), but as for a solution, I’d mirror what Chris is saying about simply using unique names, and not rely on the (apparently obscure) auto-naming feature of Maya for anything going into production.
Something like this should do it.
for x in range(10):
grp = pm.group(em=True
)
t = pm.spaceLocator(n='test_%s' % x)
pm.parent(t, grp)
But surely (hopefully) you’ve got better intentions that to use test
and an arbitrary number as object name. But that’s just me. :)
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)
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAHUba0KynD8USgVOKg6ohOx8c7EA0WXfHccDRt%3Dd5kgWbLY0%2Bg%40mail.gmail.com.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@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.
--
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+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/7d8478c4-33e5-4e5b-a93d-013c0a245bcc%40googlegroups.com.To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
import maya.cmds
def safeSpaceLocator(*args, **kwargs):
""" Wrapper around spaceLocator command since it doesn't return unique names correctly if name argument is provided """
maya.cmds.spaceLocator(*args, **kwargs)
return maya.cmds.ls(sl=1)
print maya.cmds.createNode('locator', name='test')
import maya.cmds
def safeSpaceLocator(*args, **kwargs):
createKwargs = {}
name = kwargs.pop('name', kwargs.pop('n', None))
if name is not None:
createKwargs['name'] = name
locator = maya.cmds.createNode('locator', **createKwargs)
if args or kwargs:
maya.cmds.spaceLocator(locator, e=1, *args, **kwargs)
return [locator]
for x in range(2): jnt_list = [pm.joint(p=p) for p in [(0,0,0), (5,5,0), (10,0,0)]] ik_handle, eff = pm.ikHandle(sj=jnt_list[0], ee=jnt_list[-1], name='test_ik#') grp = pm.group(em=True) pm.parent(jnt_list[0], ik_handle, grp) pm.select(deselect=True)