'
' This example illustrates how to create an ActionSource
' from FCurve information.
'
set oRoot = Application.ActiveProject.ActiveScene.Root
if Application.Selection.Count <> 0 then
set oObject = Application.Selection(0)
else
' Create sample scene
set oNull = oRoot.AddNull
set oObject = oNull.AddNull()
oObject.posx.AddFCurve2( Array(1, -10, 50, 0, 100, 10) )
oObject.posy.AddFCurve2( Array(1, 10, 50, 0, 100, 10) )
end if
CreateActionSourceFromLocalFCurves oObject
sub CreateActionSourceFromLocalFCurves( in_object )
strTitle = "Create ActionSource from Local FCurves"
if IsObject(in_object) <> True then
MsgBox "Please select an object", vbExclamation, strTitle
exit sub
end if
if InStr(in_object.Families, "3D Object") = 0 then
MsgBox "Please select a 3D object", vbExclamation, strTitle
exit sub
end if
set k = in_object.Kinematics
' ... assuming all animation is on local transform
set oAnimatedParams = k.AnimatedParameters(siFCurveSource)
if oAnimatedParams.Count = 0 then
MsgBox "Please select an object with animation", vbExclamation, strTitle
exit sub
end if
' Find local parameters
set oLocalParams = CreateObject("XSI.Collection")
for each oAnimatedParam in oAnimatedParams
' Poor man's test for local parameters
if InStr( oAnimatedParam.FullName, ".local." ) <> 0 then
' Only support fcurves for now.
if TypeName(oAnimatedParam.Source) = "FCurve" then
oLocalParams.Add oAnimatedParam
end if
end if
next
if oLocalParams.Count = 0 then
exit sub
end if
Dim aTarget, aSource, aActive
ReDim aTarget(oLocalParams.Count-1)
ReDim aSource(oLocalParams.Count-1)
ReDim aActive(oLocalParams.Count-1)
i=0
for each oLocalParam in oLocalParams
aTarget(i) = oLocalParam.FullName
set aSource(i) = oLocalParam.Source
aActive(i) = True
i = i + 1
next
set oActionSource = oRoot.AddActionSource( in_object.Name & "-localfcurves", _
aTarget, aSource, aActive )
LogMessage "Created new ActionSource " & oActionSource.FullName
end sub
|