Hi,
I have the below code which interfaces with a matrix i have created in excell/VBA.
I want to create the loadcase, this code works, and then add the reference load say "R1" to the load case with a load factor as per the image below. The reference loads have already been created successfully. How can I achieve this?
'Define Load Cases
Dim RefLoadNo As DoubleDim RefLoadName As StringDim RefLoadType As Long
Dim LoadCaseName As StringDim LoadCaseType As LongDim LoadCaseNo As DoubleDim LoadFactor As Double
For j = 2 To UBound(Load_Matrix(), 2) 'i=2 at start as i=0 is the loacombination row and i=1 is loadcombination name row LoadCaseName = Load_Matrix(1, j) LoadCaseType = 22 ' Type "NONE" LoadCaseNo = Load_Matrix(0, j) ObjOPENSTAAD.Load.CreateNewPrimaryLoadEx2 LoadCaseName, LoadCaseType, LoadCaseNo ' in form LoadCaseName, LoadCaseType, LoadCaseNo For i = 2 To UBound(Load_Matrix(), 1) RefLoadNo = CDbl(RemoveFirstChars(CVar(Load_Matrix(i, 0)), 1)) ' this results in a reference load case number of 1 rather than R1. LoadFactor = Load_Matrix(i, j) ObjOPENSTAAD.Load.AddLoadRefEx2 LoadCaseNo, RefLoadNo, LoadFactor ' in form LoadCase, Node, Factor Next i
Next j
Best Regards,
Tom
Yes, you need to use AddReferenceLoad function.
I would like to mention one thing here that the datatype of the Primary or Reference Load case number should be Long instead of Double
Sample VBA Syntax is
Set objOpenSTAAD = GetObject(, "StaadPro.OpenSTAAD")Dim LoadCaseNo As LongDim RefLoadNo(2) As LongDim LoadFactor(2) As Double
LoadCaseNo = 1objOpenSTAAD.Load.SetLoadActive LoadCaseNo
RefLoadNo(0) = 2RefLoadNo(1) = 4RefLoadNo(2) = 5
LoadFactor(0) = 1.2LoadFactor(1) = 1LoadFactor(2) = 0.9
objOpenSTAAD.Load.AddReferenceLoad RefLoadNo, LoadFactor
Answer Verified By: Tom Pallister
The answer is
ObjOPENSTAAD.Load.AddLoadRefEx2 LoadCaseNo, RefLoadNo, LoadFactor ' in form LoadCase, Node, Factor
to be replaced with
ObjOPENSTAAD.Load.SetLoadActive LoadCaseNo
ObjOPENSTAAD.Load.AddReferenceLoad RefLoadNo, LoadFactor