The Final Script

In the preceding sections a script was developed for generating a simple portal frame.  Each section developed a separate piece of the script.  All of these pieces combine into a single script that is listed below.

Public Sub CreatePortal()

  'Declare variables
  Dim mfApp As New Multiframe.Application
  Dim myLC As Multiframe.LoadCase
  Dim myEl As Multiframe.Element
  Dim myLoad As Multiframe.ElementLoad
  Dim myRest As Multiframe.Restraint
 
  'Set units
  With mfApp.Preferences
    .UnitSet = mfUnitsetAustralian
    Call .SetUnit(mfUnitLength, "m")
    Call .SetUnit(mfUnitForce, "kN")
  End With
 
  'Create elements forming portal frame
  With mfApp.Frame.Elements
    Set myEl = .AddElement(0#, 0#, 0#, 0#, 4#, 0#)
    Set myEl = .AddElement(0#, 4#, 0#, 6#, 5.25, 0#)
    Set myEl = .AddElement(6#, 5.25, 0#, 12#, 4#, 0#)
    Set myEl = .AddElement(12#, 4#, 0#, 12#, 0#, 0#)
  End With
 
  'Set section type 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
 
  'Apply restraints to base of columns
  With mfApp.Frame.restraints
    Set myRest = .AddRestraint(1, mfRestraintFixed)
    Set myRest = .AddRestraint(5, mfRestraintFixed)
  End With
 
  'Add load cases to frame
  With mfApp.Frame.LoadCases
    Call .Item(1).Delete
    Set myLC = .AddCase(mflcSelfWeight, "Self Weight")
    Set myLC = .AddCase(mflcStatic, "Live Load")
    Set myLC = .AddCase(mflcCombined, "DL + 1.25*LL")
  End With
 
  'Define live loads
  With mfApp.Frame.LoadCases(2).ElementLoads
    Set myLoad = .AddLoad(2, mfDOFy, mfLoadshapeUniform, -3.5, 0, -3.5, 0, False)
    Set myLoad = .AddLoad(3, mfDOFy, mfLoadshapeLinear, -3.5, 0, -1.5, 0, True)
  End With
 
  'Set factors for combined load case
  With mfApp.Frame.LoadCases(3)
    .Factor(1) = 1#
    .Factor(2) = 1.25
  End With
 
  'Perform linear analysis
  With mfApp.Frame.Analysis
    .Linear = True
    .Nonlinear = False
    .Analyse
  End With
   
End Sub