I am new to Openstaad and am trying to develop a macro in Openstaad to get Plate center stresses and moments corresponding to Maximum Bending moment,(Sagging/Hogging, Mx/My) for selected plates and selected number of Loadcases. There are two major issues I am facing
1) The command for extracting Plate Center stresses and moments in Openstaad is getallplatecenterstressesandmoments(plate_number, loadcase_number, lplatecenterstressesandmoments), where lplatecenterstressesandmoments is an array of size 8.When I am taking the Data type of lplatecenterstressesandmoments as Long, all the stresses and moments are zero. When I am taking the Datatype of lplatecenterstressesandmoments as Double, then I am getting an error saying " Array Index out of Range", whenever I am trying to address any element of that array.
2) If I want to use the results for my slab or wall design, then how do I link the final array consisting of results to my design spreadsheets
Please find below my code, I have highlighted the line where the problem is. I have added a lot of Message boxes in the code for my own checks, you can ignore them. Please got through it and help me out. Thanks in advance
Sub Main()'DESCRIPTION:Description of the macro goes hereDim loadcase_lower As StringDim loadcase_upper As StringDim ListArray1(0 To 1) As StringDim ListArray2(0 To 1) As String
ListArray1(0)="Mx"ListArray1(1)="My"ListArray2(0)="Max"ListArray2(1)="Min" Begin Dialog UserDialog 400,203 ' %GRID:10,7,1,1 TextBox 230,14,60,21,.TextBox1 Text 30,14,130,21,"Loadcase Lower = ",.Text1 Text 30,56,130,21,"Loadcase Upper = ",.Text2 TextBox 230,49,60,21,.TextBox2 DropListBox 40,98,90,21,ListArray1(),.DropListBox1 DropListBox 240,98,90,21,ListArray2(),.DropListBox2 OKButton 120,140,80,21 End Dialog Dim dlg As UserDialog Dialog dlg
loadcase_lower=dlg.textbox1loadcase_upper=dlg.textbox2
Dim loadcase_lint As Longloadcase_lint =CInt(loadcase_lower)Dim loadcase_uint As Longloadcase_uint =CInt(loadcase_upper)
Dim staad As ObjectDim no_loadcases_total, no_loadcases As LongDim lcenterstressesarray(0 To 7) As LongDim templcenterstressesarray(0 To 7) As LongDim checker,tempchecker As DoubleDim i,j,k,ind, plate_id,loadcase_id,no_selplates As Long
If dlg.Droplistbox1=0 Thenind=2Elseind=3End If
Set staad=GetObject(,"staadpro.openstaad")no_selplates=staad.geometry.getnoofselectedplatesReDim selplates(0 To no_selplates-1) As Longstaad.geometry.getselectedplates selplatesMsgBox "the no of selected plates" &no_selplates, vbOkOnly
no_loadcases_total=staad.load.getprimaryloadcasecountReDim loadcase_total(0 To no_loadcases_total-1) As Longstaad.load.getprimaryloadcasenumbers loadcase_total
no_loadcases=loadcase_uint-loadcase_lint+1MsgBox "no_loadcases:" &no_loadcasesReDim loadcase(0 To no_loadcases-1) As LongFor i=0 To no_loadcases-1loadcase(i)=loadcase_total(loadcase_lint -1+i)Next i
plate_id=selplates(0)loadcase_id=loadcase(0)
staad.Output.getallplatecenterstressesandmoments(plate_id,loadcase_id,templcenterstressesarray)If templcenterstressesarray(ind)>0 Thenchecker=templcenterstressesarray(ind)+Abs(templcenterstressesarray(4))Elsechecker=templcenterstressesarray(ind)-Abs(templcenterstressesarray(4))End If
For i=1 To no_selplates-1For j=0 To no_loadcases-1plate_id=selplates(i)loadcase_id=loadcase(j)staad.Output.getallplatecenterstressesandmoments(selplates(i),loadcase(j),lcenterstressesarray)
If lcenterstressesarray(ind)>0 Thentempchecker=lcenterstressesarray(ind)+Abs(lcenterstressesarray(4))Elsetempchecker=lcenterstressesarray(ind)-Abs(lcenterstressesarray(4))End If
If dlg.droplistbox2=0 Then If tempchecker>checker Then checker=tempcheker plate_id=selplates(i) loadcase_id=loadcase(j) For k=0 To 7 templcenterstressesarray(k)=lcenterstressesarray(k) Next k 'Else 'checker=checker 'plate_id=plate_id 'loadcase_id=loadcase_id 'templcenterstressesarray=templcenterstressesarray End IfElse If tempchecker<checker Then checker=tempcheker plate_id=selplates(i) loadcase_id=loadcase(j) For k=0 To 7 templcenterstressesarray(k)=lcenterstressesarray(k) Next k 'Else 'checker=checker 'plate_id=plate_id 'loadcase_id=loadcase_id 'templcenterstressesarray=templcenterstressesarray End IfEnd IfNext jNext i
MsgBox "plate_id" &plate_idMsgBox "loadcase_id" &loadcase_idFor i=0 To 7MsgBox "load:" &templcenterstressesarray(i)Next i
'TODO: Add your code here
End Sub
Sudip Narayan Choudhury
You can export the results to excel using the same code. One method to export the results to excel is to create a macro enabled excel file (extension .xlsm) and add your code in that excel. You can add a ActiveX control button in the excel and add your code there. You can select the inputs from the excel cells and also extract the values to excel cells. For that, you need to modify your code accordingly. I have added your code in the attached excel file. You need to open only the relevant .std file first and then open the excel and click on the Plate stress tab to extract the results.Plate Center Stress.zip