Created
October 14, 2025 10:35
-
-
Save stephensmitchell/d709fc24fa1bf21536707500f601f8b1 to your computer and use it in GitHub Desktop.
Parameters with Units
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #https://help.alibre.com/articles/#!alibre-help-v28/parameters-with-units | |
| # this script uses inches for it's units | |
| Units.Current = UnitTypes.Inches | |
| MyPart = Part('Foo') | |
| # create parameter using current script units | |
| LengthParam = MyPart.AddParameter('Length', ParameterTypes.Distance, 123.4) | |
| # parameter value reads back in current script units | |
| print 'Value in script units =', LengthParam.Value | |
| # cteate parameter in degrees | |
| RotationParam = MyPart.AddParameter('Rotation', ParameterTypes.Angle, 34.2) | |
| # parameter reads back in degrees | |
| print 'Value in degrees = ', RotationParam.Value | |
| # create parameter with specific units | |
| WidthParam = MyPart.AddParameter('Width', ParameterTypes.Distance, ParameterUnits.Centimeters, 7.32) | |
| # reads back in current script units | |
| print 'Value in script units = ', WidthParam.Value | |
| # reads back the actual value we wrote | |
| print 'Value we wrote = ', WidthParam.RawValue | |
| # create parameter with specific units | |
| WidthParam2 = MyPart.AddParameter('Width2', ParameterTypes.Distance, ParameterUnits.Inches, 1.0) | |
| # reads back in current script units | |
| print 'Value in script units = ', WidthParam2.Value | |
| # reads back the actual value we wrote | |
| print 'Value we wrote = ', WidthParam2.RawValue | |
| # create parameter with no units | |
| Count = MyPart.AddParameter('Count', ParameterTypes.Count, ParameterUnits.Unitless, 45) | |
| # reads back value | |
| print 'Count value = ', Count.Value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment