Prompt(string)
Also see :
Quick Notes |
- String (a built-in Python object type)
- param (module from which the Prompt function is imported)
- Using a text editor
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()