RuntimeError setAttr

1,263 views
Skip to first unread message

flaye

unread,
Oct 14, 2014, 10:24:09 PM10/14/14
to python_in...@googlegroups.com
I get this error, and haven't been able to find the source of it. Is it way Python interprets the numbers for Y & Z?


# RuntimeError: setAttr: Error reading data element number 1: [(24.1303752966691, 1.4210854715202004e-13, 5.329070518200751e-15)] #


Here's the method that generates it:


def FKstretch(self,limb,side,ctrlAttr,rigJnt,axis):
       
       
# create attribute
        mc
.addAttr(ctrlAttr,ln="stretch",at="double",min=0.1, max=3, dv=1,k=True)
        mc
.setAttr(ctrlAttr+".stretch")
       
       
# get primary axis length value
       
        jntLength
=mc.getAttr("{0}.t{1}".format(rigJnt,axis))
       
               
        setFkMdn
=mc.shadingNode("multiplyDivide", au=True,n="{0}_MDN".format(ctrlAttr))
        mc
.setAttr(setFkMdn+".operation",1) #set to multiply, just in case
        mc
.setAttr(setFkMdn+".input1X",jntLength)
       
        mc
.connectAttr(ctrlAttr+".stretch", setFkMdn+".input2X")
        mc
.connectAttr(setFkMdn+".outputX",rigJnt+".t{0}".format(axis))


The strange thing is that this method works perfectly fine when called by the legs joints, but not by the arms. The code is identical for both.

thanks

Justin Israel

unread,
Oct 15, 2014, 1:45:29 AM10/15/14
to python_in...@googlegroups.com
It would be great if you could identify which line actually produces this error.

--
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/da4bdd60-bb7c-4e98-bee7-ade06a63a58c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Eduardo Grana

unread,
Oct 15, 2014, 11:58:28 AM10/15/14
to python_in...@googlegroups.com
Hello Flaye,

Maybe you are trying to set a double3 type with this?
[(24.1303752966691, 1.4210854715202004e-13, 5.329070518200751e-15)]
If this is the case,
be aware, you have a list with a tuple inside, so you need something like
*[(24.1303752966691, 1.4210854715202004e-13, 5.329070518200751e-15)][0]

Hope this helps,
Eduardo




For more options, visit https://groups.google.com/d/optout.



--
Eduardo Graña
www.eduardograna.com.ar

flaye

unread,
Oct 15, 2014, 12:57:02 PM10/15/14
to python_in...@googlegroups.com
Justin: I believe the error returns on this line

mmc.setAttr(setFkMdn+".input1X",jntLength)


Eduardo: if the above is correct, I'll assume that the jntLength variable is the one getting the list. I tried adding the [0] at the end of it, but it returns a "TypeError: 'float" object has no attribute '__getitem__'

again, the odd thing is that it works perfectly well when it's the leg joints that need the stretch FK, but not the arms.

flaye

unread,
Oct 16, 2014, 1:06:10 AM10/16/14
to python_in...@googlegroups.com
I'm beginning to suspect this has to do with the joint setup of the bind skeleton. Only the translation on the primary joint orientation is supposed to show up, but I get the dreaded -0 values in the other two axis. It also does not update the code for finding the primary joint orientation axis

I'll update once I (hopefully) find the culprit.
Reply all
Reply to author
Forward
0 new messages