Greetings STAAD fans,
I am developing a VBA to the get the list of beams and after a couple of tries I have notice that the OpenSTAAD | GetBeamList command is not working.
Any suggestions?
See the following VBA Macro
Sub GetBeamList()
On Error GoTo Handler1:
'Exit Sub
'Handler1:
'MsgBox "Error: Open Bentley STAAD Pro and/or define file path in Excel STAAD Tab "
'Variables
Dim objOpenSTAAD As Object 'STAAD object
Dim lBeamCnt As Long 'STAAD BeamCount
Dim strFileName As String 'File Path STAAD
Dim RowsN As Long 'nodes
Dim ColmsN As Integer 'nodes and XYZ Coordinates
Dim RowsM As Integer 'members
Dim ColmsM As Integer 'members and nodes i, j
Dim RowsW As Integer 'webs
Dim ColmsW As Integer 'webs and nodes i, j
Dim t As String 'print text
Dim n As Integer 'nodes
Dim m As Integer 'members
Dim w As Integer 'webs
Dim i As Integer 'number of interactions row direction
Dim J As Integer 'number of interactions column direction
'________________________________________________________________________
'
'
' OPEN STAAD FILE VBA
'
'________________________________________________________________________
'
'file Name
strFileName = Sheets("STAAD").Cells(2, 2).Value
'Get the application object
Set objOpenSTAAD = GetObject(, "StaadPro.OpenSTAAD")
'Open the file
'objOpenSTAAD.OpenSTAADFile strFileName
objOpenSTAAD.GetSTAADFile strFileName
'________________________________________________________________________
'
'
' SET WORKSHEET NAME
'
'________________________________________________________________________
'
Dim MinMaxForcesMoments As Worksheet
Dim rn As Range
Set MinMaxForcesMoments = ThisWorkbook.Sheets("MinMaxForcesMoments")
'________________________________________________________________________
'
'
' GET MEMBER LIST ARRAY
'
'________________________________________________________________________
'
Dim BeamNumberArray() As Long 'Beam List Array
'Get Beam Numbers
lBeamCnt = objOpenSTAAD.Geometry.GetMemberCount
MsgBox "Beam Count is " & lBeamCnt
ReDim BeamNumberArray(0 To (lBeamCnt - 1)) As Long
'Get Beam list
For i = 0 To (lBeamCnt - 1)
Sheets("MinMaxForcesMoments").Cells(i + 1, 2).Value = objOpenSTAAD.Geometry.GetBeamList(BeamNumberArray(i))
'MsgBox "Beam Number from list " & objOpenSTAAD.Geometry.GetBeamList(BeamNumberArray(i))
Next i
Set objOpenSTAAD = Nothing
End Sub