Retrieve values of standard Mechanical through scripting

Pernelle Marone-Hitz
Pernelle Marone-Hitz Member, Moderator, Employee Posts: 712
First Anniversary Ansys Employee Solution Developer Community of Practice Member First Answer
edited June 2023 in Structures

Can we retrieve the values of a standard result in Mechanical through scripting?

Tagged:

Answers

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 712
    First Anniversary Ansys Employee Solution Developer Community of Practice Member First Answer
    Answer ✓

    In 2020R2 a new feature was introduced to retrieve the values of a native result inserted in the Mechanical tree. For example, you can insert from the Mechanical GUI (or through automation scripting) a Equivalent Stress result, choose the averaging option, and then retrieve the values:

        standardVonMises=ExtAPI.DataModel.Project.Model.Analyses[0].Solution.AddEquivalentStress() # insert Equivalent Stress result through automation
        standardVonMises.DisplayOption=ResultAveragingType.Averaged # change averaring option 
        standardVonMises.EvaluateAllResults() # evaluate
        plotData=standardVonMises.PlotData # retrieve plot data -> for averaged option, returns an object containing list of body ids, node numbers, and values.
        plotData[0] # list of body ids
        plotData[1] # list of node ids
        plotData[2] # list of values
    

    For example, if plotData.Values[1][0] returns 159 and plotData.Values[2][0] returns 2.7287E+08 then you know that averaged equivalent stress on node 159 is 2.7287E+08 Pa.