[Maya development basic notes] Alternative method when offsetParentMatrix fails in Transform node

foreword

The water document is here, but as a beginner, I really feel uncomfortable if I really forget what I learn.
What is TAT? You can check the last three lines of the offsetParentMatrixprevious document .

  • Generally, a locator ( loc) is set to record the transformation behavior between parent and self, which is very practical for objects with strong hierarchical relationships such as bones. Now discuss two cases

When not expired

            if cmds.objExists(对象+'.offsetParentMatrix'):
                connectAttr(loc, 'matrix', 对象, 'offsetParentMatrix')

on failure

We will set an empty object and name it 对象+'_OFF_GRP'. OFF is the abbreviation of offset. In fact, this empty object is on the parent of the object, so it has the off suffix. In other words, it changes from the original 对象的parent-对象hierarchical relationship 对象的原parent-OFF_GRP-对象, with an additional transformation process in the middle.

                dcm = cmds.createNode('decomposeMatrix', name=loc+'_DCM')
                connectAttr(loc, 'matrix', dcm, 'inputMatrix')# relative to parent
                for attr in ['translate', 'rotate', 'scale']:
                    connectAttr(dcm,'output'+attr.title(), 对象+'_OFF_GRP', attr)

postscript

Digging a small hole:
About how to use scripts to create empty objects, I will add it later when I think about it. This is just an emergency note.
——20230407 stay

Guess you like

Origin blog.csdn.net/qq_43544518/article/details/130014670