copy/paste Transform attributes into the Offset Parent Matrix

copy/paste Transform attributes into the Offset Parent Matrix

PSkala
Observer Observer
658 Views
0 Replies
Message 1 of 1

copy/paste Transform attributes into the Offset Parent Matrix

PSkala
Observer
Observer
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 too. 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)'''
0 Likes
659 Views
0 Replies
Replies (0)