##  Beam_ShearSplice.py Version 1.02

##  Copyright (c) 2006 Bruce Vaughan, BV Detailing & Design, Inc.

##  All rights reserved.

###############################################################################

"""

    Add shear splice plates to a beam web for connection of continuous beams.

    User has the option of adding shim plates for webs of differing thicknesses.

    User selects the beam member to receive the plates and the member to connect to.

    Options are splice plates near side, far side and both sides - welded or bolted

    to selected member.

 

    IMPORTANT NOTE:

    'Weld' option - Shims if required should be on the 'supported' beam. The member

    selected is the supporting beam. There will be undesireable results if shims

    are required on the supporting beam.

 

    The information is organized in the dialog box (reactions, etc.) assuming the

    selected member is the supporting member.

   

    NOTE:

    This script will read and write the defaults to a disk file if so enabled in

    the "Defaults section". The first time the script is executed the defaults file

    will be created. Subsequent script executions will import the defaults used in

    the previous execution. Set the variable "enable_default_import_export" to

    "Disable" to disable this feature.

 

    Originally developed in SDS2 7.021 2/19/07

    This script will not work in SDS/2 versions 6.XXX

 

    Version History:

    Version 1.00 (2/19/07)

    Version 1.01 (6/18/07) - dim_print removed from dialog box at variables no_cols_left

                             and no_cols_right

                             SDS/2 built-in Hole().columns does not accept float values

                             Corrected NS/FS plates Left End

    Version 1.02 (6/27/07) - Predefine shim_thk_left and shim_thk_right in defaults section

                             Modify dialog box for shim thicknesses and connection data

    Version 1.03 (9/20/07) - Add ClearSelection() in try/finally block

                             Move imports outside of function run_script()

 

    Developed by Bruce Vaughan, BV Detailing & Design, Inc. (BVD)  (615) 646-9239

    For comments, suggestions or questions call BVD at the number above.

 

    Go to 'Variables section' to turn off default file import/export

    Go to 'Variables section' to edit system paths for image and default files

    Go to 'Defaults section' to edit script defaults.

 

    Required files from folder 'macrolib' on SDS/2 system path:

        pickle.py

        FileDefaults.py

        SpliceFraming.py

        angle.py

        MemSelection.py

 

     Required folders:

         "system path"/macrolib

         "system path"/Defaults

         "system path"/Images       

 

"""

# startup code begin

from math import cos, sin, floor, atan, tan

from param import yes_or_no, ResponseNotOK, Units, ClearSelection, Dialog, dim_print, Warning, dim

from macrolib.FileDefaults import import_data, export_data

# macrolib.pickle required

from macrolib.angle import rtod, dtor

from macrolib.SpliceFraming import SpliceSupport

from macrolib.ColumnFraming import ColumnSupport

# macrolib.L3D required

from macrolib.MemSelection import mem_select

# macrolib.MemCnt required

from macrolib.bolt_match import bolt_match

from macrolib.Weld import mtrl_weld

 

import os

Units("feet")

from shape import Shape

from point import Point, PointLocate

from member import Member, MemberLocate, MemberAllocated

from rect_plate import RectPlate

from hole_add import Hole

from weld_add import Weld

from job import Job

from fab import Fabricator

# startup code end

def run_script():

    #################################################################

    ## Variables section

    # system path for defaults file

    default_file_path = os.path.join(os.getcwd(), "macro", "Defaults")

    # defaults file

    def_file = "Beam_ShearSplice_v1.03.txt"

    image_path = os.path.join(os.getcwd(), "macro", "Images")

    image_name1 = os.path.join(image_path, "Beam_ShearSplice1.gif")

    image_name2 = os.path.join(image_path, "Beam_ShearSplice2.gif")

    image_name3 = os.path.join(image_path, "Beam_ShearSplice3.gif")

    # default to enable or disable the importing and exporting of dialog dictionary variables "Enable" "Disable"

    enable_default_import_export = "Enable"

 

    holeTypeList = ("Standard Round", "Short Slot", "Oversized Round", "Long Slot")

    holeTypeList1 = ("Standard Round", "Oversized Round")

    finishList = ("None", "Red Oxide", "Yellow Zinc", "Gray Oxide", "Sandblasted", "Blued Steel", "Galvanized")

    wsList = ['3/16', '1/4', '5/16', '3/8']

    #########################################

    ## Defaults section

    bolt_dia = 0.75

    # Job().bolt_sched()

    bolt_type = "A325N"

    # holeTypeList

    hole_type = "Long Slot"

    # Enter 0 to have SDS/2 calculate slot length

    long_slot_length = 1.5

    hole_type_bm = "Standard Round"

 

    # ("NS", "FS", "BS")   

    which_side = "BS"

    # ("Bolt", "Weld")

    bolt_or_weld = "Bolt"

 

    # finishList

    plate_color = "None"

    # finishList

    shim_color = "None"

 

    plate_thick = 0.375

    edge_dist_mem = 1.5

    edge_dist_plh = 1.5

    edge_dist_plv = 1.5

    edge_dist_shim = 1.25

 

    # material grade Job().steel_grades("Plate").keys()   

    plate_grade = "A36"                                

 

    # welded connection, lap distance of plate onto beam web   

    plate_lap_dist = 4.0                               

 

    # ("Do not add holes or bolts", "Add holes only", "Add holes and bolts")

    hls_and_blts = "Add holes and bolts"

    # ("One Side", "Both Sides")

    shim_thk = 0.0

 

    # material grade Job().steel_grades("Plate").keys()

    shim_grade = "A36"

 

    # number of bolt rows is determined from Job().min_shear(mem.nom_depth).num_rows

    # mem.nom_depth for shallower beam

    # no_rows = 3

 

    # number of bolt columns

    no_cols_left = 2

    no_cols_right = 2

 

    # distance to first row from top of lower beam

    dist_1st_left = 3.0

    vert_spa_left = 3.0

    hor_spa_left = 3.0

    dist_1st_right = 3.0

    vert_spa_right = 3.0

    hor_spa_right = 3.0

 

    add_weld = "Yes"

    weld_type = "Fillet"

    weld_size = "3/16"

 

    shim_thk_left = 0.0

    shim_thk_right = 0.0

    # Calculated:

    # no_rows

    # shim_thk

    ## End Defaults and Variables

    ###############################################################################

    # Format a point for display

    def formatPT(p):

        return dim_print(p.x), dim_print(p.y), dim_print(p.z)

   

    # Add plate material

    def apply_plate(mem, p1, mtrl_length, pl_thk, pl_width, steelgrade, mtrl_color, ref, rot_arg):

        # print 'Applying plate material'

        # rectangular plate begin

        rp1 = RectPlate()

        rp1.member = mem

        rp1.pt1 = p1

        rp1.pt2 = p1

        rp1.grade = steelgrade

        rp1.origin = "FS"

        rp1.width = pl_width

        rp1.thick = pl_thk

        rp1.work_pt_dist = mtrl_length

        rp1.length = mtrl_length

        rp1.mtrl_type = "Plate"

        rp1.finish = mtrl_color

        rp1.ref_pt_offset = (0.000000, 0.000000, 0.000000)

        rp1.add()

        rp1.rotate(rp1.member, rot_arg)

        # rectangular plate end

        return rp1

        # End function definition

    ###########################################################################

    # add hole pattern splice material and shims

    # slots are rotated perpendicular to length of material

    def add_holes (m, xga, yga, x_spa, y_spa, no_cols, no_rows, bt, ht, bs, slot_len):

        if slot_len and ht == 'Long Slot':

            str = "slot_len"

        else:       

            str = "hole1.calc_slot_length()"

        # hole group add begin

        hole1 = Hole()

        hole1.mtrl = [m, ]

        hole1.pt1 = m.pt1 + m.translate(xga, -yga, 0.0)

        hole1.hole_type = ht

        hole1.face = "NS Face"

        hole1.valid_cnc = "Yes"

        hole1.x_ref_offset = 0.0

        hole1.y_ref_offset = 0.0

        hole1.x_spa = x_spa

        hole1.y_spa = y_spa

        hole1.group_rot = 0.0

        hole1.locate = "Below Right"

        hole1.columns = no_cols

        hole1.rows = no_rows

        hole1.bolt_type = bt

        hole1.bolt_dia = bs

        hole1.slot_rot = 90.0

        hole1.length = eval(str)

        hole1.hole_dia = hole1.calc_hole_size()

        hole1.show_window = "No"

        hole1.create()

        # hole group add end

        return hole1

    ###########################################################################

    # add hole pattern splice material and shims

    # slots are rotated perpendicular to length of material

    def add_holes_mem (m, pt1, x_spa, y_spa, no_cols, no_rows, bt, ht, bs, ref):

        # hole group add begin

        hole1 = Hole()

        hole1.mtrl = [m, ]

        hole1.pt1 = pt1

        hole1.hole_type = ht

        hole1.face = "Web NS"

        hole1.valid_cnc = "Yes"

        hole1.x_ref_offset = 0.0

        hole1.y_ref_offset = 0.0

        hole1.x_spa = x_spa

        hole1.y_spa = y_spa

        hole1.group_rot = 0.0

        hole1.locate = ref

        hole1.columns = no_cols

        hole1.rows = no_rows

        hole1.bolt_type = bt

        hole1.bolt_dia = bs

        hole1.slot_rot = 90.0

        hole1.length = hole1.calc_slot_length()

        hole1.hole_dia = hole1.calc_hole_size()

        hole1.show_window = "No"

        hole1.create()

        # hole group add end

        return hole1

    ###########################################################################

    ## Import default values if enabled

    if enable_default_import_export == "Enable":

        dd0 = import_data(os.path.join(default_file_path, def_file))

        if dd0:

            for key, value in dd0.items():

                exec "%s = %s" % (key, repr(value)) in None

           

    ###########################################################################

    ## Main program loop

    while True:

        # allow one member to be selected

        bm_list = mem_select("Select WF BEAM Member", ['Beam',], ["W flange", ], True, False)

        try:

            mem1 = bm_list[0]

        except:

            break

 

        # Check for splice members at ends of beam

        a = SpliceSupport(mem1, 'Beam', mem1.nom_depth / 2.0)

        mem_left = a.left_member

        mem_right = a.right_member

 

        b = ColumnSupport(mem1)

        if b.left_member <> 'None':

            mem_left = 'None'

        if b.right_member <> 'None':

            mem_right = 'None'

 

        if mem_left == 'None' and mem_right == 'None':

            Warning('There are no splice members')

            break

 

        if mem_left <> 'None':

            shim_thk_left = abs((round(((mem1.tw-mem_left.tw)/2-0.03)*16.0)/16.0))

            shim_thkR_left = abs((mem1.tw-mem_left.tw)/2)

            no_rows_left = Job().min_shear(min(mem1.nom_depth, mem_left.nom_depth)).num_rows

            which_end = "Left"

 

        if mem_right <> 'None':

            shim_thk_right = abs((round(((mem1.tw-mem_right.tw)/2-0.03)*16.0)/16.0))

            shim_thkR_right = abs((mem1.tw-mem_right.tw)/2)

            strRight = "Right End Splice Member: %s %s \nShim Space Each Side: %0.4f" % (mem_right.size, mem_right.piecemark, shim_thkR_right)

            no_rows_right = Job().min_shear(min(mem1.nom_depth, mem_right.nom_depth)).num_rows

            which_end = "Right"

           

        if mem_left <> 'None' and mem_right <> 'None':

            which_end = "Both"

       

        #############################################################

        ## DIALOG BOX 1 --------------------------------------------#

        #############################################################

        dlg1 = Dialog( "WF to WF beam shear splice" )

        dlg1.menu("print_doc", ("Yes", "No"), "No", "Print documentation only")

 

        dlg1.tabset_begin()

 

        dlg1.tab("General information")

        dlg1.group_title("Splice Plate Locations")

        dlg1.menu("which_side", ("NS", "FS", "BS"), which_side, "Add splice plate(s) to which side                          ")

        dlg1.menu("which_end", ("Left", "Right", "Both"), which_end, "Add splice plates(s) to which end(s)")

        dlg1.group_title_end

       

        dlg1.group_title("Bolt or Weld option")

        dlg1.menu("bolt_or_weld", ("Bolt", "Weld"), bolt_or_weld, "Bolt or Weld splice plates                   ")

        dlg1.entry("plate_lap_dist", dim_print(plate_lap_dist), "Plate lap distance (applies to 'Weld' option)")

        dlg1.group_title_end

 

        dlg1.group_title("Match holes and add bolts to main material options")

        dlg1.line("%s at location %s, %s, %s" % ((mem1.size, ) + formatPT(mem1.left.location)))

        dlg1.menu("hls_and_blts", ["Add holes and bolts", ], hls_and_blts, "Select option")

        dlg1.group_title_end

 

        dlg1.group_title("Bolts and Holes")

        dlg1.entry("bolt_dia", dim_print(bolt_dia), "Bolt diameter                                                         ")

        dlg1.menu("bolt_type", Job().bolt_sched(), bolt_type, "Bolt type")             

        dlg1.menu("hole_type", holeTypeList, hole_type, "Hole type splice plate")

        dlg1.line("Enter a long slot length of 0 and SDS/2 will calculate")

        dlg1.entry("long_slot_length", dim_print(long_slot_length), "Long slot length in splice plate")

        dlg1.menu("hole_type_bm", holeTypeList1, hole_type_bm, "Hole type beam web")

        dlg1.group_title_end

 

        dlg1.tab("Splice plate information and Weld")       

        dlg1.group_title("Splice Plate Dimensions and Information")

        dlg1.entry("plate_thick", dim_print(plate_thick), "Splice plate thickness")

        dlg1.entry("edge_dist_mem", dim_print(edge_dist_mem), "Member horizontal edge distance")

        dlg1.entry("edge_dist_plh", dim_print(edge_dist_plh), "Plate horizontal edge distance")

        dlg1.entry("edge_dist_plv", dim_print(edge_dist_plv), "Plate vertical edge distance")

        dlg1.menu("plate_grade", Job().steel_grades("Plate").keys(), plate_grade, "Splice plate material grade")

        dlg1.menu("plate_color", finishList, plate_color, "Splice plate finish")

        dlg1.group_title_end

        dlg1.group_title("Weld")

        dlg1.line('If plates are bolted, weld will not be added')

        dlg1.menu("add_weld", ("Yes", "No"), add_weld, "Add weld" )

        dlg1.menu("weld_type", ("Fillet", ), weld_type, "Weld type" )

        dlg1.menu("weld_size", wsList, weld_size, "Weld size")

 

        dlg1.tab("Shim information")

        dlg1.group_title("Shim Plate Dimensions and Information")

        dlg1.line('Shim(s) will be added to same side as splice plate(s) on the member with the thinnest web')

        dlg1.line("Enter 0 for no shims")

        if mem_left <> 'None':

            dlg1.entry("shim_thk_left", dim_print(shim_thk_left), "Shim plate thickness LEFT")

        else:

            dlg1.line('There is no spliced member at the left end.')

        if mem_right <> 'None':

            dlg1.entry("shim_thk_right", dim_print(shim_thk_right), "Shim plate thickness RIGHT")

        else:

            dlg1.line('There is no spliced member at the right end.')

        dlg1.entry("edge_dist_shim", dim_print(edge_dist_shim), "Shim plate edge distance")

        dlg1.menu("shim_grade", Job().steel_grades("Plate").keys(), shim_grade, "Shim plate material grade")

        dlg1.menu("shim_color", finishList, shim_color, "Shim plate finish")

        dlg1.group_title_end   

 

        dlg1.tab("Bolts and Holes Left")

        if mem_left <> 'None':

            dlg1.line("Left End Splice Member: %s %s" % (mem_left.size, mem_left.piecemark))

            dlg1.line("Shim Space Each Side: %0.4f" % (shim_thkR_left))

            dlg1.line("Left end spliced member reaction: %0.1f kips" % (mem_left.right.shear))

            dlg1.line("Location: %s, %s, %s" % formatPT(mem_left.right.location))

            dlg1.group_title("Bolt Rows and Columns Left")

            dlg1.entry("no_rows_left", no_rows_left, "Number of bolt rows")

            dlg1.entry("dist_1st_left", dim_print(dist_1st_left), "Distace to first row from lowest beam")

            dlg1.entry("vert_spa_left", dim_print(vert_spa_left), "Bolt row spacing")

            dlg1.entry("no_cols_left", no_cols_left, "Number of bolt columns")

            dlg1.entry("hor_spa_left", dim_print(hor_spa_left), "Bolt column spacing")

            dlg1.group_title_end

        else:

            dlg1.line('There is no spliced member at the left end.')

           

        dlg1.tab("Bolts and Holes Right")

        if mem_right <> 'None':

            dlg1.line("Right End Splice Member: %s %s" % (mem_right.size, mem_right.piecemark))

            dlg1.line("Shim Space Each Side: %0.4f" % (shim_thkR_right))

            dlg1.line("Right end spliced member reaction %0.1f kips" % (mem_right.left.shear))

            dlg1.line("Location: %s, %s, %s" % formatPT(mem_right.left.location))

            dlg1.group_title("Bolt Rows and Columns Right")

            dlg1.entry("no_rows_right", no_rows_right, "Number of bolt rows")

            dlg1.entry("dist_1st_right", dim_print(dist_1st_right), "Distace to first row from lowest beam")

            dlg1.entry("vert_spa_right", dim_print(vert_spa_right), "Bolt row spacing")

            dlg1.entry("no_cols_right", no_cols_right, "Number of bolt columns")

            dlg1.entry("hor_spa_right", dim_print(hor_spa_right), "Bolt column spacing")

            dlg1.group_title_end

        else:

            dlg1.line('There is no spliced member at the right end.')

           

        dlg1.tab("Images")

        dlg1.column_group_begin()

        dlg1.column(0)

        dlg1.image(image_name1)

        dlg1.column(0)

        dlg1.image(image_name2)

        dlg1.column(0)

        dlg1.image(image_name3)

        dlg1.column_group_end()

        dlg1.tabset_end()

       

        try:

            dd1 = dlg1.done()

        except ResponseNotOK:

            break

   

        # Update the local namespace

        for key, value in dd1.items():

            exec "%s = %s" % (key, repr(value)) in None

        ###############################################################

        ## END DIALOG BOX 1 ------------------------------------------#

        ###############################################################

        if print_doc == "Yes":

            print __doc__

            break

        ###############################################################

        # Export defaults to disk if enabled

        if enable_default_import_export == "Enable":

            export_data(os.path.join(default_file_path, def_file), dd1)

        ###############################################################

 

        ## LEFT END ##################################   

        if which_end == "Left" or which_end == "Both":

            bolt_match_list = []

            hole_location_z_left = dist_1st_left + max(0, mem1.left.location.z-mem_left.right.location.z)

           

            # Add shim plate(s) and hole pattern to supported beam

            ptWP1 = mem1.left.location + mem1.translate(-(edge_dist_mem + mem_left.right.setback), -hole_location_z_left, 0.0)

            add_holes_mem(mem_left, ptWP1, hor_spa_left, vert_spa_left, no_cols_left, no_rows_left, \

                          bolt_type, hole_type_bm, bolt_dia, 'Below Left')

           

            if shim_thk_left > 0:

                shim_length = (no_rows_left-1) * vert_spa_left + (edge_dist_shim * 2)

                shim_width = (no_cols_left-1) * hor_spa_left + (edge_dist_shim * 2)

                if mem1.tw < mem_left.tw:

                    shim_mem = mem1

                    ptWP1 = mem1.left.location + mem1.translate((edge_dist_mem - edge_dist_shim + mem1.left.setback + shim_width), \

                                                                -(hole_location_z_left - edge_dist_shim), mem1.tw/2)

                else:

                    shim_mem = mem_left

                    ptWP1 = mem1.left.location + mem1.translate(-(edge_dist_mem - edge_dist_shim + mem_left.right.setback), \

                                                                -(hole_location_z_left - edge_dist_shim), mem_left.tw/2)

                    

                ptWP2 = ptWP1 + mem1.translate(0.0, -shim_length, -(min(mem_left.tw, mem1.tw)))

 

                # Add NS shim plate and holes

                if (which_side == "NS" or which_side == "BS"):

                    m1 = apply_plate(shim_mem, ptWP1, shim_length, shim_thk_left, shim_width, shim_grade, shim_color, \

                                     (0.0, 0.0, 0.0), (0.0, 0.0, -90.0))

                    bolt_match_list.append(m1)

                    add_holes(m1, edge_dist_shim, edge_dist_shim, vert_spa_left, hor_spa_left, no_rows_left, \

                              no_cols_left, bolt_type, hole_type_bm, bolt_dia, long_slot_length)

                   

                   

                # Add FS shim plate and holes

                if (which_side == "FS" or which_side == "BS"):

                    m2 = apply_plate(shim_mem, ptWP2, shim_length, shim_thk_left, shim_width, shim_grade, shim_color, \

                                     (0.0, 0.0, 0.0), (180.0, 0.0, 90.0))

                    bolt_match_list.append(m2)

                    add_holes(m2, edge_dist_shim, edge_dist_shim, vert_spa_left, hor_spa_left, no_rows_left, \

                              no_cols_left, bolt_type, hole_type_bm, bolt_dia, long_slot_length)

 

            # Add hole pattern to supporting beam web if 'Bolt' option is selected LEFT END

            # Calculate points and dimensions for splice plate

            z_off = max(mem_left.tw, mem1.tw)

            if bolt_or_weld == 'Bolt':

                ptWP1 = mem1.left.location + mem1.translate((edge_dist_mem + mem1.left.setback), -hole_location_z_left, 0.0)

                add_holes_mem(mem1, ptWP1, hor_spa_left, vert_spa_left, no_cols_left, no_rows_left, \

                              bolt_type, hole_type_bm, bolt_dia, 'Below Right')

                dist1 = edge_dist_mem + mem1.left.setback + hor_spa_left*(no_cols_left-1) + edge_dist_plh

                dist2 = edge_dist_mem + mem_left.right.setback + hor_spa_left*(no_cols_left-1) + edge_dist_plh

                ptWP2 = mem1.left.location + mem1.translate(dist1, -hole_location_z_left+edge_dist_plv, z_off/2)

                spl_pl_width = dist1 + dist2

               

            else:

                dist1 = mem1.left.setback + plate_lap_dist

                dist2 = edge_dist_mem + mem_left.right.setback + hor_spa_left*(no_cols_left-1) + edge_dist_plh

                ptWP2 = mem1.left.location + mem1.translate(dist1, -hole_location_z_left + edge_dist_plv, z_off/2)

                spl_pl_width = dist1 + dist2

 

            # Add splice plate material and holes LEFT END           

            spl_pl_depth = vert_spa_left*(no_rows_left-1) + edge_dist_plv*2

            if (which_side == "NS" or which_side == "BS"):

                m11 = apply_plate(mem1, ptWP2, spl_pl_depth, plate_thick, spl_pl_width, plate_grade, plate_color, \

                                 (0.0, 0.0, 0.0), (0.0, 0.0, -90.0))

                bolt_match_list.append(m11)

                if bolt_or_weld == 'Bolt':

                    add_holes(m11, edge_dist_plv, edge_dist_plh, vert_spa_left, hor_spa_left, no_rows_left, \

                              no_cols_left, bolt_type, hole_type, bolt_dia, 0)

                dist3 = dist1 + edge_dist_mem + mem_left.right.setback

                add_holes(m11, edge_dist_plv, dist3, vert_spa_left, hor_spa_left, no_rows_left, \

                          no_cols_left, bolt_type, hole_type, bolt_dia, 0)

 

            ptWP3 = ptWP2 + mem1.translate(0.0, 0.0, -z_off-plate_thick)

            if (which_side == "FS" or which_side == "BS"):

                m33 = apply_plate(mem1, ptWP3, spl_pl_depth, plate_thick, spl_pl_width, plate_grade, plate_color, \

                                 (0.0, 0.0, 0.0), (0.0, 0.0, -90.0))

                bolt_match_list.append(m33)

                if bolt_or_weld == 'Bolt':

                    add_holes(m33, edge_dist_plv, edge_dist_plh, vert_spa_left, hor_spa_left, no_rows_left, \

                              no_cols_left, bolt_type, hole_type, bolt_dia, 0)

                dist3 = dist1 + edge_dist_mem + mem_left.right.setback

                add_holes(m33, edge_dist_plv, dist3, vert_spa_left, hor_spa_left, no_rows_left, \

                          no_cols_left, bolt_type, hole_type, bolt_dia, 0)

               

            if bolt_or_weld == 'Bolt':

                bolt_match(mem1.main_mtrl(), bolt_match_list)

            else:

                if add_weld == 'Yes':

                    for m in bolt_match_list:

                        mtrl_weld([mem1.main_mtrl(), ], [m, ], weld_size, weld_type)

                       

            bolt_match(mem_left.main_mtrl(), bolt_match_list)

 

        ## RIGHT END ##################################       

        if which_end == "Right" or which_end == "Both":

            bolt_match_list = []

            hole_location_z_right = dist_1st_right + max(0, mem1.right.location.z-mem_right.left.location.z)

 

            # Add shim plate(s) and hole pattern supported beam

            ptWP1 = mem1.right.location + mem1.translate((edge_dist_mem + mem_right.left.setback), -hole_location_z_right, 0.0)

            add_holes_mem(mem_right, ptWP1, hor_spa_right, vert_spa_right, no_cols_right, no_rows_right, \

                          bolt_type, hole_type_bm, bolt_dia, 'Below Right')

           

            if shim_thk_right > 0:

                shim_length = (no_rows_right-1) * vert_spa_right + (edge_dist_shim * 2)

                shim_width = (no_cols_right-1) * hor_spa_right + (edge_dist_shim * 2)

                if mem1.tw < mem_right.tw:

                    shim_mem = mem1

                    ptWP1 = mem1.right.location + mem1.translate(-(edge_dist_mem - edge_dist_shim + mem1.right.setback + shim_width), \

                                                                 -(hole_location_z_right - edge_dist_shim + shim_length), mem1.tw/2)

                else:

                    shim_mem = mem_right

                    ptWP1 = mem1.right.location + mem1.translate((edge_dist_mem - edge_dist_shim + mem_right.left.setback), \

                                                                 -(hole_location_z_right - edge_dist_shim + shim_length), mem_right.tw/2)

 

                ptWP2 = ptWP1 + mem1.translate(0.0, shim_length, -(min(mem_right.tw, mem1.tw)))               

                   

                # Add NS shim plate and holes

                if (which_side == "NS" or which_side == "BS"):

                    m3 = apply_plate(shim_mem, ptWP1, shim_length, shim_thk_right, shim_width, shim_grade, shim_color, \

                                     (0.0, 0.0, 0.0), (0.0, 0.0, 90.0))

                    bolt_match_list.append(m3)

                    add_holes(m3, edge_dist_shim, edge_dist_shim, vert_spa_right, hor_spa_right, no_rows_right, \

                              no_cols_right, bolt_type, hole_type_bm, bolt_dia, long_slot_length)

 

                # Add FS shim plate and holes

                if (which_side == "FS" or which_side == "BS"):

                    m4 = apply_plate(shim_mem, ptWP2, shim_length, shim_thk_right, shim_width, shim_grade, shim_color,

                                     (0.0, 0.0, 0.0), (-180.0, 0.0, -90.0))

                    bolt_match_list.append(m4)

                    add_holes(m4, edge_dist_shim, edge_dist_shim, vert_spa_right, hor_spa_right, no_rows_right, \

                              no_cols_right, bolt_type, hole_type_bm, bolt_dia, long_slot_length)

 

            # Add hole pattern to supporting beam web if 'Bolt' option is selected RIGHT END

            # Calculate points and dimensions for splice plate

            z_off = max(mem_right.tw, mem1.tw)

            if bolt_or_weld == 'Bolt':

                ptWP1 = mem1.right.location + mem1.translate(-(edge_dist_mem + mem1.right.setback), -hole_location_z_right, 0.0)

                add_holes_mem(mem1, ptWP1, hor_spa_right, vert_spa_right, no_cols_right, no_rows_right, \

                              bolt_type, hole_type_bm, bolt_dia, 'Below Left')

                dist1 = edge_dist_mem + mem_right.left.setback + hor_spa_right*(no_cols_right-1) + edge_dist_plh

                dist2 = edge_dist_mem + mem1.right.setback + hor_spa_right*(no_cols_right-1) + edge_dist_plh

                ptWP2 = mem1.right.location + mem1.translate(dist1, -hole_location_z_right+edge_dist_plv, z_off/2)

                spl_pl_width = dist1 + dist2

               

            else:

                dist1 = edge_dist_mem + mem_right.left.setback + hor_spa_right*(no_cols_right-1) + edge_dist_plh

                dist2 = mem1.left.setback + plate_lap_dist

                ptWP2 = mem1.right.location + mem1.translate(dist1, -hole_location_z_right+edge_dist_plv, z_off/2)

                spl_pl_width = dist1 + dist2

 

            # Add splice plate material and holes RIGHT END           

            spl_pl_depth = vert_spa_right*(no_rows_right-1) + edge_dist_plv*2

            if (which_side == "NS" or which_side == "BS"):

                m22 = apply_plate(mem1, ptWP2, spl_pl_depth, plate_thick, spl_pl_width, plate_grade, plate_color, \

                                 (0.0, 0.0, 0.0), (0.0, 0.0, -90.0))

                bolt_match_list.append(m22)

                if bolt_or_weld == 'Bolt':

                    dist3 = dist1 + edge_dist_mem + mem1.right.setback

                    add_holes(m22, edge_dist_plv, dist3, vert_spa_right, hor_spa_right, no_rows_right, \

                              no_cols_right, bolt_type, hole_type, bolt_dia, 0)

                add_holes(m22, edge_dist_plv, edge_dist_plh, vert_spa_right, hor_spa_right, no_rows_right, \

                          no_cols_right, bolt_type, hole_type, bolt_dia, 0)

 

            ptWP3 = ptWP2 + mem1.translate(0.0, 0.0, -z_off-plate_thick)

            if (which_side == "FS" or which_side == "BS"):

                m44 = apply_plate(mem1, ptWP3, spl_pl_depth, plate_thick, spl_pl_width, plate_grade, plate_color, \

                                 (0.0, 0.0, 0.0), (0.0, 0.0, -90.0))

                bolt_match_list.append(m44)

                if bolt_or_weld == 'Bolt':

                    dist3 = dist1 + edge_dist_mem + mem1.right.setback

                    add_holes(m44, edge_dist_plv, dist3, vert_spa_right, hor_spa_right, no_rows_right, \

                              no_cols_right, bolt_type, hole_type, bolt_dia, 0)

                add_holes(m44, edge_dist_plv, edge_dist_plh, vert_spa_right, hor_spa_right, no_rows_right, \

                          no_cols_right, bolt_type, hole_type, bolt_dia, 0)

 

            if bolt_or_weld == 'Bolt':

                bolt_match(mem1.main_mtrl(), bolt_match_list)

            else:

                if add_weld == 'Yes':

                    for m in bolt_match_list:

                        mtrl_weld([mem1.main_mtrl(), ], [m, ], weld_size, weld_type)

 

            bolt_match(mem_right.main_mtrl(), bolt_match_list)

 

        if not yes_or_no('Make another beam splice?'):

            break

        

## End run_script()

if __name__ == '__main__':

    try:

        run_script()

    finally:

        del run_script

        ClearSelection()