Hi everyone !!
I’m writing a simple script to check if my objects are frozen in maya.
The good thing is that it works, but I have a few questions to optimize it:
import pymel.core as pm
def checkFreeze():
nonFreezedList = []
transformNodes = pm.ls(exactType = "transform")
for x in transformNodes:
matrix = x.pm.get()
if str(matrix) != "[[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]":
nonFreezedList.append(x)
print nonFreezedList
print len(nonFreezedList)
This works properly, but I have a few questions :
- to check my matrix, I convert it to a string because I failed otherwise:
matrix = x.pm.get()
if str(matrix) != "[[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]":
Is there a cleaner way to do that?
- My second question is that I read in another script that it’s a bad idea to check all my transform nodes and that I should list all the parent nodes of my objects instead. I don’t really understand why (I want to freeze groups too and this doesn’t affect cameras).
Is there a simple way to get a nice name instead of something like:
[nt.Transform(u'group1'), nt.Transform(u'group2'), nt.Transform(u'pCube2'), nt.Transform(u'pCylinder1')]
- Lastly I use the
get()
function, but I tried thegetTransformations()
function from the transform class, and I get slightly different values when not frozen (otherwise it works)
Thanks !!!