This library implements a set of functions to manipulate the unit-dependent quantities within an extension. This library is of particular interest each time quantities have to remain consistent with the current unit system activated in the ANSYS product.
libraries/DesignModeler/materials.py
libraries/ElectonicsDesktop/materials.py
libraries/Fluent/materials.py
libraries/Mechanical/materials.py
libraries/Project/materials.py
libraries/SpaceClaim/materials.py
libraries/Study/materials.py
import units
ConvertUnit(value,fromUnit,toUnit[,quantityName])
This function converts the value from
the unit fromUnit to the unit toUnit. The user can specify the quantity name to avoid conflict during
conversion. This quantity name is not mandatory.
Assume that you enter this command:
import units units.ConvertUnit(1,"m","mm")
A result like this is returned:
1000.0
ConvertUserAngleUnitToDegrees(api, value)
This function converts the angle value to the unit degrees. If the current activated unit is already degrees,
then the value remains unchanged.
Assume that you enter this command:
import units units.ConvertUserAngleUnitToDegrees(api,3.14)
A result like this is returned if the angle unit is set to radius when the command is called:
180
A result like this is returned if the angle unit is set to degrees when the command is called:
3.14
ConvertToSolverConsistentUnit(api, value, quantityName, analysis)
This function converts the value of the quantity
quantityName from the currently activated unit in the ANSYS product
to the corresponding consistent unit used by the solver for the resolution of the analysis
analysis.
Assume that you enter this command:
import units units.ConvertToSolverConsistentUnit(api,1.,”pressure”,”Static Structural”)
A result like this is returned if the unit system is set to Metric(mm,dat,N,s,mV,mA) when the command is called:
10
ConvertToUserUnit(api, value, fromUnit, quantityName)
This function converts the value of the quantity
quantityName from the unit fromUnit to the
currently activated unit system in the ANSYS product.
Assume that you enter this command:
import units units.ConvertToUserUnit(api,1.,”m”,”length”)
A result like this is returned if the current activated unit is millimeter when the command is called:
1000
ConvertUnitToSolverConsistentUnit(api, value, fromUnit, quantityName, analysis)
This function converts the valueof the
quantity quantityName from the unit fromUnit to the consistent unit that is used by the solver
for the resolution of the analysis analysis.
Assume that you enter this command:
import units units.ConvertUnitToSolverConsistentUnit(api,1.,”m”,”length”,”Static Structural”)
A result like this is returned if the consistent unit is millimeter when the command is called:
1000
GetMeshToUserConversionFactor(api)
This function returns the scale factor to be applied to convert a length from the unit associated with the mesh and the currently activated unit in the ANSYS product.
Assume that you enter this command:
import units units.GetMeshToUserConversionFactor(api)
A result like this is returned if the unit associated with the mesh is meter and if the current activated unit in the application is millimeter:
1000