CenterMovingAverage: Boolean;
The CenterMovingAverage property determines whether center method is used to calculate average values.
Sub Main;
Var
MB: IMetabase;
CrInf: IMetabaseObjectCreateInfo;
MObj: IMetabaseObject;
Model: IMsModel;
Trans: IMsFormulaTransform;
Varr: IMsVariable;
VarTrans: IMsFormulaTransformVariable;
Tree: IMsFormulaTransformSlicesTree;
Slice: IMsFormulaTransformSlice;
Selector: IMsFormulaTransformSelector;
Formula: IMsFormula;
SlideSmooth: IMsSlideSmoothingTransform;
Begin
MB := MetabaseClass.Active;
CrInf := Mb.CreateCreateInfo;
CrInf.ClassId := MetabaseObjectClass.KE_CLASS_MSMODEL;
CrInf.Id := "New_SlideSmooth";
CrInf.Name := "New_SlideSmooth";
CrInf.Parent := Mb.ItemById("KONT_MODEL");
CrInf.Permanent := False;
MObj := Mb.CreateObject(CrInf).Edit;
Model := MObj As IMsModel;
Trans := Model.Transform;
Varr := MB.ItemByIdNamespace("Var_1", MB.ItemById("KONT_MODEL").Key).Bind As IMsVariable;
Model.Output.Add(Varr);
// loaded variable
Varr := MB.ItemByIdNamespace("Var_2", MB.ItemById("KONT_MODEL").Key).Bind As IMsVariable;
Model.Output.Add(Varr);
VarTrans := Trans.Outputs.Item(0);
Tree := VarTrans.SlicesTree(VarTrans);
Slice := Tree.CreateSlice(1);
Selector := Model.Transform.CreateSelector;
Selector.Slice := Slice;
Formula := Model.Transform.Transform(Selector);
Formula.Kind := MsFormulaKind.SlideSmoothing;
SlideSmooth := Formula.Method As IMsSlideSmoothingTransform;
SlideSmooth.CenterMovingAverage := True;
SlideSmooth.Width := 4;
//set the downloaded variable
SlideSmooth.FittedSerie := Varr As IMsVariableStub;
MObj.Save;
End Sub Main;
After executing the example a model using moving average method for calculation is created in the modeling container.
See also: