Hey,

Long story short: you are storing strings (the name of the node) in
the textfield.

Maya works because the setAttr expects a string.  Pymel works with
objects when doing object method calls.

Thus it is tellubg you the string you stored, a unicode object, does
not contain the methods you are attempting to utilize, and rightly so.

I do believe using the name as input to a PyNode will give you want
you desire:

for jnt in tmpJnts2Unlock:
    myNode = pm.PyNode(jnt)
    if jnt.hasAttr('liw'):

Something you may want to try, typicalling in python it is easier to
ask forgiveness than permission (duck-typing ftw!):

try:
   jnt.liw.get()
except:
    # I dont have an liw attribute....

Cheers

On May 11, 11:38 pm, PixelMuncher <[email protected]> wrote:
> I'm working on a joint locking tool for weight painting.
> It includes a UI which permits the user to type the names of the
> joints into a textfield or to create a list from a selection via a
> button.
>
> If a list is created via a button, I update the text field to list the
> selected joints.
> This allow the user to update the selection via keyboard while they
> are working.
>
> I convert the list of joints to their names, separated by spaces,
> before placing them into the textfield:
>
> numJnts = len(tmpJnts2Unlock)
> count = 1
> for jnt in tmpJnts2Unlock:
>         if count < numJnts:
>                 print ('if add jnt')
>                 tmpJntList += jnt.name() + ' '
>         else:
>                 print ('else add jnt')
>                 tmpJntList += jnt.name()
>         count += 1
> textField('jnt2Unlock', e = 1, text = tmpJntList)
>
> So far, so good.
> When its time to unlock the joints, I retrieve the list from the
> textfield, and at that point I can no longer access the attributes via
> PyMEL
>
> tmpJnts2UnlockString = textField('jnt2Unlock', query=True, text =
> True )
> tmpJnts2Unlock = tmpJnts2UnlockString.split(' ')
>
> for jnt in tmpJnts2Unlock:
>         if jnt.hasAttr('liw'):
> AttributeError: 'unicode' object has no attribute 'hasAttr' #
>
> or
> print tmpJnts2Unlock[0].name()
> AttributeError: 'unicode' object has no attribute 'name' #
>
> If I use maya.cmds, it works:
> if (cmds.attributeQuery( 'liw', node=jnt, exists = 1 ) ):
>         cmds.setAttr (jnt + '.liw', 0)
>
> Anyone know the fix?
> Thanks much.
>
> --http://groups.google.com/group/python_inside_maya

-- 
http://groups.google.com/group/python_inside_maya

Reply via email to