ActionSource.Reload

導入

v4.0

詳細

アクションソースをリロードします。このメソッドは、外部に格納されている、クリップから接続解除されたアクションソースを検索する場合に役立ちます。

また、オフロードされたソースをリロードすることもできます。ソースの格納場所が外部に設定されており、ファイルが有効になっている場合は、ソースの現在のAnimationSourceItemがすべて削除され、ソースファイルからリロードされます。

ソースをリロードすると、このソースを使用するすべてのアクションClipが接続解除された後、再接続されます(この処理は、ソースが内部に格納されている場合やファイルが無効な場合にも実行されます)。パスを更新した後でソースをリロードすると、すべてが正しく再接続されます。

C#構文

ActionSource.Reload();

スクリプト構文

ActionSource.Reload();

JScript の例

/*

	This example illustrates how to use the Reload method on an ActionSource

*/

NewScene( null, false );

var oRoot = Application.ActiveProject.ActiveScene.Root;

// Create a new model and add a null under it

var oModel = oRoot.AddModel();

oModel.Parameters("Name").Value = "ActionModel";

var oNull = oModel.AddNull();

// These commands were cut-and-pasted from scripting history and modified to work in a

// script. They create a simple actionsource from animation on the null's position

strPosParams = oNull + ".kine.local.posx," + oNull + ".kine.local.posy," + oNull + ".kine.local.posz";

Translate( oNull, -8.153, 7.015, -0.702, siRelative, siView, siObj, siXYZ );

SaveKey( strPosParams, 1.000 );

Translate( oNull, 8.350, -8.935, 0.894, siRelative, siView, siObj, siXYZ );

SaveKey( strPosParams, 50.000 );

Translate( oNull, 9.413, 8.935, -0.894, siRelative, siView, siObj, siXYZ );

SaveKey( strPosParams, 100.000 );

// Create a new ActionSource based on the null's translation

var oActionSource = oModel.AddActionSource( "MyActionSource" );

// Use the fcurves on the null object to create the actionsource items

var oPosx = oNull.Posx;

var oPosy = oNull.Posy;

var oPosz = oNull.Posz;

oActionSource.AddSourceItem( GetRelativeName(oPosx), oPosx.Source );

oActionSource.AddSourceItem( GetRelativeName(oPosy), oPosy.Source );

oActionSource.AddSourceItem( GetRelativeName(oPosz), oPosz.Source );

// Set the action storage to external (text)

oActionSource.Parameters( "storage" ).Value = 2; 	// equivalent to: SetValue( oActionSource + ".storage", 2 );

// Add a clip for the source

AddClip( oModel, oActionSource, "", "", 16, "", "", "", false );

// Save the scene, in order to save the action externally

var sSavePath = XSIUtils.BuildPath( Application.InstallationPath(siProjectPath), "Scenes", "ASTestScene.scn" );

SaveSceneAs( sSavePath, true );

// So, calling Reload on the source will disconnect the source, reload the action and reconnect the source.

oActionSource.Reload();

/* 

	GetRelativeName removes the name of the model from the FullName 

	of the specified parameter. This is necessary when setting up a source 

	that will later be used to instantiate a clip when the parameter lives 

	under a model other than the Scene_Root.

*/

function GetRelativeName( in_param )

{

	var mdlname = in_param.Model.FullName;

	if ( mdlname == "Scene_Root" ) {

		return in_param.FullName;

	} else {

		var tmp = in_param.FullName;

		var re = new RegExp( mdlname + ".", "i" );

		return tmp.replace( re, "" );

	}

}

//