Openstaad Plate Stresses and Moments

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 here
Dim loadcase_lower As String
Dim loadcase_upper As String
Dim ListArray1(0 To 1) As String
Dim 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.textbox1
loadcase_upper=dlg.textbox2

Dim loadcase_lint As Long
loadcase_lint =CInt(loadcase_lower)
Dim loadcase_uint As Long
loadcase_uint =CInt(loadcase_upper)

Dim staad As Object
Dim no_loadcases_total, no_loadcases As Long
Dim lcenterstressesarray(0 To 7) As Long
Dim templcenterstressesarray(0 To 7) As Long
Dim checker,tempchecker As Double
Dim i,j,k,ind, plate_id,loadcase_id,no_selplates As Long

If dlg.Droplistbox1=0 Then
ind=2
Else
ind=3
End If


Set staad=GetObject(,"staadpro.openstaad")
no_selplates=staad.geometry.getnoofselectedplates
ReDim selplates(0 To no_selplates-1) As Long
staad.geometry.getselectedplates selplates
MsgBox "the no of selected plates" &no_selplates, vbOkOnly

no_loadcases_total=staad.load.getprimaryloadcasecount
ReDim loadcase_total(0 To no_loadcases_total-1) As Long
staad.load.getprimaryloadcasenumbers loadcase_total

no_loadcases=loadcase_uint-loadcase_lint+1
MsgBox "no_loadcases:" &no_loadcases
ReDim loadcase(0 To no_loadcases-1) As Long
For i=0 To no_loadcases-1
loadcase(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 Then
checker=templcenterstressesarray(ind)+Abs(templcenterstressesarray(4))
Else
checker=templcenterstressesarray(ind)-Abs(templcenterstressesarray(4))
End If

For i=1 To no_selplates-1
For j=0 To no_loadcases-1
plate_id=selplates(i)
loadcase_id=loadcase(j)
staad.Output.getallplatecenterstressesandmoments(selplates(i),loadcase(j),lcenterstressesarray)

If lcenterstressesarray(ind)>0 Then
tempchecker=lcenterstressesarray(ind)+Abs(lcenterstressesarray(4))
Else
tempchecker=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 If
Else
 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 If
End If
Next j
Next i

MsgBox "plate_id" &plate_id
MsgBox "loadcase_id" &loadcase_id
For i=0 To 7
MsgBox "load:" &templcenterstressesarray(i)
Next i

 'TODO: Add your code here

End Sub

Parents
  • Try using the function as the following:

    staad.Output.GetAllPlateCenterStressesAndMoments plate_id, loadcase_id, templcenterstressesarray

    Does this work?

    In case not can you please let us know which VBA editor are you using?

    I will then look into your macro in more details.

    Sudip Narayan Choudhury

  • Hi Sudip,

    I tried your definition of the function. Output hasn't changed, Its still the same, I am getting the same error when I am using Double Datatype and all zeros when I am using Long. I don't know which VBA editor I am using (how can I find out?), but I can tell you where I am opening it. I am creating it by going to Edit->Create new VB Macro.
  • Hi,

    I have reviewed your code. The problem was with the following command lines--

    staad.Output.getallplatecenterstressesandmoments(plate_id,loadcase_id,templcenterstressesarray)

    If templcenterstressesarray(ind)>0 Then

    I have modified the code and also changed the variable type of the stress array to Double and now the correct values are reported. I have attached the code in .txt format. Change the extension to .vbs and import the same in STAAD.

    Sub Main()
    Dim loadcase_lower As String
    Dim loadcase_upper As String
    Dim ListArray1(0 To 1) As String
    Dim 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.textbox1
    loadcase_upper=dlg.textbox2
    
    Dim loadcase_lint As Long
    loadcase_lint =CInt(loadcase_lower)
    Dim loadcase_uint As Long
    loadcase_uint =CInt(loadcase_upper)
    
    Dim staad As Object
    Dim no_loadcases_total, no_loadcases As Long
    Dim lcenterstressesarray(0 To 7) As Double
    Dim templcenterstressesarray(0 To 7) As Double
    Dim checker,tempchecker As Double
    Dim i,j,k,ind, plate_id,loadcase_id,no_selplates As Long
    
    If dlg.Droplistbox1=0 Then
    ind=2
    Else
    ind=3
    End If
    
    
    Set staad=GetObject(,"staadpro.openstaad")
    no_selplates=staad.geometry.getnoofselectedplates
    ReDim selplates(0 To no_selplates-1) As Long
    staad.geometry.getselectedplates selplates
    MsgBox "the no of selected plates" &no_selplates, vbOkOnly
    
    no_loadcases_total=staad.load.getprimaryloadcasecount
    ReDim loadcase_total(0 To no_loadcases_total-1) As Long
    staad.load.getprimaryloadcasenumbers loadcase_total
    
    no_loadcases=loadcase_uint-loadcase_lint+1
    MsgBox "no_loadcases:" &no_loadcases
    ReDim loadcase(0 To no_loadcases-1) As Long
    For i=0 To no_loadcases-1
    loadcase(i)=loadcase_total(loadcase_lint -1+i)
    Next i
    
    i = 0
    j = 0
    staad.Output.getallplatecenterstressesandmoments (selplates(i), loadcase(j), templcenterstressesarray)
    
    If templcenterstressesarray(ind)>0 Then
    checker=templcenterstressesarray(ind)+Abs(templcenterstressesarray(4))
    Else
    checker=templcenterstressesarray(ind)-Abs(templcenterstressesarray(4))
    End If
    
    For i=1 To no_selplates-1
    For j=0 To no_loadcases-1
    plate_id=selplates(i)
    loadcase_id=loadcase(j)
    staad.Output.getallplatecenterstressesandmoments(selplates(i),loadcase(j),lcenterstressesarray)
    
    If lcenterstressesarray(ind)>0 Then
    tempchecker=lcenterstressesarray(ind)+Abs(lcenterstressesarray(4))
    Else
    tempchecker=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 If
    Else
     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 If
    End If
    Next j
    Next i
    
    MsgBox "plate_id" &plate_id
    MsgBox "loadcase_id" &loadcase_id
    For i=0 To 7
    MsgBox "load:" &templcenterstressesarray(i)
    Next i
    
    End Sub
    



    Answer Verified By: Aravind Basavaraju 

  • Hi
    Can you develop a similar code for getting the output in Excel format for P, Mx,My,Mz (Maximum & Minimum Load case only) for all the beam/column members. I want the output in Excel format similar to "Max Force Envelope command".
  • Hi Suro,

    Thanks to your changes I am now getting the outputs. But my second query is still unanswered, Can you help me out with that? For now as I was testing, I just printed the outputs in a message box. But,I wanted to export these stresses and moments to an excel sheet which I can use for design.
  • Hi,

    Yes I think I can get outputs for beam column members as well. But how to export the outputs to excel, that is still unclear. I have raised a query for that as well. Hopefully, I will get a solution for that problem in this thread itself.
  • 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



Reply Children