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

Pernelle Marone-Hitz
Pernelle Marone-Hitz Member, Moderator, Employee Posts: 870
100 Answers 500 Comments 250 Likes First Anniversary
✭✭✭✭
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: 870
    100 Answers 500 Comments 250 Likes First Anniversary
    ✭✭✭✭
    Answer ✓

    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"