Sub Get_ALL_Supports()
' Connect to STAAD.Pro
Dim objOpenSTAAD As Object
Dim stdFile As String
Set objOpenSTAAD = GetObject(, "StaadPro.OpenSTAAD")
objOpenSTAAD.GetSTAADFile stdFile, "TRUE"
If stdFile = "" Then
MsgBox "STAAD file not found or not open.", vbCritical
GoTo Cleanup
End If
Dim SupportCount As Long
SupportCount = objOpenSTAAD.Support.GetSupportCount
If SupportCount = 0 Then
MsgBox "No supports found in the model.", vbExclamation
Exit Sub
End If
On Error GoTo ErrorHandler
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
' Create or clear the "AllSupports" sheet
Dim ws As Worksheet
Set ws = Nothing
On Error Resume Next
Set ws = Worksheets("AllSupports")
On Error GoTo 0
If ws Is Nothing Then
Set ws = Worksheets.Add(After:=ActiveSheet)
ws.Name = "AllSupports"
Else
' Clear all contents
ws.Cells.Clear
' Reset outline levels
ws.Outline.ShowLevels RowLevels:=1, ColumnLevels:=1
End If
On Error GoTo 0
' Write headers
Dim headers As Variant
headers = Array("Support Sl No", "Node Number", "Support Type No", "Support Type",
"Support Name", "Support ID", "FX", _
"FY", "FZ", "MX", "MY", "MZ", "KFX", "KFY", "KFZ", "KMX", "KMY", "KMZ")
ws.Range("A5:R5").Value = headers
ws.Range("A2").Value = "SupportCount"
ws.Range("B2").Value = SupportCount
Dim SupportNodesArray() As Long
ReDim SupportNodesArray(0 To SupportCount - 1)
Dim nodeArr As Variant
nodeArr = objOpenSTAAD.Support.GetSupportNodes(SupportNodesArray)
' ' Write data
Dim i As Long
For i = 0 To SupportCount - 1
Dim SupportType As Variant
SupportType = objOpenSTAAD.Support.GetSupportType(SupportNodesArray(i))
Dim supportName As Variant
supportName = objOpenSTAAD.Support.GetSupportName(SupportNodesArray(i))
Dim SupportID As Variant
SupportID = objOpenSTAAD.Support.GetSupportUniqueID(SupportNodesArray(i))
'Gets Extended Support Information
Dim releaseData(5) As Double
Dim springData(5) As Double
Dim supportSpecType As Variant
supportSpecType =
objOpenSTAAD.Support.GetSupportInformation(SupportNodesArray(i), releaseData,
springData)
ws.Cells(i + 6, 1).Value = i + 1
ws.Cells(i + 6, 2).Value = SupportNodesArray(i)
ws.Cells(i + 6, 3).Value = SupportType
ws.Cells(i + 6, 5).Value = supportName
ws.Cells(i + 6, 6).Value = SupportID
Dim j As Integer
For j = 0 To 5
ws.Cells(i + 6, 7 + j).Value = releaseData(j)
ws.Cells(i + 6, 13 + j).Value = springData(j)
Next j
Next i
' Apply XLOOKUP for Country Name
Dim lastRow As Long
lastRow = SupportCount + 5
Dim formulaRange1 As Range
Set formulaRange1 = ws.Range("D6:D" & lastRow)
formulaRange1.Formula =
"=XLOOKUP(C6,'STAAD_SECTION_TYPE_TABLE'!$F$2:$F$16,'STAAD_SECTION_TYPE_TA
BLE'!$G$2:$G$16,""NA"",0)"
' Optional: Create a space-separated list of node IDs in B1
ws.Range("B1").Formula = "=TEXTJOIN("" "", TRUE, B6:B" & lastRow & ")"
' Autofit columns
ws.Columns("C:F").AutoFit
Call LogStatus.LogProgress("All Support data extracted")
Cleanup:
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Set objOpenSTAAD = Nothing
Application.StatusBar = False
Exit Sub
ErrorHandler:
MsgBox "An error occurred: " & Err.Description
Resume Cleanup
End Sub