Esempio n. 1
0
def makeSingleTieMultipleRebars(
    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_main_rebars,
    main_rebars_t_offset,
    main_rebars_b_offset,
    main_rebars_type="StraightRebar",
    main_hook_orientation="Top Inside",
    main_hook_extend_along="x-axis",
    l_main_rebar_rounding=None,
    main_hook_extension=None,
    sec_rebars_t_offset=None,
    sec_rebars_b_offset=None,
    sec_rebars_number_diameter=None,
    sec_rebars_type=("StraightRebar", "StraightRebar"),
    sec_hook_orientation=("Top Inside", "Top Inside"),
    l_sec_rebar_rounding=None,
    sec_hook_extension=None,
    structure=None,
    facename=None,
):
    """makeSingleTieMultipleRebars(LeftCoverOfTie, RightCoverOfTie,
    TopCoverOfTie, BottomCoverOfTie, OffsetofTie, BentAngle, ExtensionFactor,
    DiameterOfTie, NumberSpacingCheck, NumberSpacingValue, DiameterOfMainRebars,
    TopOffsetOfMainRebars, BottomOffsetofMainRebars, MainRebarType,
    MainLShapeHookOrientation, MainLShapeHookExtendAlong,
    LShapeMainRebarRounding, LShapeMainHookLength, TopOffsetOfSecondaryRebars,
    BottomOffsetOfSecondaryRebars, SecondaryRebarNumberDiameterString,
    SecondaryRebarType, SecondaryLShapeHookOrientation,
    LShapeSecondaryRebarRounding, LShapeSecondaryHookLength, Structure,
    Facename):
    Adds the Single Tie Multiple Rebars reinforcement to the selected structural
    column object.

    It takes two different inputs for main_rebars_type i.e. 'StraightRebar',
    'LShapeRebar'.

    It takes eight different orientations input for Main 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 main_hook_extend_along i.e. 'x-axis',
    'y-axis'.

    Note: Type of sec_rebars_t_offset, sec_rebars_b_offset,
    sec_rebars_number_diameter, sec_rebars_type, sec_hook_orientation,
    l_sec_rebar_rounding and sec_hook_extension arguments is a tuple.
    Syntax: (<value_for_xdir_rebars>, <value_for_ydir_rebars>).

    In sec_hook_orientation(<xdir_rebars_orientation>,
    <ydir_rebars_orientation>),
    Value of xdir_rebars_orientation can be: 'Top Inside', 'Top Outside',
    'Bottom Inside', 'Bottom Outside', 'Top Upward', 'Top Downward', 'Bottom
    Upward', 'Bottom Downward'.
    Value of ydir_rebars_orientation can be: 'Top Inside', 'Top Outside',
    'Bottom Inside', 'Bottom Outside', 'Top Left', 'Top Right', 'Bottom
    Left', 'Bottom Right'.
    """
    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

    SingleTieFourRebarsObject = 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_main_rebars,
        main_rebars_t_offset,
        main_rebars_b_offset,
        main_rebars_type,
        main_hook_orientation,
        main_hook_extend_along,
        l_main_rebar_rounding,
        main_hook_extension,
        structure,
        facename,
    )

    if not sec_rebars_number_diameter:
        return SingleTieFourRebarsObject
    else:
        xdir_rebars_number_diameter = sec_rebars_number_diameter[0]
        ydir_rebars_number_diameter = sec_rebars_number_diameter[1]
        if (
            not xdir_rebars_number_diameter
            or xdir_rebars_number_diameter == "0"
        ) and (
            not ydir_rebars_number_diameter
            or ydir_rebars_number_diameter == "0"
        ):
            return SingleTieFourRebarsObject

    # Set parameters for xdir and ydir rebars
    if not sec_rebars_t_offset:
        xdir_rebars_t_offset = ydir_rebars_t_offset = main_rebars_t_offset
    else:
        xdir_rebars_t_offset = sec_rebars_t_offset[0]
        ydir_rebars_t_offset = sec_rebars_t_offset[1]
    if not sec_rebars_b_offset:
        xdir_rebars_b_offset = ydir_rebars_b_offset = main_rebars_b_offset
    else:
        xdir_rebars_b_offset = sec_rebars_b_offset[0]
        ydir_rebars_b_offset = sec_rebars_b_offset[1]
    xdir_rebars_type = sec_rebars_type[0]
    ydir_rebars_type = sec_rebars_type[1]
    if not sec_hook_orientation:
        if xdir_rebars_type == "StraightRebar":
            xdir_hook_orientation = None
        elif xdir_rebars_type == "LShapeRebar":
            xdir_hook_orientation = "Top Inside"
        if ydir_rebars_type == "StraightRebar":
            ydir_hook_orientation = None
        elif ydir_rebars_type == "LShapeRebar":
            ydir_hook_orientation = "Top Inside"
    else:
        xdir_hook_orientation = sec_hook_orientation[0]
        ydir_hook_orientation = sec_hook_orientation[1]
    if l_sec_rebar_rounding:
        l_xdir_rebar_rounding = l_sec_rebar_rounding[0]
        l_ydir_rebar_rounding = l_sec_rebar_rounding[1]
    if sec_hook_extension:
        xdir_hook_extension = sec_hook_extension[0]
        ydir_hook_extension = sec_hook_extension[1]

    if xdir_rebars_number_diameter and xdir_rebars_number_diameter != "0":
        xdir_rebars = makeXDirRebars(
            l_cover_of_tie,
            r_cover_of_tie,
            t_cover_of_tie,
            b_cover_of_tie,
            dia_of_tie,
            dia_of_main_rebars,
            xdir_rebars_t_offset,
            xdir_rebars_b_offset,
            xdir_rebars_type,
            xdir_hook_orientation,
            xdir_hook_extension,
            l_xdir_rebar_rounding,
            xdir_rebars_number_diameter,
            facename,
            structure,
        )
    if ydir_rebars_number_diameter and ydir_rebars_number_diameter != "0":
        ydir_rebars = makeYDirRebars(
            l_cover_of_tie,
            r_cover_of_tie,
            t_cover_of_tie,
            b_cover_of_tie,
            dia_of_tie,
            dia_of_main_rebars,
            ydir_rebars_t_offset,
            ydir_rebars_b_offset,
            ydir_rebars_type,
            ydir_hook_orientation,
            ydir_hook_extension,
            l_ydir_rebar_rounding,
            ydir_rebars_number_diameter,
            facename,
            structure,
        )

    # Create object of _SingleTieMultipleRebars to add new properties to it
    SingleTieMultipleRebars = _SingleTieMultipleRebars(
        SingleTieFourRebarsObject
    )

    # Add created xdir/ydir rebars to xdir_rebars_group/ydir_rebars_group
    SingleTieMultipleRebars.addXDirRebars(xdir_rebars)
    SingleTieMultipleRebars.addYDirRebars(ydir_rebars)

    # Set properties values for xdir_rebars in  xdir_rebars_group object
    if len(xdir_rebars) > 0:
        xdir_rebars_group = SingleTieMultipleRebars.xdir_rebars_group
        xdir_rebars_group.RebarType = xdir_rebars_type
        if xdir_rebars_type == "LShapeRebar":
            xdir_rebars_group.HookOrientation = xdir_hook_orientation
            xdir_rebars_group.HookExtension = xdir_hook_extension
        else:
            xdir_rebars_group.HookOrientation = "Top Inside"
        xdir_rebars_group.TopOffset = xdir_rebars_t_offset
        xdir_rebars_group.BottomOffset = xdir_rebars_b_offset
        xdir_rebars_group.NumberDiameter = xdir_rebars_number_diameter

    # Set properties values for ydir_rebars in  ydir_rebars_group object
    if len(ydir_rebars) > 0:
        ydir_rebars_group = SingleTieMultipleRebars.ydir_rebars_group
        ydir_rebars_group.RebarType = ydir_rebars_type
        if ydir_rebars_type == "LShapeRebar":
            ydir_rebars_group.HookOrientation = ydir_hook_orientation
            ydir_rebars_group.HookExtension = ydir_hook_extension
        else:
            ydir_rebars_group.HookOrientation = "Top Inside"
        ydir_rebars_group.TopOffset = ydir_rebars_t_offset
        ydir_rebars_group.BottomOffset = ydir_rebars_b_offset
        ydir_rebars_group.NumberDiameter = ydir_rebars_number_diameter

    FreeCAD.ActiveDocument.recompute()
    return SingleTieMultipleRebars.Object
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