python, scripts, softimage

Models to Nulls


This script just converts XSI models into nulls – essentially just matching the null to the model, parenting it’s children to the null and deleting it. It’s filed here

import win32com
xsi = Application
 
objs = win32com.client.Dispatch( "XSI.Collection" )
objs.AddItems (xsi.Selection)
 
 
for i in objs:
          if i.Type == "#model":
                   newNull = xsi.GetPrim("null", str(i) + "_null", "", "")   #create null
                   xsi.MatchTransform(newNull, i, "siSRT")   #match it's transforms to the model
                  
                   for eachChild in i.Children:  #parent model's children to null
                             xsi.ParentObj(newNull, eachChild)
                            
                   try:
                             for eachGroup in i.Groups:   #move groups to nulls parent
                                      xsi.CopyPaste (eachGroup,"", newNull.Parent, 1)
                   except:
                             print ""
 
                   try:
                             xsi.ParentObj (i.Parent, newNull)    #parent new null to original models parent
                   except:
                             print ""
 
 
                   xsi.DeleteObj (i)    #Delete original model
         
          else:
                   print "Select models only"