PyMel Euler Rotation not saving

Hi, I’m having issues with euler rotation. I can’t figure out why my euler rotation is not saving inbetween for loop iterations.

bit of code:

The problem is that the print eulerVar returns [0.0, 0.0, 0.0] even though I just set its value. I’ve tried using eulerVar.setValue() function aswell, but still returns 0.

import pymel.core.datatypes as dt
eulerVar = dt.EulerRotation()

for letter in strArr:
if letter is “A”:
use eulerVar in another function.
elif letter is “B”:
eulerVar = dt.EulerRotation([45.0, 0.0, 0.0], unit=‘degrees’)
print eulerVar

The print eulerVar line returns [0.0, 0.0, 0.0] even though I just set its value. I’ve also tried using setValue() function but it returns 0 aswell.

If I just run this code, I get [45.0, 0.0, 0.0]

import pymel.core.datatypes as dt
eulerVar = dt.EulerRotation()

eulerVar = dt.EulerRotation([45.0, 0.0, 0.0], unit='degrees')
print eulerVar

So this might be some error in your if logic. What is strArr? You posted pseudo-code, so it is a bit hard to debug.

Also it seems you pasted your code with formatting, so it added smart-quotes and lost your indentation. To avoid this, you can use ctrl-shift-V or cmd-shift-V to paste without formatting. (Or maybe you used “quote” instead of “preformatted text”)

1 Like

strArr would be just any array of characters, such as “A1+FDBS-941”. That is basically the only thing I have not included in the code in my original post. I was inspired by your post though and switched the if statements “is” to “==”. I had forgotten that “is” compares identities and not values. “A” and “B” in the if statements are just generic characters that is compared with each letter in the array.