IMsCalculationTree: IMsCalculationTree;
The CalculationTree property returns modeling problem calculation tree.
The calculation tree represents the sequence of calculation in a hierarchical form, and also allows the user to display on which tree node the breakpoint is set.
Executing the example requires a form, a button with the Button1 identifier on the form and the TreeList component with the TreeList1 identifier. The repository should contain a modeling container with the MODEL_SPACE identifier that contains a modeling problem with the PROBLEM identifier.
Add links to the Metabase and Ms system assemblies.
Click the button to start executing of this example.
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
Mb: IMetabase;
ModelSpaceDescr: IMetabaseObjectDescriptor;
Problem: IMsProblem;
CalcSettings: IMsProblemCalculationSettings;
Calculation: IMsProblemCalculation;
CalculationTree: IMsCalculationTree;
CalcChildren: IMsCalculationTreeNodes;
Begin
Mb := MetabaseClass.Active;
ModelSpaceDescr := Mb.ItemById("MODEL_SPACE");
Problem := Mb.ItemByIdNamespace("PROBLEM", ModelSpaceDescr.Key).Bind As IMsProblem;
CalcSettings := Problem.CreateCalculationSettings;
CalcSettings.FactIncluded := True;
Calculation := Problem.Calculate(CalcSettings);
CalculationTree := Calculation.CalculationTree;
CalcChildren := CalculationTree.Children;
FillCalcList(CalcChildren, Null);
End Sub Button1OnClick;
Sub FillCalcList(Items: IMsCalculationTreeNodes; ParentNode: ITreeListNode);
Var
TreeNodes: ITreeListNodes;
i: Integer;
Item: IMsCalculationTreeNode;
TreeNode: ITreeListNode;
Text: String;
Begin
TreeNodes := TreeList1.Nodes;
For i := 0 To Items.Count - 1 Do
Item := Items.Item(i);
Text := Item.Text;
If Item.Kind = MsCalculationTreeNodeKind.Model Then
Text := Text + " (breakpoint is set!)";
End If;
TreeNode := TreeNodes.AddChild(ParentNode, Text);
FillCalcList(Item.Children, TreeNode);
TreeNode.Expand(False);
End For;
End Sub FillCalcList;
After executing the example the modeling problem calculation tree is displayed in the TreeList component.
See also: