Code: Select all
xsi = Application
frame = xsi.GetValue("PlayControl.Current")
pivot = xsi.PickPosition("Set new pivot position and key it", "Remove key on the current frame")
if pivot[0] == 1:
v3 = XSIMath.CreateVector3(pivot[1],pivot[2],pivot[3])
m4x4 = XSIMath.CreateMatrix4()
obj = xsi.Selection[0]
obj.Kinematics.Global.Transform.GetMatrix4(m4x4)
m4x4.Invert(m4x4)
v3.MulByMatrix4InPlace(m4x4)
x, y, z = 0, 0, 0
x, y, z = v3.Get(x, y, z)
xsi.SetValue("*.kine.local.pposx", x)
xsi.SetValue("*.kine.local.pposy", y)
xsi.SetValue("*.kine.local.pposz", z)
xsi.SavePivotKey(["*"], "siTrn", frame)
xsi.RotationTool()
elif pivot[0] == 2:
try:
xsi.RemoveKey("*.kine.local.pposx,*.kine.local.pposy,*.kine.local.pposz,*.kine.local.pcposx,*.kine.local.pcposy,*.kine.local.pcposz", frame)
except:
pass