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?

Parents
  • 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.



  • Thank you very much! Just a follow up on the issue presented by Karthik. Is there an alternative to the Application.Wait method? I would like my next iteration to run directly after the previous analysis is finish. The simple attempt I made was:

    obj.analyze()

    While Not obj.AreResultsAvailable()

    Wend

    I found this method to be insistent, which I assume is because obj.analyze() uses a separate thread and might not change AreResultsAvailable() before I get to my loop, and will result in the AreResultsAvailable() from the previous iteration analysis.

  • AreResultsAvailable function checks whether the analysis results are available or not. It doesn't have the intelligence to understand whether any analysis is running in the background or not. So Application.Wait function is used to pause the code till the analysis is completed. There is another function available which can check if any analysis is running. You can use IsAnalyzing() function as -- 

    Dim stat As Boolean
    Set suro = GetObject(, "StaadPro.OpenSTAAD")

    stat = suro.IsAnalyzing()

    This will report if analysis is running (True) or not (False). Also you can define it as Long variable (1 or 0 value respectively).



  • So, my new solution is:

    sp.analyze()

    While sp.isAnalyzing()

    Wend

    Wait(0.5)

    I have been playing around with this, and it works relatively well... however, it seems I'm still running into a bit of a bug where the IsAnalyzing returns False but I get an error when trying to extract NodeDisplacements. I feel like it would be better if I had the abaility to Set the AreAnalysisResultsAvailable Flag. That way, I could reset it before the analysis and let the analysis command set it back when results are available. Then, I would always know that the new results are available.

Reply
  • So, my new solution is:

    sp.analyze()

    While sp.isAnalyzing()

    Wend

    Wait(0.5)

    I have been playing around with this, and it works relatively well... however, it seems I'm still running into a bit of a bug where the IsAnalyzing returns False but I get an error when trying to extract NodeDisplacements. I feel like it would be better if I had the abaility to Set the AreAnalysisResultsAvailable Flag. That way, I could reset it before the analysis and let the analysis command set it back when results are available. Then, I would always know that the new results are available.

Children
No Data