elif ( Parametric )

  • Elif code follows if code (and may also follow elif code) in a Python script. It provides an alternative course of action when the previous if or elif statement is not true.

Also see :


Example :

The following example shows if and elif code blocks in a Python script that first prompts the user to " Select a member ," then opens a dialog box with " mem type ," " left wp ," and " wp to wp " buttons. The button that the user presses determines which results are sent to the report viewer . How this example was put together is explained in the step-by-step instructions . Please note that, since Units("feet") is specified, the output will be in decimal inches, no matter what the primary dimension " Units " are in setup.

# Select member, press 1 of 3 buttons; results are printed. 
from param import Units, yes_or_no, ClearSelection 
from member import MemberLocate
Units("feet") # sets output to decimal inches
mem1 = MemberLocate("Select a member") 
var = yes_or_no("press a button", "mem type", "left wp", "wp to wp") 
if var is "mem type": 
    print("Member type = ", mem1.Type)
elif var is "left wp": 
    print("Left work point = ",)
mem1.LeftEnd.Location 
elif var is "wp to wp": 
    print("Workpoint to work point =", mem1.RightEnd.Location.Distance(mem1.LeftEnd.Location))
ClearSelection()

Tip: See Copying and Pasting scripts from Help for information on how to paste these scripts into blank .py text files that you can Run as parametrics in Modeling .