STAAD.Pro Help

OS. Retrieve Dynamic Output

The following example macro uses several OpenSTAAD dynamic output functions to build a mode shape report for the results of a dynamic analysis.

About this Example

This macro first verifies if analysis results are available. If so, it then begins printing information into a text results file. If the number of modes extracted are greater than zero, then the modal frequencies, mass modal participation factors, and modal deflections are printed to this report.

This code can be saved to a .vbs file directly or pasted into the macro editor in a macro project for use in STAAD.Pro.

Visual Basic Code

Option Explicit

Sub Main()
    Dim stdFile As String
    Dim stdFolder As String
    Dim rptFile As String
    Dim Tokens() As String
    Dim boolResults As Boolean

    Dim objOpenSTAAD As Object

    Set objOpenSTAAD = GetObject(,"StaadPro.OpenSTAAD")
    objOpenSTAAD.GetSTAADFile(stdFile, False)

    If objOpenSTAAD.Output.AreResultsAvailable = "True" Then
        Tokens = Split(stdFile,".")
        rptFile = stdFolder + "\" + Tokens(0) + ".ModeShapeData.txt"
        CreateModeShapeReport(rptFile, objOpenSTAAD, stdFile)
        MsgBox("No analysis results available for this input file",vbOkOnly,"Error")
    End If

    Set objOpenSTAAD = Nothing

End Sub

Private Function CreateModeShapeReport(rptFile As String, objOpenSTAAD As Object, stdFile As String)
 Dim I As Integer, J As Integer
 Dim nNodeCount As Long
 Dim nModeCount As Long
 Dim nModeNo As Long
 Dim strLenUnit As String
 Dim setOfNodes() As Long
 Dim setOfFrequency() As Double
 Dim modVal(6) As Double

 Dim szName As String
 Dim tblno As Long
 Dim rptno As Long
 Dim idx As Long

 Dim geometry As OSGeometryUI
 Dim Output As OSOutputUI
 Set geometry = objOpenSTAAD.Geometry
 Set Output = objOpenSTAAD.Output

 nNodeCount = geometry.GetNodeCount()

'Variant GetNoOfModesExtracted();
 nModeCount = Output.GetNoOfModesExtracted()

 Open rptFile For Output As #10
 Print #10, "Mode Shape Data Report for",stdFile
 Print #10, ""
 Print #10, Space$(3);"No of Nodes  = ";nNodeCount
 Print #10, Space$(3);"No of Modes Extracted = ";nModeCount
 Print #10, ""

 If nModeCount > 0 Then

     ReDim setOfNodes(nNodeCount)
     ReDim setOfFrequency(nModeCount)

'Variant GetModeFrequency(Variant varMode, Variant varFreq);
     Print #10, "Mode      Frequency (Hz)"
     Print #10, "-------------------------"
     For I = 0 To nModeCount - 1
        nModeNo = I+1
        Output.GetModeFrequency(nModeNo, setOfFrequency(I))
        Print #10, nModeNo;Space$(10);Format$(setOfFrequency(I),"Standard")
     Print #10, "-------------------------"
     Print #10,

'Variant GetModalMassParticipationFactors(Long longMode, Variant varfactorX, Variant varfactorY, Variant varfactorZ);
    Dim Participation(3) As Double
    Dim ParticipationSum(3) As Double
    Print #10, Space$(18);"Modal Participation Factors Table"
    Print #10, "Mode    Participation X (%)    Participation Y (%)    Participation Z (%)"
     Print #10, "-------------------------------------------------------------------------"
     For I = 0 To nModeCount - 1
        nModeNo = I+1
        Output.GetModalMassParticipationFactors(nModeNo, Participation(1), Participation(2), Participation(3))
        Print #10, nModeNo;Space$(10);Format$(Participation(1),"#0.00"); Space$(20); Format$(Participation(2),"#0.00"); Space$(20); Format$(Participation(3),"##0.00")
        ParticipationSum(1) = ParticipationSum(1) +Participation(1)
        ParticipationSum(2) = ParticipationSum(2) +Participation(2)
        ParticipationSum(3) = ParticipationSum(3) +Participation(3)
     Print #10, "-------------------------------------------------------------------------"
     Print #10, "Sum";Space$(9);Format$(ParticipationSum(1),"#0.00"); Space$(20); Format$(ParticipationSum(2),"#0.00"); Space$(20); Format$(ParticipationSum(3),"#0.00")
     Print #10,

'Variant GetModalDisplacementAtNode(Variant varMode, Variant arNode, Variant varModalDisps);

     Print #10, Space$(10);"Modal Displacements Table"
     Print #10, "Mode  Node         x            y             z"
     Print #10, Space$(18);"(";strLenUnit;")";Space$(9);"(";strLenUnit;")";Space$(10);"(";strLenUnit;")"
     Print #10, "--------------------------------------------------"
     For I = 0 To nModeCount - 1
        nModeNo = I+1
        For J = 0 To nNodeCount - 1
            Output.GetModalDisplacementAtNode(nModeNo, setOfNodes(J), modVal)
            Print #10, Format$(nModeNo,"00");Space$(5);Format$(setOfNodes(J),"000");Space$(5);Format$(modVal(0),"Scientific");Space$(5);Format$(modVal(1),"Scientific");Space$(5);Format$(modVal(2),"Scientific")
        Next J
     Next I
     Print #10, "--------------------------------------------------"
     Print #10,

'The following function is currently not operational:-
'Variant GetMissingMassParticipationFactors

 End If

Close #10

End Function