I’ve been requested by some animators to write a quick script that will take a selection of an existing heirarchy, and for each object in the selection, unlink it from both its parents and children, copy the skin modifier, reset the transforms, re-apply the skin, and the relink it into its original heirarchy.
I'm having trouble with the entire model shifting out of its original position in the reset transform operations.. Here's my Xform-reset code. obj is the object in the selection currently being worked on after it has been unlinked from its parents and children...
ntm = obj.transform obj.transform = transMatrix obj.pos piv = obj.objecttransform * inverse obj.transform obj.objectoffsetPos = [0,0,0] obj.objectoffsetRot = (quat 0 0 0 1) obj.objectoffsetScale = [1,1,1] ntm.translation=[0,0,0] ntm = piv * ntm xformMod = xform() addmodifier obj xformMod xformMod.gizmo.transform = ntm
Is there another (or perhaps more efficient) way to thoroughly reset the transforms? Am I performing the XForm reset completely incorrectly? What else might be causing the objects to shift?
Thanks in advance!