Make Reset-Nulls

Hey!

How many times a day do you make reset nulls, to zero out the local values? To me it fells that I’m doing it >30 times a day – So automating this process is essential to speed-up working. Here is a small python script, that makes your day more comfortable.

Usage: Select a Object and run the script. The code will generate a new parent of the object you have selected. With this approach you have zero out all local transforms.

Maya

Please notice that I have made a NullGrpSwitch Variable. This lets you choose if you want a locator or a tranform group as rest object.

import maya.cmds as cmds

#Globale Variable for Null or Transfrom Group
NullGrpSwitch = False

#Get current Selecton
selection= cmds.ls(selection=True )

#Loop through the Selecton 
for sel in selection:
    #Set Driven Key
    oParent = cmds.listRelatives(sel, ap=True)
    print(oParent)
    #Choose if you want a locator or a empty group as parent
    if(NullGrpSwitch == True):
        #Create a Locator as Rest Object
        oParentRest = cmds.spaceLocator( p=(0,0,0), n=(sel+"_rest"))[0]
    else:
        #Create a Traform Group as Rest Object
        oParentRest = cmds.group( em=True, n=sel+'_rest') 
    #Get the global Matrix of the current Object
    pivotTranslate = cmds.xform (sel, q = True, m = True) #m=matrix,ro=rotation,t=transfrom
    #Set the global Matrix of the current Object to the Rest Object
    cmds.xform(oParentRest, r=True, m=pivotTranslate)
    if(oParent):
        cmds.parent(oParentRest,oParent)
        cmds.parent(sel,oParentRest)
    else:
        #Parent Objects
        #cmds.parent(oParentRest,oParent)
        cmds.parent(sel,oParentRest) 

 

Softimage

 

xsi = Application
log = Application.LogMessage
collSel = Application.Selection

mysel = []

if(collSel.Count == 0):
	log("debug: Nothing is selected!")
else:
	for i in range(0,collSel.Count):
		mysel.append(collSel[i].FullName)
		
	for x in range(0,len(mysel)):
		#log("debug :" + mysel[x])
		xsi.SelectObj(mysel[x], "", "")
		oParent = collSel[0].Parent.FullName 
		oSel = xsi.Selection(0)
		xsi.SelectNeighborObj(xsi.Selection(0), 0, "NODE", False)
		oSelParent = xsi.Selection(0)
		oParentNull = xsi.GetPrim("Null", "", "", "")
		xsi.SetValue(str(oParentNull.Name) + ".null.primary_icon", 0, "")
		xsi.MatchTransform(oParentNull, str(oSel.FullName), "siSRT", "")
		xsi.SetValue(str(oParentNull) + ".Name", str(oSel.Name) + "_rest", "")
		xsi.CopyPaste(oSel, "", oParentNull, 1)
		if(oParent != "Scene_Root"):
			xsi.CopyPaste(oParentNull, "", oSelParent, 1)

One last thing to notice, you can easily adapt this scripts to do other stuff with your objects. In softimage I use this script frequently to edit parameters on a big amount of ojects.