copy/paste Transform attributes into the Offset Parent Matrix
Hey everyone, could you help me with a script that copy/paste Transform attributes into the Offset Parent Matrix on selected object, and finally sets the Transform Attributes to zero? Thanks a lot. I tryed this, but it add values from parent Transforms to child. Thank you.
'''import maya.cmds as cmds
def copy_transform_to_offset_parent():
selected_objects = cmds.ls(selection=True)
translate = cmds.getAttr(obj + ".translate")[0]
rotate = cmds.getAttr(obj + ".rotate")[0]
scale = cmds.getAttr(obj + ".scale")[0]
transform_matrix = cmds.xform(obj, query=True, matrix=True, worldSpace=True)
cmds.setAttr(obj + ".offsetParentMatrix", transform_matrix, type="matrix")
cmds.setAttr(obj + ".translate", 0, 0, 0)
cmds.setAttr(obj + ".rotate", 0, 0, 0)
cmds.setAttr(obj + ".scale", 1, 1, 1)'''