Dear sir,
I am trying to develop a VBA macro in Excel in order to retrieve Member end displacements from Staad Pro (v20.07.11.82).
The following code is used, with OpenSTAAD functions Shown in Red not working properly.
Public Sub Check_Deflection()
Dim Input_Worksheet As StringDim Output_Worksheet As StringDim Input_Row_P1 As IntegerDim Input_Row_PA As Integer
Dim BeamNumsCount As LongDim BeamNums() As LongDim MemberEndDis(6) As LongDim MemberForces(6) As DoubleDim MemberNo As LongDim MemberEnd As Long ' 0 is start, 1 is EndDim LoadCase As LongDim TempDis(6) As Long
Dim i As IntegerDim j As IntegerDim k As IntegerDim L As IntegerDim m As IntegerDim n As IntegerDim Count As IntegerDim ObjOPENSTAAD As ObjectDim PrimaryLCs As Integer, LoadCombs As Integer, totalLoads As Integer
Dim STAAD_Path As StringDim STAAD_Name As StringDim WB_Path As StringDim WB_Name As StringDim stdFile As String
Input_Worksheet = "Results"Output_Worksheet = "Results"
Worksheets(Input_Worksheet).Activate
STAAD_Path = Range("B1").ValueSTAAD_Name = Range("B2").Value
'Get OpenSTAAD Libary and set the file name of the STAAD Document to be interporated.Set ObjOPENSTAAD = GetObject(, "StaadPro.OpenSTAAD") ' Must have STAAD Model open for this line to workObjOPENSTAAD.openstaadfile STAAD_Path & STAAD_Name
'Wait for the STAAD File to loadApplication.Wait (Now + TimeValue("0:00:10"))
'Load your STAAD file - make sure you have successfully run the fileObjOPENSTAAD.GetSTAADFile stdFile, "TRUE"
If stdFile = "" Then MsgBox "This macro can only be run with a valid STAAD file loaded.", vbOKOnly Set ObjOPENSTAAD = Nothing Exit SubEnd If
'check brace and chord member numbers exist in modelBeamNumsCount = ObjOPENSTAAD.Geometry.GetMemberCount()ReDim BeamNums(BeamNumsCount - 1)ObjOPENSTAAD.Geometry.GetBeamList BeamNums
'Find out how many primary load cases and load combinations you have:-PrimaryLCs = ObjOPENSTAAD.Load.GetPrimaryLoadCaseCount()
MemberNo = 6MemberEnd = 0LoadCase = 1
ObjOPENSTAAD.Output.GetMemberEndDisplacements MemberNo, MemberEnd, LoadCase, MemberEndDis
For i = 0 To UBound(MemberEndDis()) - 1 Cells(4 + i, 1) = MemberEndDis(i) * 1000 TempDis(i) = MemberEndDis(i) * 1000Next i
ObjOPENSTAAD.Output.GetMemberEndForces MemberNo, MemberEnd, LoadCase, MemberForces
For i = 0 To UBound(MemberForces()) - 1 Cells(4 + i, 2) = MemberForces(i) * 1000 TempDis(i) = MemberForces(i) * 1000Next i
'Release OpenSTAAD objectObjOPENSTAAD.closestaadfile
' Type the following statement to close the instance of the OpenSTAAD objectSet ObjOPENSTAAD = NothingEnd Sub
Please change the data type of variable MemberEndDis from Long to Double
Answer Verified By: Tom Pallister
Thanks, I've updated that but still get the same issue for both: ObjOPENSTAAD.Output.GetMemberEndDisplacements
and
ObjOPENSTAAD.Output.GetMemberEndForces
The arrays are both returning 0 values.
Can you please install the latest version of STAAD.Pro CONNECT Edition (22.12.00.142) and check the issue?
I've replaced ObjOPENSTAAD.GetSTAADFile stdFile, "TRUE"
with
ObjOPENSTAAD.GetSTAADFile stdFile, CStr("TRUE")
That has worked along with changing MemberEndDis to type Double. Forces are now extracting and the displacements were showing 0 as this is the relative displacement I assume? The STAAD results also show the end node displacements as 0, so function is working the values are just 0.