v4.0
Reloads the action source. This method is useful when you want
to find externally stored action sources that have become
disconnected from a clip.
You can also use this method to reload a source which has been
offloaded. If the source has external storage and the file is
valid, the source removes all current AnimationSourceItems and reloads
them from the source file.
Reloading the source disconnects all action Clips that use this source and reconnects them
(this happens even if the source is stored internally or if the
file is invalid). Once the paths are updated, reloading the source
reconnects everything correctly.
ActionSource.Reload(); |
/* 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, "" ); } } // |