MemberLocate ( Parametric )

  • When the script is Run , the user must left-click ( Select ) a member in order for the script to continue to execute. Presumably one or more attributes of that member will later be used as variables in the code.

Also see :


Examples :

The following script , when Run or Tested , first prompts the user to " Select a member ," then prints to the report viewer ( Output-Request Summary ) the member type and work point-to-work point distance of that member on separate lines. How code similar to this was put together is explained in the step-by-step instructions . Please note that, since Units("feet") is specified in this script, the output using dim_print() will be feet-inches fractions , no matter what the specified primary dimension " Units " are in setup.

# Prints member type and work point to work point distance.
from member import MemberLocate
from param import Units, dim_print, ClearSelection
Units("feet")      # affects dim_print
mem1 = MemberLocate("Select a member")
wkpt_dist = mem1.LeftEnd.Location.Distance(mem1.RightEnd.Location)
print(mem1.Type)
print(dim_print(wkpt_dist))
ClearSelection()

This next script uses mem1.Update() to enter a " Section size " to the selected member. Note the use of except to catch the exception that occurs when the user cancels instead of selecting a member.

# Enters a new section size to the selected member.
from member import Member, MemberLocate
from param import ClearSelection
import member # to catch the exception
try:
mem1 = MemberLocate("Select a member")
mem1.SectionSize = "W18x40"
mem1.Update()
except member.error:
print("You canceled without selecting a member!")
ClearSelection()

This script opens a dialog that lets the user enter a different section size for the member that is selected after the dialog closes. Press " Cancel " on the dialog ( Size = Prompt(size, "Section size:") ) to end the while loop ( break ). After the while loop ends, the selection is cleared ( ClearSelection() ), and the script ceases to run.

# While loop for changing section sizes of members. Press "Cancel" to end.
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()