The remainder of this chapter concentrates on the development of simple model for a two dimensional portal frame. The dimensions of the portal frame are shown in the following diagram. The next sections describe how to build the geometry of the frame by defining the nodes and elements that make up the frame. Each section after that then extends the script by adding a new piece of code that defines the restraints, allocates section sizes, applies loads and finally analyses the frame.

Each of these sections begins by introducing a small part of the Multiframe object model. It then uses this in the development of the script for generating the portal frame. The entire script for generating the portal frame is listed at the end of this chapter.
The geometry of a frame is constructed by adding new nodes and elements to the frame. These are created using the AddNode and AddElement methods of the Nodes and Elements collections. The script shown below uses these methods and objects to create the portal frame described above.
Sub CreatePortal()
Dim mfApp As New Multiframe.Application
Dim myFrame As Multiframe.Frame
Dim myNode as Multiframe.Node
Dim myEl as Multiframe.Element
‘Add nodes to frame
Set myNode =
myFrame.Nodes.AddNode(0.0,0.0,0.0)
Set myNode =
myFrame.Nodes.AddNode(0.0,5.0,0.0)
Set myNode =
myFrame.Nodes.AddNode(6.0,5.5,0.0)
Set myNode =
myFrame.Nodes.AddNode(12.0,5.0,0.0)
Set myNode = myFrame.Nodes.AddNode(12.0,0.0,0.0)
’Add Elements by joining nodes
Set myEl =
myFrame.Elements.AddElement(1,2)
Set myEl =
myFrame.Elements.AddElement(2,3)
Set myEl =
myFrame.Elements.AddElement(3,4)
Set myEl =
myFrame.Elements.AddElement(4,5)
End Sub
After the declaration of variables, the script creates the five nodes required to define the portal frame. Each node is created via a single call to the AddNode method which returns a reference to the object that represents the new node. This reference is assigned to the myNode variable that is declared at the start of the script as a Node object. After the nodes have been created, each of the elements representing the members of the portal frame are created by calling the AddElement method, which, like the AddNode method, returns a reference to the object representing the new element. This code assumes that the new nodes are the only nodes in the frame as it requires the nodes be numbered from 1 to 5.
It is not always necessary to create the nodes and then add elements as elements can be created directly by specifying the coordinates at each end of the element. Hence, the piece of code above could be refined to
Sub CreatePortal()
Dim mfApp As New Multiframe.Application
Dim myFrame As Multiframe.Frame
Dim myEl as Multiframe.Element
‘Create elements
Set
myEl=myFrame.Elements.AddElement(0.0,0.0,0.0,0.0,5.0,0.)
Set
myEl=myFrame.Elements.AddElement(0.0,5.0,0.0,6.0,5.5,0.)
Set
myEl=myFrame.Elements.AddElement(6.0,5.5,0.,12.0,5.0,0.)
Set myEl=myFrame.Elements.AddElement(12.0,5.0,0.,12.0,0.,0.)
End Sub
which is far more efficient as it reduces the number of subroutine calls made to Multiframe. When creating elements in this way, Multiframe determines if a node already exists at the specified points and connects the element to the existing node. Otherwise a new node is created to define the end of the element.
Each element within a structure is represented by an Element object. This object can be used to modify the attributes of an element such as its label, end releases or section size. All the Element objects representing the elements of a frame are contained within an Elements collection in the Frame. The Elements collection is arranged in numerical order such that element number 4 is the 4th element in the collection. A reference to the object representing this element would be obtained from the collection as follows
Dim myEl as Multiframe.Element
Set myEl = mfApp.Frame.Elements(4)
All attributes of this element that can be set in Multiframe can also be accessed and modified using the Element object. For example, the orientation and label of the element could be set using the following two lines of code.
myEl.Orientation = 45 ‘Set
orientation to 45 degrees
myEl.Label = ”Beam B2” ‘Set label
The section type associated with an element is set using the SetSection method of the Element object. This method can take a number of different parameters that are used to specify a section from the current sections library. The first and simplest method is to specify the section by the number of the group and the number of the section within the group. The section can also be specified by name, in which case the entire sections library is searched in order to match the name of the section. Examples of each of these methods are
Call myEl.SetSection(1,2)
Call myEl.SetSection(“310UB40”) ‘Australia
Call myEl.SetSection(“W40x480”) ‘United States
Call myEl.SetSection(“150x150x7x10”) ‘Japan
For the portal frame created above, the following piece of code is used to set the section size of each element.
‘Set section size of each element
With mfApp.Frame
Call .Elements(1).SetSection(1, 1)
Call .Elements(2).SetSection(2, 1)
Call .Elements(3).SetSection(2, 1)
Call .Elements(4).SetSection(1, 1)
End With
In this code fragment, the section size is set by specifying the index of the group and section. This allows the script to work with any sections library.
In Multiframe, restraints are not implemented as properties of a node. Instead, they are considered as a separate entity that is associated with a particular node. In this way, several restraints can be applied to a single node. This is reflected in the Multiframe automation model in which each restraint applied to a node is represented by a separate Restraint object. The object contains the attributes of a restraint such as the node to which is applied and the degrees of freedom it restrains. All the restraints within a structure are stored in the Restraints collection in the Frame object.
A new restraint can be applied to a structure by adding a new object to the Restraints collection using the AddRestraint method. This method takes two parameters; the first parameter specifies the node at which the restraint is to be applied. The second parameter specifies the degrees of freedom to be restrained. This parameter can take many forms but the simplest means of identifying the restrained freedoms is using constants representing common type of restrains. For the portal frame we are developing in the example, we need to apply rigid restraints at the 1st and 5th node in the frame. These restraints are added to the model using the following code.
Dim myRestraint as Multiframe.Restraint
With mfApp.Frame.restraints
Set myRestraint = .AddRestraint(1,
mfRestraintFixed)
Set myRestraint = .AddRestraint(5,
mfRestraintFixed)
End With
VBA and Office 97
The VBA language provided in Microsoft Office 2000
contains a number of improvements to the version used within the Office 97
suite of products. A significant difference is in the use of enumerated
types. The Multiframe automation
interface uses many enumerated types to make programming scripts much simpler
when using the latest versions of VBA.
However, when programming using an older version of VBA, such as used in
Office 97, the use of enumerated types is not supported and the enumerated
constants must be replaced with their integer value. The enumerated types and their values are summarised
in Appendix A of this document.
If you were using Office 97, the above script would need to be programmed using
a value of 2 instead of enumerated constant mfRestraintFixed.
You can also import the list of types from the Types module contained in the
Office 97 examples provided with Multiframe.