The automation interface can interact with the selection in any of Multiframes windows. The selection is stored within a Selection object that encapsulates lists of the selected items. For instance, the nodes contained within a selection are stored in a NodeList object that is returned by the Nodes property of the Selection object. Similarly the Elements property of the Selection object returns an ElementList containing each of the selected elements.
The properties and methods of the Selection object are summarised in the tables below.
|
Property |
Type |
Description |
|
Application |
Application |
Read Only. Returns a reference to the parent application. |
|
Elements |
Elementlist |
Get/Set list of elements contained in the selection. |
|
Frame |
Frame |
Read Only. Returns a reference to the parent frame. |
|
Members |
Memberlist |
Get/Set list of members contained in the selection.. |
|
Nodes |
NodeList |
Get/Set list of nodes contained in the selection. |
|
Method |
Returns |
Description |
|
Clear |
|
Deselects all items in the selection. |
|
IsEmpty |
Boolean |
Returns true if no items are selected. |
The implementation of selections within the automation interface is significantly different to the other objects as a Selection object does not correspond directly to a selection within Multiframe and, as such, is not represented within object hierarchy. The advantage of this implementation is that many selections can be created, stored and manipulated without any restrictions imposed by the Multiframe application. However, the disadvantage is that a selection in a window is not automatically updated as items are added or removed from lists within a Selection object.
To use a selection object, a new instance must first be created by declaring the selection using the New keyword.
Dim mySelection as New Multiframe.Selection
The current selection in one of Multiframes windows can be obtained using the Selection property of the Frame object. This property has a single parameter that identifies the window containing the desired selection. The Selection property is read-only and so a selection can only be set using the SetSelection method of the Frame object. The methods takes up to three parameters that specify the selection, a window in which the selection is to be set, and an optional parameter specifying if the current selection in the window is to be extended. By default the SetSelection will replace any existing selection with the new selection. As an example of using the Selection object, the following code demonstrates how to set the selection in the load window to be the same as the selection in the Frame window
Dim mySelection as New Multiframe.Selection
’Get selection from Frame window
Set mySelection = myFrame.Selection(mfWinFrame)
’Set selection in Load window
Call myFrame.SetSelection(mySelection,mfWinLoad)
The Elements property of the Selection object returns an ElementList object containing references to each of the elements in the selection. This property can be set equal to any variant value representing either a single node or a list of nodes. The following script illustrates many of the ways in which this property can be accessed.
Dim mySelection as New Multiframe.Selection
Dim myEllist as New Multiframe.ElementList
’Compose list of elements to be selected
myElList.Add “1-20”
’Set selection
mySelection.Elements = 1
mySelection.Elements = myEllist
mySelection.Elements = mfApp.Frame.Elements
mySelection.Elements = “1,3,5,7”
’Select nodes at end of elements
Set mySelection.Nodes = mySelection.Elements.Nodes
’Set selection in Frame window
Call myFrame.SetSelection(mySelection ,mfWinFrame)
In the Multiframe user interface, the selection of nodes and elements is synchronised such that the nodes at the end of an element will automatically be selected when the element is selected. This relationship is not enforced via the Selection object and must be performed manually.
The Members and Nodes properties of the Selection object returns list objects that contain references to each of the selected nodes and members. These properties behave in the same way as the Element property and can be set equal to any variant values representing a single or a group of nodes or members. A further example demonstrating the use of the Selection object and the Nodes properties is listed below.
Dim mySelection as New Multiframe.Selection
Dim myNodeList as New Multiframe.Nodelist
Dim myNode as Multiframe.Node
’Get selection from Frame window
Set mySelection = myFrame.Selection(mfWinFrame)
’Get list of node contained in selection
myNodeList.Add (mySelection.Nodes)
’Refine selection to include only nodes that are pinned
For each myNode in myNodeList.Nodes
If (myNode.Pinned)
myNodeList.Remove myNode
Next
Next
’Set selection in Frame window
Call myFrame.SetSelection(mySelection ,mfWinFrame)
The Clear method of the Selection object removes all items from the selection. The IsEmpty method returns true if the selection empty and contains no selected items.
Dim mySelection as New Multiframe.Selection
’Get selection from Frame window
Set mySelection = myFrame.Selection(mfWinFrame)
Test if anything is selected
If (mySelection.IsEmpty) Then
msgbox “Nothing is selected in Frame
window”,,”MF Script”
End If