Lazy Animator tool..


#1

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!


#2

hiya

Would this be possible?

select the object so its in the modify panel
look for and disable ‘skin’ modifier
root=the base object underneath all the mods

root.AffectPivotPointOnly=true – here’s the kicker - does this exist? Anybody know?

reset the root.pivot point - I’m not sure how thats done, I’d like to see an example…
root.AffectPivotPointOnly=false
reactivate the ‘skin’ mod
repeat and rinse

Maldwyn


#3

Ok, it seems my transform reset code was not an issue at all, but more my lack of understanding how Skin works.

As previously stated, my animators want to be able to 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. However, when I do all of these steps, my skin weights are not correct.

Here’s a walk through of what the script does:

-Walk the selection, collecting all the objects that have skin on them, and then recording the bones associated with that skin modifier.
-Using Skin Utilites, I extract the skin data. This creates a “SkinData” copy of the original.
-I then delete the skin modifier from the stack.
-I then walk the selection again, testing each object for parent’s and children. I record both and de-link the object.
-the transform on the object is reset using resetXform()
-the stack is collapsed
-using the previously collected data, I re-link the object and all its children properly.
-I walk the list of object that had Skin on them
-and reset the xforms on the SkinData copies of the object
-and collapse the stack of the SKinData copies.
-a new skin modifier is added to the original object
-the list of bones are added to the modifier
-the original and its SkinData are selected and SkinUtils.ImportSkinDataNoDialog is executed to replace the skin data onto the now resetXformed object.

However, after all this, the re-applied skin data is wrong. :confused:

Am I missing something obvious? Thanks in advace.


#4

I’m not a programmer, but I think you should look into saving skin weights/envelope (Advanced Parameters / Save) , delete the skin modifier, adding a new skin modifier after all your code business is done and then importing your skin weights/envelope again. Then you’ll get a fresh start for the skin modifier. I assume your bones are in T-pose matching up with the mesh? This would help alot if you want a new skin modifier to work. :wink:

Another Tip:

You might also want to look at the ‘Always Deform’ check box under ‘Advanced Parameters’ in the skin modifier. This resets your weights to preferred ‘Ref. Frame’ … Just mentioning it.

Good luck


#5

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.