I'm a little confused what you're looking for and what you are calling a
matrix.
if you want to get the translation of an object you can get that from a
globalMatrix as well as getTranslation.

but if you want to get the scale:
the docs say this for getMatrix:

*  Note that, when querying the scale, that this calculation is cumulative
and is only valid if there are all uniform scales and no rotation. In a*
*  hierarchy with non-uniform scale and rotation, this value may not
correspond entirely with the perceived global scale*.

One way you could do it is to go up the hierarchy and multiply the scale by
each parent's scale.
I'm sure there is a linear algebraic way of doing this, eterminant
multiplied by the inverseMatrix or some such. I dunno.
where is Chad Vernon when you need him?

but this kinda works even if there are rotations in the parents and
children. it won't "look" the same because of possible shearing but it will
get you what I think it is you're looking for.

import pymel.core as pmdef returnAncestors(node):
    """ returns a list of ancstors"""
    hierarchy = []
    while not node.getParent() == None:
        node = node.getParent()
        hierarchy.append(node)

    return hierarchy
          def retGlobalScale(node):
    """ returns a cumulative scale from transform hierarchy"""
    curScale = node.scale.get()
    for ancestor in returnAncestors(node):
        scale = ancestor.getScale()
        curScale = curScale * scale

    return curScale

#EXAMPLE USE OF A TRANSFORM IN A HIERARCHY OF DIFFERENT SCALES
scl = retGlobalScale(pm.selected()[0])

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CABPXW4g2N0CKndNsnh_pXVRokFFENeG1%3D7h2MTHQ5HSj8mG0Zg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to