# Demon Project - Export Group Python Script # Plots the local transformations of a group, then exports them out as a Action Clip # By Peter Agg: # peter.agg@googlemail.com / peteragg.co.uk from win32com.client import constants as c def Pickmodel(): global Picked # Pick the model to work with Picked = Application.PickElement(c.siGroupFilter, "Pick group", "Pick group" ) # Right-Click bomb out if Picked[0] == 0: Application.logmessage("Right button clicked, returning") return else: Application.logmessage(str(Picked(2)) +" was chosen") MakeClip() def MakeClip(): # The model of the group chose Modelname = Picked(2).Parent #Prompt the user to name the clip ActionName = Application.XSIInputBox ("Action Name", "Action Clip Name", "Action") Application.logmessage(str(Modelname) + ".Mixer." + str(ActionName)) # See whether the action clip already exists - cheers to Atyss at XSI Base for how: http://www.xsibase.com/forum/index.php?board=14;action=display;threadid=9773 oColl = XSIFactory.CreateObject( "XSI.Collection" ) oColl.Items = str(Modelname) + ".Mixer." + str(ActionName) if oColl.count > 0: # if the clip exists as whether the user wants to delete it Query = XSIUIToolkit.MsgBox("Clip name already exists, delete old clip?", c.siMsgYesNo) if Query == 6: # If yes, delete the clip and restart the function Application.DeleteObj(str(Modelname) + ".Mixer." + str(ActionName)) MakeClip() elif Query == 7: # If they don't want to delete the existing clip then exit Application.logmessage("Exiting script - Clip already exists") else: oObject = oColl(0) # Select the group selection = Application.SelectMembers( str(Picked(2)), "", "") # log the in and out Playback times intime = Application.GetValue("PlayControl.In") outime = Application.GetValue("PlayControl.Out") # activate local marking Application.SetMarking("kine.local.pos.posx,kine.local.pos.posy,kine.local.pos.posz,kine.local.ori.euler.rotx,kine.local.ori.euler.roty,kine.local.ori.euler.rotz,kine.local.scl.sclx,kine.local.scl.scly,kine.local.scl.sclz") # plot, store and export the action Application.PlotAndApplyActions("", ActionName, intime, outime, "", 20, 3, "", "", "", "", True, True) Application.StoreAction(Picked(2),"", 2, ActionName, "", intime, outime, "", "", "", 0) path = Application.InstallationPath( c.siProjectPath ) + "\\Actions" Application.ExportAction(str(Modelname) + ".Mixer." + str(ActionName), path+"\\"+ActionName+".eani") # User instructions: Application.logmessage("Select enveloping group") Pickmodel()