Applies To
ImportAction command
Description
This example demonstrates how to use the ImportAction command.
Code
/* This example demonstrates how to export and import an action. It also shows how to create an action source from a static source and then how to access the static source from the imported action. */ NewScene( null, false ); var root = ActiveSceneRoot; // Create a static action var obj = root.AddGeometry( "Cone", "MeshSurface" ); var targets = new Array( obj.rotx.FullName, obj.roty.FullName, obj.rotz.FullName ); var statics = new Array( 22.5, 90, 45 ); var actives = new Array( true, true, true ); var src = root.AddActionSource( "StoredAnimStaticAction", targets, statics, actives ); // Export the action var path = Application.InstallationPath( siProjectPath ) + "\\Actions"; var filepath = path + "\\TestImportAction.eani"; ExportAction( src, filepath ); // Import the action into a new scene but this time in a different model NewScene( null, false ); var mdl = ActiveSceneRoot.AddModel(); mdl.Name = "TestActionModel"; var newsrc = ImportAction( mdl, filepath, "ImportedAction4Test", -1 ); if ( newsrc.SourceItems.Count > 0 ) { LogMessage( "Imported action contains these items: " ); for ( var s=0; s<newsrc.SourceItems.Count; s++ ) { var datasrc = newsrc.SourceItems(s).Source; LogMessage( "\t" + datasrc ); } } else { LogMessage( "Imported action is a(n) " + ClassName(newsrc) ); } // Expected results: //INFO : Imported action contains these items: //INFO : StaticSource //INFO : StaticSource //INFO : StaticSource
Keywords
ImportAction
Autodesk Softimage 2011