Run Analysis Iteratively in a loop using OpenSTAAD VBA

Is there a way to run analysis in a iterative loop using OpenSTAAD. For example, I would like to run analysis 15 times while changing a certain parameter each time. I tried using 'objOpenSTAAD.Analyze' in a loop but after each iteration as follows 

    For i = 1 To 3
    'Run Analysis
        objOpenSTAAD.Analyze
        'Change to Postprocessing
        objOpenSTAAD.View.SetInterfaceMode 1
        lLoadCase = 1
        lNodeNo = 8
        'Get Nodal Displacement
        objOpenSTAAD.Output.GetNodeDisplacements lNodeNo, lLoadCase, Disp
        Sheet4.Cells(3 + i, 2).Value = Disp(0)
        objOpenSTAAD.View.SetInterfaceMode 0
    Next i

BUT

I have to manually click on 'Go to postprocessing' radio button and then chick on the load case for which the results need to be viewed etc. I want to avoid manual intervention. Any help or example problem please?

  • You can do this using few OpenSTAAD functions. As you have mentioned that you want to automate the whole process so that no inputs or controls are required during the run, so you need to eliminate the analysis pop-up window using the silent analysis method --

    obj.SetSilentMode (1)

    Also you need to store all the inputs in an array variable, create a loop which changes the model with relevant input before analysis and then analyze the model. Don't forget to introduce an application wait time function to freeze the program during analysis.

    If you want to extract any data from STAAD model, you can add the relevant OpenSTAAD function after the analysis function. It is better to add analysis status check OpenSTAAD function to check the analysis completion status before extracting any result. 



    Answer Verified By: Surojit Ghosh 

  • Hi Suro,

    obj.SetSilentMode(1) did the trick, I also added Application.Wait as suggested by you. Thank you very much. I however need another suggestion. In this loop of mine, I am trying to play with different breadths and widths for say a set of beams and columns. So in each iteration, I use the following commands to assign the new breadth and depth to the column and beams

    Property_Beam = objOpenSTAAD.Property.CreatePrismaticRectangleProperty(b2, b2)
    'Columns
    Property_Col = objOpenSTAAD.Property.CreatePrismaticRectangleProperty(b1, b1)
    'Beams

    and then assign the above property ids to corresponding members.

    Unfortunately my number of iterations are of the order 10000 to 100,000 and 2 member properties are getting added in each run.. I am not sure if the STAADs GUI can save those many member properties. 

    Iteration number is so huge because I am calculating the probability of failure of the structure. So I have to play with a huge set of breadths and widths

    My question : Is there a way to delete a member property via OpenStaad by keying in a certain properly ID? If the answer is no, do you think STAAD can handle 100,000 property ids in its GUI? I tried 100 runs and it worked well. But afraid to go beyond that

    Thanks in advance,

    Regards,

    Karthik 

  • Use the following function to delete a property reference --

    Property.DeleteProperty reference_no

    This function will delete a property value from the property table. Just add this command in your code and provide the property reference number which you have stored in the previous step during new property creation.



  • My apologies for reopening this thread. But I found this answer very helpful... I am wondering why these methods are not given in the OpenSTAAD documentation... is there a more up to date document that I am missing?

  • In STAAD.Pro CONNECT Edition version, a more informative and updated OpenSTAAD manual has been provided. But we notice few functions are still not documented. Our development team has been working on this, to update the OpenSTAAD help manual and in the future release of STAAD.Pro, you can find a updated manual with lots of more information.
    Meanwhile, if you need any information about OpenSTAAD, you can post your query here or create a service request. I will get back to you with relevant information.