How to assign units to a custom result in the python file of an ACT extension?

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

How to assign units to a custom result in the python file of an ACT extension?

Tagged:

Answers

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

    In Mechanical, this can be done by modifying the value of "result.Unit", where "result" is one of the arguments of the function called. Below is an example :

        def OnValidateResultType(result,property):
            if result.Properties["Result Type"].Value == "Length Result":
                result.Unit = "Length"
            
            elif result.Properties["Result Type"].Value == "Force Result":
                result.Unit = "Force"
            elif result.Properties["Result Type"].Value == "Moment Result":
                result.Unit = "Moment"
            elif result.Properties["Result Type"].Value == "Unitless Result":
                result.Unit = "Dimensionless"