RefreshAttributesStructure;
The RefreshAttributesStructure method refreshes the structure of attributes of the variable
The method is relevant if the variable is based on attributes.
Executing the example requires a time series database with the TSDB identifier containing a model of the determinate equation with the MODEL_ATTR identifier in the internal modeling container.
Add links to the Cubes, Metabase, Ms system assemblies.
Sub UserCalc;
Var
Mb: IMetabase;
RubrDescr: IMetabaseObjectDescriptor;
Rubr: IRubricator;
MsDescr: IMetabaseObjectDescriptor;
Model: IMsModel;
Transform: IMsFormulaTransform;
TransformVarables: IMsFormulaTransformVariables;
TransfVar: IMsFormulaTransformVariable;
Coord: IMsFormulaTransformCoord;
Calc: IMsMethodCalculation;
Period: IMsModelPeriod;
Formula: IMsFormula;
Begin
// Get time series database
Mb := MetabaseClass.Active;
RubrDescr := Mb.ItemById("TSDB");
Rubr := RubrDescr.Bind As IRubricator;
// Get the internal modeling container
MsDescr := Rubr.ModelSpace;
// Get the model
Model := Mb.ItemByIdNamespace("MODEL_ATTR", MsDescr.Key).Edit As IMsModel;
// Get model parameters
Transform := Model.Transform;
// Update attributes structure of output variable
TransformVarables := Transform.Outputs;
TransfVar := TransformVarables.Item(0);
TransfVar.RefreshAttributesStructure;
// Set the parameters for calculation of the model
Coord := Transform.CreateCoord(TransfVar);
Calc := Transform.CreateCalculation;
Period := Calc.Period;
Period.IdentificationStartDate := Model.Transform.Period.IdentificationStartDate;
Period.IdentificationEndDate := Model.Transform.Period.IdentificationEndDate;
Period.ForecastStartDate := Model.Transform.Period.ForecastStartDate;
Period.ForecastEndDate := Model.Transform.Period.ForecastEndDate;
Calc.CurrentPoint := Model.Transform.Period.IdentificationStartDate;
// Perform calculation of the model
Formula := Transform.FormulaItem(0);
(Formula.Method As IMsDeterministicTransform).Execute(Calc, Coord);
// Save changes
(Model As IMetabaseObject).Save;
End Sub UserCalc;
After executing the example the attributes structure if output variable is updated in the MODEL_ATTR model. The model is calculated.
See also: