#include <xsi_actiondeltaitem.h>
The ActionDeltaItem object tracks changes made on a parameter that is part of a reference model. Each ActionDeltaItem represents a single change, or modification, to a referenced parameter. So each time there a change to a static value, an FCurve, a Constraint, an Expression or a GroupRelation, a new ActionDeltaItem is generated.
You can also create new ActionDeltaItems from a data set using one of these functions:
ActionDeltaItem objects of the same type (see siModificationDeltaType) are stored in an ActionDelta which is accessible via the ActionDelta::GetItems function.
using namespace XSI; Application app; // NewScene command CValueArray cargs; CValue oarg; cargs.Add( L"" ); cargs.Add( false ); app.ExecuteCommand( L"NewScene", cargs, oarg ); cargs.Clear(); //Add cube geometry and create the reference model Model root = app.GetActiveSceneRoot(); X3DObject myCube; root.AddGeometry( L"Cube", L"MeshSurface",L"",myCube); // CreateModelAndConvertToRef command CString strFactPath = app.GetInstallationPath(siProjectPath) ; strFactPath += L"/Models/MyModel.emdl"; cargs.Add( myCube.GetFullName() ); cargs.Add( strFactPath ); app.ExecuteCommand( L"CreateModelAndConvertToRef", cargs, oarg ); cargs.Clear(); Delta myDelta; // AddDelta command cargs.Add( L"Model" ); app.ExecuteCommand( L"AddDelta", cargs, oarg ); cargs.Clear(); myDelta = oarg; // Translate command cargs.Add(myCube.GetFullName()); cargs.Add(2.0); cargs.Add(1.3); cargs.Add(0.0); cargs.Add(L"siRelative"); cargs.Add(L"siView"); cargs.Add(L"siObj"); cargs.Add(L"siXYZ"); app.ExecuteCommand( L"Translate", cargs, oarg ); cargs.Clear(); ActionDelta ActionDelta0 = myDelta.GetActionDeltas().GetItem(0); CRefArray ActionDeltaItems = ActionDelta0.GetItems(); CString strmgs; for ( LONG i=0; i<ActionDeltaItems.GetCount(); ++i ) { ActionDeltaItem item = ActionDeltaItems[i]; // Print info about the current ActionDeltaItem strmgs = L"ActionSourceItem["; strmgs += CValue(i).GetAsText(); strmgs += L"]"; Application().LogMessage(strmgs); strmgs = L"Name: "; strmgs += item.GetName(); Application().LogMessage(strmgs); strmgs = L"Type: "; strmgs += item.GetType(); Application().LogMessage(strmgs); //Print the current value strmgs = L"Initiale Value: "; strmgs += item.GetValue(); Application().LogMessage(strmgs); // Change the value of the item item.PutValue ( 1.2 * i ); //Print the new value + some AuditInformation strmgs = L"New value: "; strmgs += item.GetValue(); strmgs+= L", "; strmgs += item.GetAuditInfo(); Application().LogMessage(strmgs); }
Public Member Functions |
|
ActionDeltaItem () | |
~ActionDeltaItem () | |
ActionDeltaItem (const CRef &in_ref) | |
ActionDeltaItem (const ActionDeltaItem &in_obj) | |
bool | IsA (siClassID in_ClassID) const |
siClassID | GetClassID () const |
ActionDeltaItem & | operator= (const ActionDeltaItem &in_obj) |
ActionDeltaItem & | operator= (const CRef &in_ref) |
CString | GetName () const |
CStatus | PutName (const CString &in_Name) const |
CString | GetType () const |
bool | GetMute () const |
CStatus | PutMute (const bool in_Mute) |
CValue | GetValue () const |
CStatus | PutValue (CValue in_value) |
CString | GetAuditInfo () |
ActionDeltaItem | ( | ) |
Default constructor.
~ActionDeltaItem | ( | ) |
Default destructor.
ActionDeltaItem | ( | const CRef & | in_ref | ) |
Constructor.
in_ref | constant reference object. |
ActionDeltaItem | ( | const ActionDeltaItem & | in_obj | ) |
Copy constructor.
in_obj | constant class object. |
bool IsA | ( | siClassID | in_ClassID | ) | const [virtual] |
Returns true if a given class type is compatible with this API class.
in_ClassID | class type. |
Reimplemented from SIObject.
siClassID GetClassID | ( | ) | const [virtual] |
ActionDeltaItem& operator= | ( | const ActionDeltaItem & | in_obj | ) |
Creates an object from another object. The newly created object is set to empty if the input object is not compatible.
in_obj | constant class object. |
ActionDeltaItem& operator= | ( | const CRef & | in_ref | ) |
Creates an object from a reference object. The newly created object is set to empty if the input reference object is not compatible.
in_ref | constant class object. |
Reimplemented from SIObject.
CString GetName | ( | ) | const |
Returns the name of the ActionDeltaItem.
Reimplemented from SIObject.
Sets the name of the ActionDeltaItem.
in_Name | New name for the object. |
CString GetType | ( | ) | const |
Returns the type of the ActionDeltaItem.
Reimplemented from SIObject.
bool GetMute | ( | ) | const |
Returns whether the ActionDeltaItem is muted or not.
CStatus PutMute | ( | const bool | in_Mute | ) |
Sets whether the ActionDeltaItem is muted or not.
in_Mute | True to mute the ActionDeltaItem is muted; false to make it active. |
using namespace XSI; Application app; // NewScene command CValueArray cargs; CValue oarg; cargs.Add( L"" ); cargs.Add( false ); app.ExecuteCommand( L"NewScene", cargs, oarg ); cargs.Clear(); //Add cube geometry and create the reference model Model root = app.GetActiveSceneRoot(); X3DObject myCube; root.AddGeometry( L"Cube", L"MeshSurface",L"",myCube); // CreateModelAndConvertToRef command CString strFactPath = app.GetInstallationPath(siProjectPath) ; strFactPath += L"/Models/MyModel.emdl"; cargs.Add( myCube.GetFullName() ); cargs.Add( strFactPath ); app.ExecuteCommand( L"CreateModelAndConvertToRef", cargs, oarg ); cargs.Clear(); Delta myDelta; // AddDelta command cargs.Add( L"Model" ); app.ExecuteCommand( L"AddDelta", cargs, oarg ); cargs.Clear(); myDelta = oarg; // Add an action of type siModificationDeltaStaticValue ActionDelta myDeltaAction = myDelta.AddAction(siModificationDeltaStaticValue); // Add the Static value item ActionDeltaItem myActionDeltaItem = myDeltaAction.AddStaticValueItem ( myCube.GetFullName() + L".kine.global.posx", 10.0); // Mute the Item myActionDeltaItem.PutMute (true); app.LogMessage(L"muting " + myActionDeltaItem.GetName()); // Apply modification myDelta.Apply(); // UpdateReferencedModel command cargs.Add( L"Model" ); app.ExecuteCommand( L"UpdateReferencedModel", cargs, oarg ); cargs.Clear();
CValue GetValue | ( | ) | const |
Returns the value of an ActionDeltaItem. Depending on the type of the ActionDeltaItem (see ActionDeltaItem::GetType) the returned CValue may contain several different types of data.
using namespace XSI; Application app; // NewScene command CValueArray cargs; CValue oarg; cargs.Add( L"" ); cargs.Add( false ); app.ExecuteCommand( L"NewScene", cargs, oarg ); cargs.Clear(); //Add cube geometry and create the reference model Model root = app.GetActiveSceneRoot(); X3DObject myCube; root.AddGeometry( L"Cube", L"MeshSurface",L"",myCube); // CreateModelAndConvertToRef command CString strFactPath = app.GetInstallationPath(siProjectPath) ; strFactPath += L"/Models/MyModel.emdl"; cargs.Add( myCube.GetFullName() ); cargs.Add( strFactPath ); app.ExecuteCommand( L"CreateModelAndConvertToRef", cargs, oarg ); cargs.Clear(); Delta myDelta; // AddDelta command cargs.Add( L"Model" ); app.ExecuteCommand( L"AddDelta", cargs, oarg ); cargs.Clear(); myDelta = oarg; // SaveKey command cargs.Add( L"Model.kine.local.posx,Model.kine.local.posy,Model.kine.local.posz" ); cargs.Add( 1 ); app.ExecuteCommand( L"SaveKey", cargs, oarg ); cargs.Clear(); FCurve myFCurve; ActionDelta ActionDelta0 = myDelta.GetActionDeltas().GetItem(0); ActionDeltaItem ActionDeltaItem0 = ActionDelta0.GetItems().GetItem(0); myFCurve = ActionDeltaItem0.GetValue(); LONG nbkeys = 100; myFCurve.BeginEdit(); for(LONG i = 0; i < nbkeys; i++ ) { double val = sin(1.0/(i+1.0) *10.0); myFCurve.AddKey(i, val); } myFCurve.EndEdit(); CValue MyFCValue(myFCurve); ActionDeltaItem0.PutValue(MyFCValue); // Apply modification myDelta.Apply();
Sets the value of an ActionDeltaItem. Depending on the type of
the ActionDeltaItem (see
ActionDeltaItem::GetType) you may specify several different
types of data in in_value
.
in_value | CValue::m_t == CValue::siRef for item of type ::siModificationDeltaFCurves (CRef containing a reference to the FCurve). |
in_value | CValue::m_t == CValue::double for item of type siModificationDeltaStaticValue. |
in_value | CValue::m_t == CValue::string for item of any other type. |
using namespace XSI; Application app; // NewScene command CValueArray cargs; CValue oarg; cargs.Add( L"" ); cargs.Add( false ); app.ExecuteCommand( L"NewScene", cargs, oarg ); cargs.Clear(); //Add cube, cone and sphere geometries and create the reference model Model root = app.GetActiveSceneRoot(); X3DObject myCube, myCone, mySphere; root.AddGeometry( L"Cube", L"MeshSurface",L"",myCube); root.AddGeometry( L"Cone", L"MeshSurface",L"",myCone); root.AddGeometry( L"Sphere", L"MeshSurface",L"",mySphere); // CreateModelAndConvertToRef command CString strFactPath = app.GetInstallationPath(siProjectPath) ; strFactPath += L"/Models/MyModel.emdl"; cargs.Add( myCube.GetFullName() ); cargs.Add( strFactPath ); app.ExecuteCommand( L"CreateModelAndConvertToRef", cargs, oarg ); cargs.Clear(); Delta myDelta; // AddDelta command cargs.Add( L"Model" ); app.ExecuteCommand( L"AddDelta", cargs, oarg ); cargs.Clear(); myDelta = oarg; // Translate command cargs.Add(myCone.GetFullName()); cargs.Add(3.0); cargs.Add(3.0); cargs.Add(0.0); cargs.Add(L"siRelative"); cargs.Add(L"siView"); cargs.Add(L"siObj"); cargs.Add(L"siXYZ"); app.ExecuteCommand( L"Translate", cargs, oarg ); cargs.Clear(); // Translate command cargs.Add(mySphere.GetFullName()); cargs.Add(-2.0); cargs.Add(-2.0); cargs.Add(0.0); cargs.Add(L"siRelative"); cargs.Add(L"siView"); cargs.Add(L"siObj"); cargs.Add(L"siXYZ"); app.ExecuteCommand( L"Translate", cargs, oarg ); cargs.Clear(); // ApplyCns command cargs.Add( L"Position" ); cargs.Add(myCube.GetFullName()); cargs.Add(myCone.GetFullName()); app.ExecuteCommand( L"ApplyCns", cargs, oarg ); cargs.Clear(); ActionDelta ActionDelta0 = myDelta.GetActionDeltas().GetItem(0); CRefArray ActionDeltaItems = ActionDelta0.GetItems(); for ( LONG i=0; i<ActionDeltaItems.GetCount(); ++i ) { ActionDeltaItem item = ActionDeltaItems[i]; item.PutValue(L"Scene_Root." + mySphere.GetFullName()); } // Apply modification myDelta.Apply(); // UpdateReferencedModel command cargs.Add( L"Model" ); app.ExecuteCommand( L"UpdateReferencedModel", cargs, oarg ); cargs.Clear();
CString GetAuditInfo | ( | ) |
Returns the Audit Information on the ActionDeltaItem.