Model.AddActionSource

説明

ActionSource を作成し、モデルのソースコレクションに追加します。

C#構文

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

スクリプト構文

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

戻り値

ActionSource

パラメータ

パラメータ タイプ 説明
Name String 新しいアクションソースの名前
TargetArray Array ソース項目ターゲットパスの配列
SourceArray Array ソース項目ソースの配列。現時点では、固定値を表すFCurveStaticSource、またはDoubleの値のみが有効なソースです。
ActiveArray Array ソース項目アクティブフラグの配列

VBScript の例

'

' 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