Models to Nulls

This small script will convert selected models into nulls.

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"

Leave a Reply

Your email address will not be published. Required fields are marked *