Ansys Products

Ansys Products

Discuss installation & licensing of our Ansys Teaching and Research products

ACT Mechanical Coordinates Units

TAGGED: ,

    • Azmin Zamsanirani
      Subscriber

      Im doing a ACT entension to find the node with the average temperature. I manage to do it but the coordinates is diplaying in unit U.S Customary (In) only. How can I make it flexible which mean it will change when the user change the unit from the Home tab.




    • mjmiddle
      Ansys Employee

      unit="Coordinate" is not a valid unit string. Try unit="Length"

      Valid strings for units are seen in "units>unit systems" in column A from the project schematic workbench page.

    • mjmiddle
      Ansys Employee

      Also, the default usually has a quantity:

      default="0.0 [m]"

      • Azmin Zamsanirani
        Subscriber

         

        Thank you, It is currently functioning; however, the coordinates' initial values after evaluation will consistently be in inches ("in"). The problem arises when opening ANSYS Mechanical with the unit system set to another unit. For example, if your current unit is set to "meters," and you evaluate a coordinate that is originally in inches (e.g., 0.2 inches), the software might display it as "0.2 m," which is meters. The only way to make it work as it should currently is to set the units in inches before evaluating the result.

         

    • mjmiddle
      Ansys Employee

       

       

    • mjmiddle
      Ansys Employee

       

      When your python code sets the value, you have to get the current unit and convert:

          import units
          #toUnit = ExtAPI.DataModel.CurrentUnitFromQuantityName(“Length”)
          toUnit = result.Properties[“MyProperty”].GetCurrentUnit()    # assuming unit=”Length” in property in XML
          fromUnit = ‘m'
          result.Properties[“MyProperty”].Value = units.ConvertUnit(2.54, fromUnit, toUnit)

       

      • Azmin Zamsanirani
        Subscriber

        Thank you so much. It is now working after some modification I did but may I know where does units library and GetCurrentUnit() come from? Because I cant find both of it from global python documentation nor the ANSYS API and XML reference.

    • mjmiddle
      Ansys Employee

      The units module is in the Ansys installation at:

      ANSYS Inc\v{version}\Addins\ACT\libraries\Mechanical\units.py

      It is dicussed in the Ansys online documentation (https://ansyshelp.ansys.com/):
      "Customization Suite > ACT Developer's Guide > Extensions > Libraries and Advanced Programming > Function Libraries"
      Example at:
      "Mechanical Application > Scripting in Mechanical Guide > Scripting Examples > Script Examples for Interacting with Tree Objects > Transform Coordinate Systems (with Math)"

      You can use the basic python command dir() with an object inside the parentheses to see the objects underneath it. So with some exploration you could find the GetCurrentUnit() under the property.

Viewing 5 reply threads
  • You must be logged in to reply to this topic.