Prompt(string)

  • When the script is Run an ok-cancel dialog opens with a prompt to enter a sequence of characters.
  • When the user who runs the script presses " OK " on the ok-cancel dialog, the string that in entered to the dialog becomes a variable that is presumably used later in the script.

Also see :

Quick Notes

Examples :

The following Python script lets the user enter different section sizes for multiple members. Note that size in the prompt code in this example ( Size = Prompt(size, "Section size:") ) is not in quotes because it is a variable that returns a string , but is not a string itself. Also note that the Python interpreter is case sensitive, and Size and size are different variables. When the user presses " Cancel " on the dialog, the while loop ends ( break ) and the script stops running. Pressing " Cancel " on a dialog returns ResponseNotOK .

# While loop for changing section sizes of members. Press "Cancel" to end the operation.
from param import Prompt, ResponseNotOK, ClearSelection
from member import MemberLocate
default = "W18x40"
while default:
    try: 
        Size = Prompt(default, "Section size:")
    except ResponseNotOK:        # user presses "Cancel"
        break
    mem1 = MemberLocate("Select a member")
    mem1.SectionSize = Size
    mem1.Update()
ClearSelection()

This next script lets the user enter a " Member description " at a string prompt ( Prompt("CRANE RAIL", "Member description:") ). The user-entered description is then applied using Update to each member ( each_mem ) in a list named mem_list that was created using MultiMemberLocate() .

# Updates "Member description" for multiple members.
from member import MultiMemberLocate
from param import ClearSelection, Prompt, ResponseNotOK
mem_list = MultiMemberLocate("Select members")
try:
    desc = Prompt("CRANE RAIL", "Member description:")
    for each_mem in mem_list:
        each_mem.TypeDescription = desc
        each_mem.Update()
except ResponseNotOK:
    pass
ClearSelection()