Warning ( Parametric )

  • Warning("Warning String") creates a warning dialog that displays whatever "Warning String" or read-only attribute is entered.
  • An " OK " button is provided so that the user can dismiss the dialog.
  • The script continues to run after the dialog is dismissed.

Also see :

Quick Notes

Examples :

Warning("string") opens a read-only dialog with an "OK" button on it. Pressing the "OK" button returns no value or string. The parametric continues to run after the warning dialog is dismissed. The "string" in Warning("string") is a message to the user who Runs the parametric. The message might, for example, provide instructions to the user, so that the parametric can be Run correctly. Or it might alert the user to a potentially scary event, before that event takes place. Or it might provide read-only results.

Example 1: This warning provides instructions to the user, so that the parametric can be properly Run :

# Demonstrates a use for Warning("string").
from param import Warning
Warning("This parametric requires a brace in solids form.")
# insert code for operating on the brace
The warning dialog that is generated when you Run this script.

Example 2: This warning alerts the user to a potentially scary event, before it takes place:

# Erases the main material of the member the user selects.
from member import MemberLocate, Member
from param import Warning, ClearSelection
mem1 = MemberLocate( "Select a member" )
Warning("The main material on this member \r will be erased after you hit OK.") # \r is a return
mem1.MainMaterial().Erase()
ClearSelection()

Example 3: This warning provides read-only results:

# Displays the dimensions of the selected
  plate.
from mtrl_list import MtrlLocate
from rect_plate import *
from bnt_plate import *
from roll_plate import *
from plate_layout import *
from param import Warning, dim_print, Units
Units("feet")  # sets dim_print output to ft-in frac
try:
    plate1 = MtrlLocate("Select a plate", "Single")
    if plate1.MaterialType == "Plate":    # user selects a plate
        Warning("Plate dimensions are:\r\r"+"Width = " + 
          dim_print(plate1.Width)+"\rThickness = " +
          dim_print(plate1.Thickness) +"\rLength = " +
          dim_print(plate1.OrderLength))
    else:       # user selects a material other than plate
        print("The material you selected is not a plate.")
except AttributeError:        # user selects nothing, hits Esc
    print("You canceled instead of selecting a plate.")
# + operator can be used to concatenate strings
An example of the warning dialog that is generated when you Run this script in Modeling .