Esempio n. 1
0
def makeSingleTieFourRebars(
    l_cover_of_tie,
    r_cover_of_tie,
    t_cover_of_tie,
    b_cover_of_tie,
    offset_of_tie,
    bent_angle,
    extension_factor,
    dia_of_tie,
    number_spacing_check,
    number_spacing_value,
    dia_of_rebars,
    t_offset_of_rebars,
    b_offset_of_rebars,
    rebar_type="StraightRebar",
    hook_orientation="Top Inside",
    hook_extend_along="x-axis",
    l_rebar_rounding=None,
    hook_extension=None,
    structure=None,
    facename=None,
):
    """makeSingleTieFourRebars(LeftCoverOfTie, RightCoverOfTie, TopCoverOfTie,
    BottomCoverOfTie, OffsetofTie, BentAngle, ExtensionFactor, DiameterOfTie,
    NumberSpacingCheck, NumberSpacingValue, DiameterOfRebars, TopOffsetOfRebars,
    BottomOffsetOfRebars, RebarType, LShapeHookOrientation, HookExtendAlong,
    LShapeRebarRounding, LShapeHookLength, Structure, Facename):
    Adds the Single Tie Four Rebars reinforcement to the selected structural
    column object.
    It takes two different inputs for rebar_type i.e. 'StraightRebar',
    'LShapeRebar'.
    It takes eight different orientations input for L-shaped hooks i.e. 'Top
    Inside', 'Top Outside', 'Bottom Inside', 'Bottom Outside', 'Top Left',
    'Top Right', 'Bottom Left', 'Bottom Right'.
    It takes two different inputs for hook_extend_along i.e. 'x-axis', 'y-axis'.
    """
    if not structure and not facename:
        if FreeCAD.GuiUp:
            selected_obj = FreeCADGui.Selection.getSelectionEx()[0]
            structure = selected_obj.Object
            facename = selected_obj.SubElementNames[0]
        else:
            showWarning("Error: Pass structure and facename arguments")
            return None

    # Calculate common parameters for Straight/LShaped rebars
    t_cover = t_offset_of_rebars
    b_cover = b_offset_of_rebars
    rebar_number_spacing_check = True
    rebar_number_spacing_value = 2

    # Create Straight Rebars
    if rebar_type == "StraightRebar":
        hook_extend_along == "x-axis"
        facename_for_rebars = getFacenameforRebar(
            hook_extend_along, facename, structure
        )
        f_cover = b_cover_of_tie + dia_of_tie
        r_cover = r_cover_of_tie + dia_of_tie
        l_cover = l_cover_of_tie + dia_of_tie
        orientation = "Vertical"
        list_coverAlong = ["Right Side", "Left Side"]
        rl_cover = [r_cover, l_cover]

        main_rebars = []
        for i, coverAlong in enumerate(list_coverAlong):
            main_rebars.append(
                makeStraightRebar(
                    f_cover,
                    (coverAlong, rl_cover[i]),
                    t_cover,
                    b_cover,
                    dia_of_rebars,
                    rebar_number_spacing_check,
                    rebar_number_spacing_value,
                    orientation,
                    structure,
                    facename_for_rebars,
                )
            )
            main_rebars[i].OffsetEnd = (
                t_cover_of_tie + dia_of_tie + dia_of_rebars / 2
            )

    # Create L-Shaped Rebars
    elif rebar_type == "LShapeRebar":
        facename_for_rebars = getFacenameforRebar(
            hook_extend_along, facename, structure
        )
        FacePRM = getParametersOfFace(structure, facename_for_rebars)
        face_length = FacePRM[0][0]
        if hook_extend_along == "x-axis":
            f_cover = b_cover_of_tie + dia_of_tie
        else:
            f_cover = r_cover_of_tie + dia_of_tie
        # Implement hook extension values from here:
        # https://archive.org/details/gov.in.is.sp.16.1980/page/n207
        if not hook_extension:
            hook_extension = 4 * dia_of_rebars
        if not l_rebar_rounding:
            l_rebar_rounding = (
                float(dia_of_tie) / 2 + dia_of_rebars / 2
            ) / dia_of_tie
        l_rebar_orientation_cover = getLRebarOrientationLeftRightCover(
            hook_orientation,
            hook_extension,
            hook_extend_along,
            l_cover_of_tie,
            r_cover_of_tie,
            t_cover_of_tie,
            b_cover_of_tie,
            dia_of_tie,
            dia_of_rebars,
            l_rebar_rounding,
            face_length,
        )
        list_orientation = l_rebar_orientation_cover["list_orientation"]
        l_cover = l_rebar_orientation_cover["l_cover"]
        r_cover = l_rebar_orientation_cover["r_cover"]
        t_cover = t_offset_of_rebars
        b_cover = b_offset_of_rebars

        main_rebars = []
        for i, orientation in enumerate(list_orientation):
            main_rebars.append(
                makeLShapeRebar(
                    f_cover,
                    b_cover,
                    l_cover[i],
                    r_cover[i],
                    dia_of_rebars,
                    t_cover,
                    l_rebar_rounding,
                    rebar_number_spacing_check,
                    rebar_number_spacing_value,
                    orientation,
                    structure,
                    facename_for_rebars,
                )
            )
            if hook_extend_along == "x-axis":
                main_rebars[i].OffsetEnd = (
                    t_cover_of_tie + dia_of_tie + dia_of_rebars / 2
                )
            else:
                main_rebars[i].OffsetEnd = (
                    l_cover_of_tie + dia_of_tie + dia_of_rebars / 2
                )

    # Calculate parameters for Tie
    rounding = (float(dia_of_tie) / 2 + dia_of_rebars / 2) / dia_of_tie
    f_cover = offset_of_tie

    # Create Tie
    ties = makeStirrup(
        l_cover_of_tie,
        r_cover_of_tie,
        t_cover_of_tie,
        b_cover_of_tie,
        f_cover,
        bent_angle,
        extension_factor,
        dia_of_tie,
        rounding,
        number_spacing_check,
        number_spacing_value,
        structure,
        facename,
    )

    # Create SingleTieFourRebars group object
    SingleTieFourRebars = _SingleTieFourRebars()
    if FreeCAD.GuiUp:
        _ViewProviderRebarGroup(SingleTieFourRebars.Object.ViewObject)

    # Add created tie and rebars to SingleTieFourRebars group
    SingleTieFourRebars.addTies(ties)
    SingleTieFourRebars.addMainRebars(main_rebars)

    # Set properties values for ties in Ties group object
    properties_values = []
    properties_values.append(("TiesConfiguration", "SingleTie"))
    properties_values.append(("LeftCover", l_cover_of_tie))
    properties_values.append(("RightCover", r_cover_of_tie))
    properties_values.append(("TopCover", t_cover_of_tie))
    properties_values.append(("BottomCover", b_cover_of_tie))
    setGroupPropertiesValues(properties_values, SingleTieFourRebars.ties_group)

    # Set properties values for rebars in MainRebars group object
    properties_values = []
    properties_values.append(("RebarType", rebar_type))
    properties_values.append(("TopOffset", t_offset_of_rebars))
    properties_values.append(("BottomOffset", b_offset_of_rebars))
    properties_values.append(("HookOrientation", hook_orientation))
    properties_values.append(("HookExtendAlong", hook_extend_along))
    if not hook_extension:
        hook_extension = "0.00 mm"
    properties_values.append(("HookExtension", hook_extension))
    setGroupPropertiesValues(
        properties_values, SingleTieFourRebars.main_rebars_group
    )
    FreeCAD.ActiveDocument.recompute()
    return SingleTieFourRebars
Esempio n. 2
0
def createBeamRebar(TopMain,
                    BottomMain,
                    AddMid,
                    AddTopR,
                    Stirrup,
                    direction='Horizontal',
                    covering=25,
                    structure=None):
    Msg('direction=%s\n' % direction)
    if not structure:
        selected_obj = FreeCADGui.Selection.getSelectionEx()[0]
        structure = selected_obj.Object

    if structure.Base:
        h = structure.Base.Height
    else:
        h = structure.Height

    diaStir = float(Stirrup['dia'])
    if direction.upper() in ['HORIZONTAL', 'HOR']:
        if structure.Base:
            b = structure.Base.Width
            L = structure.Base.Length
        else:
            b = structure.Width
            L = structure.Length
        face1 = getFaceNameFromVector(structure, Vector(0, -1, 0))
        face2 = getFaceNameFromVector(structure, Vector(-1, 0, 0))
    elif direction.upper() in ['VERTICAL', 'VER']:
        if structure.Base:
            b = structure.Base.Length
            L = structure.Base.Width
        else:
            b = structure.Length
            L = structure.Width

        face1 = getFaceNameFromVector(structure, Vector(1, 0, 0))
        face2 = getFaceNameFromVector(structure, Vector(0, -1, 0))

    # topMain ----------------
    dia = float(TopMain['dia'])
    coverNet = covering + diaStir + dia / 2
    if TopMain['type'] == 'S':
        rebar1 = makeStraightRebar(f_cover=coverNet,
                                   coverAlong=("Top Side", coverNet),
                                   rt_cover=TopMain['R_Cover'],
                                   lb_cover=TopMain['L_Cover'],
                                   diameter=dia,
                                   amount_spacing_check=True,
                                   amount_spacing_value=int(TopMain['num']),
                                   orientation="Horizontal",
                                   structure=structure,
                                   facename=face1)
    elif TopMain['type'] == 'U':
        rebar1 = makeUShapeRebar(f_cover=coverNet,
                                 b_cover=float(h) - coverNet - 1.5 * dia -
                                 12 * dia,
                                 r_cover=TopMain['R_Cover'],
                                 l_cover=TopMain['L_Cover'],
                                 diameter=dia,
                                 t_cover=coverNet,
                                 rounding=3,
                                 amount_spacing_check=True,
                                 amount_spacing_value=int(TopMain['num']),
                                 orientation="Top",
                                 structure=structure,
                                 facename=face1)
    elif TopMain['type'] == 'LL' or TopMain['type'] == 'LR':
        if TopMain['type'] == 'LL':
            orientation = 'Top Left'
        elif TopMain['type'] == 'LR':
            orientation = 'Top Right'
        rebar1 = makeLShapeRebar(f_cover=coverNet,
                                 b_cover=float(h) - coverNet - 1.5 * dia -
                                 12 * dia,
                                 t_cover=coverNet,
                                 l_cover=TopMain['L_Cover'],
                                 r_cover=TopMain['R_Cover'],
                                 diameter=dia,
                                 rounding=3,
                                 amount_spacing_check=True,
                                 amount_spacing_value=int(TopMain['num']),
                                 orientation=orientation,
                                 structure=structure,
                                 facename=face1)
    #rebar1.Label = "เหล็กหลักบน"
    rebar1.Label = "TopMainRebar"

    # bottomMain ----------------
    dia = float(BottomMain['dia'])
    coverNet = covering + diaStir + dia / 2
    if BottomMain['type'] == 'S':
        rebar2 = makeStraightRebar(f_cover=coverNet,
                                   coverAlong=("Bottom Side", coverNet),
                                   rt_cover=BottomMain['R_Cover'],
                                   lb_cover=BottomMain['L_Cover'],
                                   diameter=dia,
                                   amount_spacing_check=True,
                                   amount_spacing_value=int(BottomMain['num']),
                                   orientation="Horizontal",
                                   structure=structure,
                                   facename=face1)
    elif BottomMain['type'] == 'U':
        rebar2 = makeUShapeRebar(f_cover=coverNet,
                                 t_cover=float(h) - coverNet - 1.5 * dia -
                                 12 * dia,
                                 r_cover=TopMain['R_Cover'],
                                 l_cover=TopMain['L_Cover'],
                                 diameter=dia,
                                 b_cover=coverNet,
                                 rounding=3,
                                 amount_spacing_check=True,
                                 amount_spacing_value=int(TopMain['num']),
                                 orientation="Bottom",
                                 structure=structure,
                                 facename=face1)
    #rebar2.Label = "เหล็กหลักล่าง"
    rebar2.Label = "BottomMainRebar"
    # Add Mid ----------------
    dia = float(AddMid['dia'])
    num = int(AddMid['num'])
    coverNet = covering + diaStir + dia / 2
    if BottomMain['num'] == 2 and (num == 1 or num == 3 or num == 4):
        rebar3_1 = makeStraightRebar(f_cover=float(b) / 2.0,
                                     coverAlong=("Bottom Side", coverNet),
                                     rt_cover=float(L) * AddMid['L7'],
                                     lb_cover=float(L) * AddMid['L7'],
                                     diameter=dia,
                                     amount_spacing_check=True,
                                     amount_spacing_value=1,
                                     orientation="Horizontal",
                                     structure=structure,
                                     facename=face1)
        #rebar3_1.Label = "เหล็กเสริมพิเศษกลางคาน1"
        rebar3_1.Label = "AddMidRebar1"
    if BottomMain['num'] == 2 and (num == 2 or num == 3):
        numAdd = 2
        rebar3_2 = makeStraightRebar(f_cover=coverNet,
                                     coverAlong=("Bottom Side",
                                                 coverNet + 25 + dia),
                                     rt_cover=float(L) * AddMid['L7'],
                                     lb_cover=float(L) * AddMid['L7'],
                                     diameter=dia,
                                     amount_spacing_check=True,
                                     amount_spacing_value=numAdd,
                                     orientation="Horizontal",
                                     structure=structure,
                                     facename=face1)
        #rebar3_2.Label = "เหล็กเสริมพิเศษกลางคาน2"
        rebar3_2.Label = "AddMidRebar2"
    if BottomMain['num'] == 2 and (num == 4):
        numAdd = 3
        rebar3_2 = makeStraightRebar(f_cover=coverNet,
                                     coverAlong=("Bottom Side",
                                                 coverNet + 25 + dia),
                                     rt_cover=float(L) * AddMid['L7'],
                                     lb_cover=float(L) * AddMid['L7'],
                                     diameter=dia,
                                     amount_spacing_check=True,
                                     amount_spacing_value=numAdd,
                                     orientation="Horizontal",
                                     structure=structure,
                                     facename=face1)
        #rebar3_2.Label = "เหล็กเสริมพิเศษกลางคาน2"
        rebar3_2.Label = "AddMidRebar2"
    if BottomMain['num'] == 3 and (num == 1 or num == 2 or num == 3):
        numAdd = num
        rebar3_2 = makeStraightRebar(f_cover=coverNet,
                                     coverAlong=("Bottom Side",
                                                 coverNet + 25 + dia),
                                     rt_cover=float(L) * AddMid['L7'],
                                     lb_cover=float(L) * AddMid['L7'],
                                     diameter=dia,
                                     amount_spacing_check=True,
                                     amount_spacing_value=numAdd,
                                     orientation="Horizontal",
                                     structure=structure,
                                     facename=face1)
        #rebar3_2.Label = "เหล็กเสริมพิเศษกลางคาน2"
        rebar3_2.Label = "AddMidRebar2"

    # Add Top Right --------------------------
    dia = float(AddTopR['dia'])
    num = int(AddTopR['num'])
    coverNet = covering + diaStir + dia / 2
    if TopMain['num'] == 2 and (num == 1 or num == 3 or num == 4):
        rebar4_1 = makeStraightRebar(
            f_cover=float(b) / 2.0,
            coverAlong=("Top Side", coverNet),
            lb_cover=+float(L) - float(L) * AddTopR['LTop3'],
            rt_cover=-AddTopR['Col_Width'] - AddTopR['L2'] * AddTopR['LTop3'],
            diameter=dia,
            amount_spacing_check=True,
            amount_spacing_value=1,
            orientation="Horizontal",
            structure=structure,
            facename=face1)
        #rebar4_1.Label = "เหล็กเสริมพิเศษบนขวา1"
        rebar4_1.Label = "TopAddRightRebar1"
    if TopMain['num'] == 2 and (num == 2 or num == 3 or num == 4):
        if num == 2 or num == 3:
            numAdd = 2
        elif num == 4:
            numAdd = 3
        rebar4_2 = makeStraightRebar(
            f_cover=coverNet,
            coverAlong=("Top Side", coverNet + 25 + dia),
            lb_cover=+float(L) - float(L) * AddTopR['LTop3'],
            rt_cover=-AddTopR['Col_Width'] - AddTopR['L2'] * AddTopR['LTop3'],
            diameter=dia,
            amount_spacing_check=True,
            amount_spacing_value=numAdd,
            orientation="Horizontal",
            structure=structure,
            facename=face1)
        #rebar4_2.Label = "เหล็กเสริมพิเศษกลางคาน2"
        rebar4_2.Label = "TopAddRightRebar2"
    if TopMain['num'] == 3 and (num == 1 or num == 2 or num == 3):
        numAdd = num
        rebar4_2 = makeStraightRebar(
            f_cover=coverNet,
            coverAlong=("Top Side", coverNet + 25 + dia),
            lb_cover=+float(L) - float(L) * AddTopR['LTop3'],
            rt_cover=-AddTopR['Col_Width'] - AddTopR['L2'] * AddTopR['LTop3'],
            diameter=dia,
            amount_spacing_check=True,
            amount_spacing_value=numAdd,
            orientation="Horizontal",
            structure=structure,
            facename=face1)
        #rebar4_2.Label = "เหล็กเสริมพิเศษกลางคาน2"
        rebar4_2.Label = "TopAddRightRebar2"

    # stirrup
    if direction == 'Horizontal':
        face = 'Face6'
    elif direction == 'Vertical':
        face = 'Face1'
    coverNet = covering + diaStir / 2.
    spacing = float(Stirrup['spacing'])
    Lnet = float(L) - 200
    num = int(round(Lnet / spacing))
    num += 1
    gap = (float(L) - (num - 1) * spacing) / 2.0
    stir1 = makeStirrup(l_cover=coverNet,
                        r_cover=coverNet,
                        t_cover=coverNet,
                        b_cover=coverNet,
                        f_cover=gap,
                        bentAngle=135,
                        bentFactor=6,
                        diameter=diaStir,
                        rounding=2,
                        amount_spacing_check=True,
                        amount_spacing_value=3,
                        structure=structure,
                        facename=face2)
    stir1.CustomSpacing = "%d@%d" % (num, int(spacing))
    #stir1.Label = "เหล็กปลอก"
    stir1.Label = "Stirrup"
def makeTwoTiesSixRebars(
        l_cover_of_ties,
        r_cover_of_ties,
        t_cover_of_ties,
        b_cover_of_ties,
        offset_of_ties,
        bent_angle_of_ties,
        extension_factor_of_ties,
        dia_of_ties,
        number_spacing_check,
        number_spacing_value,
        dia_of_main_rebars,
        t_offset_of_rebars,
        b_offset_of_rebars,
        main_rebars_type="StraightRebar",
        hook_orientation="Top Inside",
        hook_extend_along="x-axis",
        l_rebar_rounding=None,
        hook_extension=None,
        ties_sequence=("Tie1", "Tie2"),
        structure=None,
        facename=None,
):
    """makeTwoTiesSixRebars(LeftCoverOfTies, RightCoverOfTies, TopCoverOfTies,
    BottomCoverOfTies, OffsetofTies, BentAngleOfTies, ExtensionFactorOfTies,
    DiameterOfTies, NumberSpacingCheck, NumberSpacingValue,
    DiameterOfMainRebars, TopOffsetOfMainRebars, BottomOffsetOfRebars,
    MainRebarsType, LShapeHookOrientation, HookExtendAlong, LShapeRebarRounding,
    LShapeHookLength, TiesSequence, Structure, Facename):
    """
    if not structure and not facename:
        if FreeCAD.GuiUp:
            selected_obj = FreeCADGui.Selection.getSelectionEx()[0]
            structure = selected_obj.Object
            facename = selected_obj.SubElementNames[0]
        else:
            showWarning("Error: Pass structure and facename arguments")
            return

    FacePRM = getParametersOfFace(structure, facename)
    face_length = FacePRM[0][0]

    # Calculate parameters for tie1 and tie2
    if ties_sequence[0] == "Tie2" and ties_sequence[1] == "Tie1":
        start_offset_of_tie1 = offset_of_ties + dia_of_ties + dia_of_ties / 2
        start_offset_of_tie2 = offset_of_ties
        end_offset_of_tie1 = start_offset_of_tie2
        end_offset_of_tie2 = start_offset_of_tie1
    else:
        start_offset_of_tie1 = offset_of_ties
        start_offset_of_tie2 = offset_of_ties + 2 * dia_of_ties
        end_offset_of_tie1 = start_offset_of_tie2
        end_offset_of_tie2 = start_offset_of_tie1
    l_cover_of_tie1 = l_cover_of_ties
    r_cover_of_tie1 = face_length / 2 - dia_of_main_rebars / 2 - dia_of_ties
    l_cover_of_tie2 = r_cover_of_tie1
    r_cover_of_tie2 = r_cover_of_ties

    # Create SingleTieFourRebars
    SingleTieFourRebarsObject = makeSingleTieFourRebars(
        l_cover_of_tie1,
        r_cover_of_tie1,
        t_cover_of_ties,
        b_cover_of_ties,
        start_offset_of_tie1,
        bent_angle_of_ties,
        extension_factor_of_ties,
        dia_of_ties,
        number_spacing_check,
        number_spacing_value,
        dia_of_main_rebars,
        t_offset_of_rebars,
        b_offset_of_rebars,
        main_rebars_type,
        hook_orientation,
        hook_extend_along,
        l_rebar_rounding,
        hook_extension,
        structure,
        facename,
    )
    SingleTieFourRebarsObject.rebar_group.RebarGroups[0].Ties[0].OffsetEnd = (
        end_offset_of_tie1 + dia_of_ties / 2)

    # Create tie2
    rounding = (float(dia_of_ties) / 2 + dia_of_main_rebars / 2) / dia_of_ties
    tie2 = makeStirrup(
        l_cover_of_tie2,
        r_cover_of_tie2,
        t_cover_of_ties,
        b_cover_of_ties,
        start_offset_of_tie2,
        bent_angle_of_ties,
        extension_factor_of_ties,
        dia_of_ties,
        rounding,
        number_spacing_check,
        number_spacing_value,
        structure,
        facename,
    )
    tie2.OffsetEnd = end_offset_of_tie2 + dia_of_ties / 2

    main_rebars = makeMainRebars(
        l_cover_of_ties,
        r_cover_of_ties,
        t_cover_of_ties,
        b_cover_of_ties,
        dia_of_ties,
        dia_of_main_rebars,
        t_offset_of_rebars,
        b_offset_of_rebars,
        main_rebars_type,
        hook_orientation,
        hook_extend_along,
        hook_extension,
        l_rebar_rounding,
        structure,
        facename,
    )

    SingleTieFourRebarsObject.ties_group.TiesConfiguration = "TwoTiesSixRebars"
    SingleTieFourRebarsObject.addTies(tie2)
    SingleTieFourRebarsObject.addMainRebars(main_rebars)
    SingleTieFourRebarsObject.ties_group.LeftCover = l_cover_of_ties
    SingleTieFourRebarsObject.ties_group.RightCover = r_cover_of_ties
    SingleTieFourRebarsObject.ties_group.TopCover = t_cover_of_ties
    SingleTieFourRebarsObject.ties_group.BottomCover = b_cover_of_ties

    TwoTiesSixRebars = _TwoTiesSixRebars(SingleTieFourRebarsObject)
    TwoTiesSixRebars.ties_group.TiesSequence = ties_sequence

    FreeCAD.ActiveDocument.recompute()
    return TwoTiesSixRebars.Object