CopyScenarioData(
DestScenarioKey: Array;
SourceScenarioKey: Integer;
EntryKeys: Array;
[CopyAll: Boolean = False]
);
CopyScenarioData(
DestScenarioKey: System.Array;
SourceScenarioKey: uinteger;
EntryKeys: System.Array;
CopyAll: boolean
);
DestScenarioKey. Array of keys of consumer scenarios.
SourceScenarioKey. Provider scenario key.
EntryKeys. Array of keys of copied variables.
CopyAll. Indicates whether to copy data of all model variables.
The CopyScenarioData method copies data by the modelling scenarios.
For correct copying of data, set the value of the IMsMetaModelVisualController.Problem property.
For copying data by the Fact scenario use -1 key.
The EntryKeys parameter must contain keys of elements of the metamodel calculation chain, which are variables.
Available values of CopyAll:
True. Copy data of all variables.
False. The default value. Copy data of variables determined in the EntryKeys parameter.
Executing the example requires that the repository contains a modeling container with the MODEL_SPACE identifier containing a modeling problem with the WEB_PROBLEM identifier. The modeling problem must contain several modeling scenarios and an internal metamodel.
Add links to the Metabase, Ms system assemblies.
Sub CopyScenarioData;
Var
MB: IMetabase;
MsObj: IMetabaseObject;
Problem: IMsProblem;
ProbScen: IMsProblemScenarios;
Meta: IMsMetaModel;
MetaVisual: IMsMetaModelVisualController;
DestScen: IMsScenario;
DestScenKeys, VarsKeys: Array[1] Of Integer;
ChainEnts: IMsCalculationChainEntries;
ChainEl: IMsCalculationChainEntry;
i: Integer;
Begin
MB := MetabaseClass.Active;
// Get modeling container
MsObj := MB.ItemById("MODEL_SPACE").Bind;
// Get modeling problem
Problem := MB.ItemByIdNamespace("WEB_PROBLEM", MsObj.Key).Bind As IMsProblem;
// Get modeling problem scenarios
ProbScen := Problem.Scenarios;
// Get the first scenario in the modeling problem
DestScen := ProbScen.Item(0);
DestScenKeys[0] := (DestScen As IMetabaseObject).Key;
// Get metamodel
Meta := Problem.MetaModel;
MetaVisual := Meta.VisualController;
// Set the modeling problem
MetaVisual.Problem := Problem;
// Get the key of the first variable in the calculation chain
ChainEnts := Meta.CalculationChain;
For i := 0 To ChainEnts.Count - 1 Do
ChainEl := ChainEnts.Item(i);
If ChainEl.Type = MsCalculationChainEntryType.Variable Then
VarsKeys[0] := ChainEl.Key;
Break;
End If;
End For;
// Copy data of the first variable by the Fact scenario to the first scenario
MetaVisual.CopyScenarioData(DestScenKeys, -1, VarsKeys);
End Sub CopyScenarioData;
Example execution result: the data of the first input variable in the metamodel calculation chain will be copied by the Fact scenario to the first scenario in the modeling problem.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Stat;
…
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
MsObj: IMetabaseObject;
Problem: IMsProblem;
ProbScen: IMsProblemScenarios;
Meta: IMsMetaModel;
MetaVisual: IMsMetaModelVisualController;
DestScen: IMsScenario;
DestScenKeys, VarsKeys: Array[1] Of integer;
ChainEnts: IMsCalculationChainEntries;
ChainEl: IMsCalculationChainEntry;
i: Integer;
Begin
MB := Params.Metabase;
// Get modeling container
MsObj := MB.ItemById["MODEL_SPACE"].Bind();
// Get modeling problem
Problem := MB.ItemByIdNamespace["WEB_PROBLEM", MsObj.Key].Bind() As IMsProblem;
// Get modeling problem scenarios
ProbScen := Problem.Scenarios;
// Get the first scenario in the modeling problem
DestScen := ProbScen.Item[0];
DestScenKeys[0] := (DestScen As IMetabaseObject).Key As integer;
// Get metamodel
Meta := Problem.MetaModel;
MetaVisual := Meta.VisualController;
// Set the modeling problem
MetaVisual.Problem := Problem;
// Get the key of the first variable in the calculation chain
ChainEnts := Meta.CalculationChain;
For i := 0 To ChainEnts.Count - 1 Do
ChainEl := ChainEnts.Item[i];
If ChainEl.Type = MsCalculationChainEntryType.mccetVariable Then
VarsKeys[0] := ChainEl.Key As integer;
Break;
End If;
End For;
// Copy data of the first variable by the Fact scenario to the first scenario
MetaVisual.CopyScenarioData(DestScenKeys, (-1) As uinteger, VarsKeys, False);
End Sub;
See also: