AddActionSource (Model)

Description

Creates and adds an ActionSource to the model's collection of sources.

Scripting Syntax

    Model.AddActionSource( [Name], [TargetArray], [SourceArray], [ActiveArray] )

C# Syntax

    ActionSource Model.AddActionSource( String in_vName, Object in_vTargetArray, Object in_vSourceArray, Object in_vActiveArray );

Parameters

Parameter | Type | Description
Name | String | Name of the new action source
TargetArray | Array | Array of source item target paths.
SourceArray | Array | Array of source item sources. For now only FCurve, StaticSource or Double values representing static values are valid sources.
ActiveArray | Array | Array of source item active flags.

Return Value

ActionSource

Examples

VBScript Example

    '
    ' 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

Autodesk Softimage v7.5