Improving performance with lists

To improve the speed of your scripts, more than a single node or element can be added to the frame at a time using the AddNodes and AddElements methods of the Nodes and Elements collections.  These methods can take arrays of parameters describing each of the items to be added to the frame and return a list of the items added to the frame.  For example, the two nodes could be created with a single call to the Multiframe application as follows

Dim myNodeList as New Multiframe.NodeList

With mfFrame.Nodes
  Set myNodeList = .AddNodes(Array(0.0,5.0),Array(2.5,5.0),0)
End With

or

Dim objNodeList as New Multiframe.NodeList
Dim xArray(1 to 2) as double
Dim yArray(1 to 2) as double

Set objNodeList = myFrame.Nodes.AddNodes(xArray,yArray,0.0)

The first two parameters specify the x and y coordinates of the two nodes that will be added to the frame.  Note that the third parameter contains only a single scalar value for the z coordinate; this value will be applied to all nodes added to the frame.

 

A further benefit of using lists is that the properties of the items can be set much more readily.  For example, if all the nodes added by the above code were to be pinned, then this could be done using the line of code

myNodeList.Pinned = true

Of course adding nodes and then connecting them with elements is not necessary in the Multiframe automation interface, elements can be added directly and the appropriate nodes will be created automatically.  A more efficient example of adding a small portal frame might be coded as

Dim objElList as New Multiframe.ElementList
Dim x1,y1 as Variant
Dim x2,y2 as Variant
Dim width,hcol,hapex as Double

’Input width and height of portal frame here
width=12.5
hcol=4.5
hapex=6.2

’Create arrays with coordinates of element ends
x1 = Array(0.0,0.0,width/2,width)      ‘Array with x coord
x2 = Array(0.0,width/2,width,width)
y1 = Array(0.0,hcol,hapex,hcol)
y2 = Array(hcol,hapex,hcol,0.0)

’ Create portal frame
With myFrame.Nodes
  Set objNodeList = .AddElements(x1,y1,0.0,x2,y2,0.0)
End With

Although this discussion has concentrated on creating nodes and elements, most collections within the Multiframe object model have method by which multiple items can be created using a single subroutine call.  A full description of list objects in presented in Chapter 10.