Browsed by
Tag: units

Parameters with Units

Parameters with Units

Compatible with WizoScript versions: 1.99

Demonstrates how to add and read parameters in the current script units, with specific units and with no 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
Units

Units

Compatible with WizoScript versions: 1.40

Wizoscript supports different units and they can even be mixed in the same script. This example shows how.

# demonstrates using multiple units in a script
 
# create a part and a sketch
MyPart = Part("My Part")
XYPlane = MyPart.GetPlane("XY-Plane")
Sketch = MyPart.AddSketch("Sketch", XYPlane)
 
# set units to mm - this is implied at the start of every script
Units.Current = UnitTypes.Millimeters
 
# create circle 50mm in diameter
Sketch.AddCircle(0, 0, 50, False)
 
# set units to inches
# all values from now on are in inches
Units.Current = UnitTypes.Inches
 
# create a circle 1.34 inches in diameter
Sketch.AddCircle(0, 0, 1.34, False)
 
# switch to cm
# now all values from this point until the next units change are in cm
Units.Current = UnitTypes.Centimeters
 
# create a circle 4.2cm in diameter
Sketch.AddCircle(0, 0, 4.2, False)