1221x
004337
2020-02-07

Question

How can I calculate only specific load cases, load combinations, or result combinations using a command with the COM interface?


Answer:

In order to calculate only specific load cases, load combinations, or result combinations in the same way as the "To Calculate..." command (see Image 01), you can use the CalculateBatch method of the ICalculation interface. For the transfer, the method expects a field with loads of the Loading type. This Loading includes the number of the load and the type (for example, a load combination):

Sub batch_test()
    
'   get interface from the opened model and lock the licence/program
    Dim iModel As RFEM5.IModel3
    Set iModel = GetObject(, "RFEM5.Model")
    iModel.GetApplication.LockLicense
    

On Error GoTo e
    
    '   get interface for calculation
    Dim iCalc As ICalculation2
    Set iCalc = iModel.GetCalculation
    
    '   create array with loading types
    Dim loadings(3) As Loading
    loadings(0).no = 1
    loadings(0).Type = LoadCaseType
    
    loadings(1).no = 4
    loadings(1).Type = LoadCaseType
    
    loadings(2).no = 4
    loadings(2).Type = LoadCombinationType
    
    '   calculate all loadings from the array at once
    iCalc.CalculateBatch loadings

e:  If Err.Number <> 0 Then MsgBox Err.description, , Err.Source
    
    Set iModelData = Nothing
    iModel.GetApplication.UnlockLicense
    Set iModel = Nothing

End Sub