Width: Integer;
The Width property determines the method window width.
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;
MedSmooth: IMsMedianSmoothingTransform;
Begin
MB := MetabaseClass.Active;
CrInf := Mb.CreateCreateInfo;
CrInf.ClassId := MetabaseObjectClass.KE_CLASS_MSMODEL;
CrInf.Id := "New_MedSmooth";
CrInf.Name := "New_MedSmooth";
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);
// unloaded 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.MedianSmoothing;
MedSmooth := Formula.Method As IMsMedianSmoothingTransform;
MedSmooth.Width := 4;
//set the downloaded variable
MedSmooth.FittedSerie := Varr As IMsVariableStub;
MObj.Save;
End Sub Main;
After executing the example the model, used for calculation of median smoothing method, is created in the modeling container. The output and unloaded variables are added and the parameter of smoothing is set to the model.
See also: