Example #1
0
def makeReinforcement(
    s_cover,
    helical_rebar_t_offset,
    helical_rebar_b_offset,
    pitch,
    dia_of_helical_rebar,
    main_rebars_t_offset,
    main_rebars_b_offset,
    dia_of_main_rebars,
    number_angle_check,
    number_angle_value,
    structure=None,
    facename=None,
):
    """makeReinforcement(SideCover, TopOffsetOfHelicalRebars,
    BottomOffsetOfHelicalRebars, Pitch, DiameterOfHelicalRebar,
    TopOffsetOfMainRebars, BottomOffsetOfMainRebars, DiameterOfMainRebars,
    NumberAngleCheck, NumberAngleValue, Structure, Facename):
    Adds the helical and straight rebars to the selected structural column
    object.
    """
    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:
            FreeCAD.Console.PrintError(
                "Error: Pass structure and facename arguments")
            return
    FacePRM = getParametersOfFace(structure, facename, sketch=False)
    if not FacePRM:
        FreeCAD.Console.PrintError(
            "Cannot identified shape or from which base object"
            "sturctural element is derived\n")
        return
    helical_rebar = makeHelicalRebar(
        s_cover,
        helical_rebar_b_offset,
        dia_of_helical_rebar,
        helical_rebar_t_offset,
        pitch,
        structure,
        facename,
    )

    main_rebars_s_cover = s_cover + dia_of_helical_rebar
    main_rebars_list = makeStraightRebars(
        main_rebars_s_cover,
        main_rebars_t_offset,
        main_rebars_b_offset,
        dia_of_main_rebars,
        number_angle_check,
        number_angle_value,
        structure,
        facename,
    )

    CircularColumnReinforcementRebarGroup = (
        _CircularColumnReinforcementRebarGroup())
    if FreeCAD.GuiUp:
        _ViewProviderCircularColumnReinforcementRebarGroup(
            CircularColumnReinforcementRebarGroup.Object.ViewObject)
    CircularColumnReinforcementRebarGroup.addHelicalRebars(helical_rebar)
    CircularColumnReinforcementRebarGroup.addMainRebars(main_rebars_list)

    properties_values = []
    properties_values.append(("TopOffset", main_rebars_t_offset))
    properties_values.append(("BottomOffset", main_rebars_b_offset))
    properties_values.append(("Diameter", dia_of_main_rebars))
    properties_values.append(("NumberAngleCheck", number_angle_check))
    if number_angle_check:
        properties_values.append(("Number", number_angle_value))
        properties_values.append(("Angle", 360.00 / number_angle_value))
    else:
        properties_values.append(
            ("Number", math.ceil(360 / number_angle_value)))
        properties_values.append(("Angle", number_angle_value))
    setGroupPropertiesValues(
        properties_values,
        CircularColumnReinforcementRebarGroup.main_rebars_group,
    )
    FreeCAD.ActiveDocument.recompute()
    return CircularColumnReinforcementRebarGroup
Example #2
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