("dim", "string")
Also see :
Quick Notes |
- Dimension strings (a dimension is a string, not a number)
- Units("...") (sets the type of distance entries to be used in the script)
- param (module from which Prompt is imported)
- Using a text editor
Please note: A dimension prompt displays the default value -- "1-2 1/4" in the following script -- at Home > Project Settings > Job > Drawing Presentation > Primary Dimension > " Units ." This means that if this script were run with setup's primary dimension " Units " set to ' Metric ', the prompt would show a default value of 362 , but the dim_print value for that default would still be 1-2 1/4 since Units("feet") is specified in the script. To a dimension prompt, you can make entries in other units than those that are displayed when the parametric is Run .
# Converts an imperial dimension to millimeters.
from param import Prompt, ResponseNotOK, Units, dim_print
Units("feet") # sets dim_print output to ft-in frac
try:
inches = Prompt("1-2 1/4", "Enter a dimension:")
mm = inches * 25.4
print("This dimension in ft-in frac =", dim_print(inches))
print("This dimension in decimal inches =", inches)
print("This dimension in mm =", mm)
except ResponseNotOK: # user presses "Cancel"
pass