TAGGED: act, mechanical
-
-
August 2, 2023 at 7:50 am
-
August 4, 2023 at 11:27 pm
-
August 4, 2023 at 11:31 pm
mjmiddle
Ansys EmployeeAlso, the default usually has a quantity:
default="0.0 [m]"
-
August 7, 2023 at 9:15 am
Azmin Zamsanirani
SubscriberThank 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.
-
-
August 14, 2023 at 11:11 pm
mjmiddle
Ansys Employee -
August 15, 2023 at 10:25 am
mjmiddle
Ansys EmployeeWhen 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)-
August 17, 2023 at 7:41 am
Azmin Zamsanirani
SubscriberThank 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.
-
-
August 18, 2023 at 1:32 am
mjmiddle
Ansys EmployeeThe 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.
-
- The topic ‘ACT Mechanical Coordinates Units’ is closed to new replies.
-
3407
-
1057
-
1051
-
896
-
882
© 2025 Copyright ANSYS, Inc. All rights reserved.