def editHelicalRebar(
    Rebar,
    s_cover,
    b_cover,
    diameter,
    t_cover,
    pitch,
    structure=None,
    facename=None,
):
    sketch = Rebar.Base
    if structure and facename:
        sketch.Support = [(structure, facename)]
    # Check if sketch support is empty.
    if not sketch.Support:
        showWarning(
            "You have checked: 'Remove external geometry of base sketches when "
            "needed.'\nTo uncheck: Edit->Preferences->Arch."
        )
        return
    # Assigned values
    facename = sketch.Support[0][1][0]
    structure = sketch.Support[0][0]
    face = structure.Shape.Faces[getFaceNumber(facename) - 1]
    # StructurePRM = getTrueParametersOfStructure(structure)
    # Get parameters of the face where sketch of rebar is drawn
    FacePRM = getParametersOfFace(structure, facename, False)
    size = (
        ArchCommands.projectToVector(
            structure.Shape.copy(), face.normalAt(0, 0)
        )
    ).Length
    normal = face.normalAt(0, 0)
    # normal = face.Placement.Rotation.inverted().multVec(normal)
    createHelicalWire(
        FacePRM,
        s_cover,
        b_cover,
        t_cover,
        pitch,
        size,
        normal,
        diameter,
        Rebar.Base,
    )
    FreeCAD.ActiveDocument.recompute()
    Rebar.Diameter = diameter
    Rebar.SideCover = s_cover
    Rebar.BottomCover = b_cover
    Rebar.TopCover = t_cover
    Rebar.Pitch = pitch
    FreeCAD.ActiveDocument.recompute()
    return Rebar
Beispiel #2
0
def editSingleTieMultipleRebars(
    rebar_group,
    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,
):
    """editSingleTieMultipleRebars(RebarGroup, 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):
    Edit the Single Tie Multiple Rebars reinforcement for 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 len(rebar_group.RebarGroups) == 0:
        return rebar_group
    for i, tmp_rebar_group in enumerate(rebar_group.RebarGroups):
        if hasattr(tmp_rebar_group, "Ties"):
            if len(tmp_rebar_group.Ties) > 0:
                Tie = tmp_rebar_group.Ties[0]
                break
            else:
                showWarning(
                    "You have deleted ties. Please recreate the "
                    "ColumnReinforcement."
                )
                return rebar_group
        elif i == len(rebar_group.RebarGroups) - 1:
            showWarning(
                "You have deleted ties group. Please recreate the "
                "ColumnReinforcement."
            )
            return rebar_group

    if not structure and not facename:
        structure = Tie.Base.Support[0][0]
        facename = Tie.Base.Support[0][1][0]

    # Edit ties and main rebars
    editSingleTieFourRebars(
        rebar_group,
        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 secondary rebars doesn't exists, return
    if len(rebar_group.RebarGroups) < 3:
        FreeCAD.ActiveDocument.recompute()
        return rebar_group

    # Set parameters for xdir and ydir rebars
    xdir_rebars_group = rebar_group.RebarGroups[2].SecondaryRebars[0]
    ydir_rebars_group = rebar_group.RebarGroups[2].SecondaryRebars[1]
    if not sec_rebars_t_offset:
        xdir_rebars_t_offset = xdir_rebars_group.TopOffset
        ydir_rebars_t_offset = ydir_rebars_group.TopOffset
    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 = xdir_rebars_group.BottomOffset
        ydir_rebars_b_offset = ydir_rebars_group.BottomOffset
    else:
        xdir_rebars_b_offset = sec_rebars_b_offset[0]
        ydir_rebars_b_offset = sec_rebars_b_offset[1]
    if not sec_rebars_number_diameter:
        xdir_rebars_number_diameter = xdir_rebars_group.NumberDiameter
        ydir_rebars_number_diameter = ydir_rebars_group.NumberDiameter
    else:
        xdir_rebars_number_diameter = sec_rebars_number_diameter[0]
        ydir_rebars_number_diameter = sec_rebars_number_diameter[1]

    xdir_rebars_type = sec_rebars_type[0]
    ydir_rebars_type = sec_rebars_type[1]
    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]

    # Set common parameters of xdir and ydir rebars
    xdir_rebars = xdir_rebars_group.XDirRebars
    ydir_rebars = ydir_rebars_group.YDirRebars

    # Check if there is need to recreate rebars
    prev_xdir_rebars_type = xdir_rebars_group.RebarType
    prev_xdir_rebars_number_diameter = xdir_rebars_group.NumberDiameter
    prev_ydir_rebars_type = ydir_rebars_group.RebarType
    prev_ydir_rebars_number_diameter = ydir_rebars_group.NumberDiameter
    if (
        prev_xdir_rebars_type == xdir_rebars_type
        and prev_xdir_rebars_number_diameter == xdir_rebars_number_diameter
    ):
        recreate_xdir_rebars = False
    else:
        recreate_xdir_rebars = True
    if (
        prev_ydir_rebars_type == ydir_rebars_type
        and prev_ydir_rebars_number_diameter == ydir_rebars_number_diameter
    ):
        recreate_ydir_rebars = False
    else:
        recreate_ydir_rebars = True

    if recreate_xdir_rebars:
        for Rebar in xdir_rebars:
            base_name = Rebar.Base.Name
            FreeCAD.ActiveDocument.removeObject(Rebar.Name)
            FreeCAD.ActiveDocument.removeObject(base_name)
        FreeCAD.ActiveDocument.recompute()

        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,
            )
    else:
        editXDirRebars(
            xdir_rebars,
            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 recreate_ydir_rebars:
        for Rebar in ydir_rebars:
            base_name = Rebar.Base.Name
            FreeCAD.ActiveDocument.removeObject(Rebar.Name)
            FreeCAD.ActiveDocument.removeObject(base_name)
        FreeCAD.ActiveDocument.recompute()

        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,
            )
    else:
        editYDirRebars(
            ydir_rebars,
            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,
        )

    # Add created xdir/ydir rebars to xdir_rebars_group/ydir_rebars_group
    xdir_rebars_group.addObjects(xdir_rebars)
    ydir_rebars_group.addObjects(ydir_rebars)

    # Set properties values for xdir_rebars in  xdir_rebars_group object
    xdir_rebars_group.XDirRebars = xdir_rebars
    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
    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
    ydir_rebars_group.YDirRebars = ydir_rebars
    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
    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 rebar_group
Beispiel #3
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
Beispiel #4
0
    def accept(self):
        """This function is executed when 'OK' button is clicked from UI. It
        execute a function to reinforcement drawing and dimensioning."""
        # Check if template file is selected or not
        template_file = self.drawing_widget.template_file.text()
        if not template_file:
            self.drawing_widget.template_file.setStyleSheet(
                "border: 1px solid red;")
            showWarning(
                'Choose template for drawing under: "Drawing - Views & Options"'
            )
            return
        # Get drawing data
        form = self.shapes_data_widget
        rebars_stroke_width = FreeCAD.Units.Quantity(
            form.rebars_stroke_width.text()).Value
        if form.rebars_shape_color_radio.isChecked():
            rebars_color_style = "Automatic"
        else:
            rebars_color_style = "Custom"
        rebars_color = form.rebars_color.property("color").getRgbF()
        structure_stroke_width = FreeCAD.Units.Quantity(
            form.structure_stroke_width.text()).Value
        if form.structure_shape_color_radio.isChecked():
            structure_color_style = "Automatic"
        elif form.structure_custom_color_radio.isChecked():
            structure_color_style = "Custom"
        else:
            structure_color_style = "None"
        structure_color = form.structure_color.property("color").getRgbF()
        form = self.drawing_widget
        views = []
        if form.front_view_check_box.isChecked():
            views.append("Front")
        if form.rear_view_check_box.isChecked():
            views.append("Rear")
        if form.left_view_check_box.isChecked():
            views.append("Left")
        if form.right_view_check_box.isChecked():
            views.append("Right")
        if form.top_view_check_box.isChecked():
            views.append("Top")
        if form.bottom_view_check_box.isChecked():
            views.append("Bottom")
        drawing_left_offset = FreeCAD.Units.Quantity(
            form.drawing_left_offset.text()).Value
        drawing_top_offset = FreeCAD.Units.Quantity(
            form.drawing_top_offset.text()).Value
        drawing_min_right_offset = FreeCAD.Units.Quantity(
            form.drawing_min_right_offset.text()).Value
        drawing_min_bottom_offset = FreeCAD.Units.Quantity(
            form.drawing_min_bottom_offset.text()).Value
        drawing_max_width = FreeCAD.Units.Quantity(
            form.drawing_max_width.text()).Value
        drawing_max_height = FreeCAD.Units.Quantity(
            form.drawing_max_height.text()).Value

        # Get dimensioning data
        form = self.dimension_labels_lines_widget
        perform_dimensioning = (
            self.drawing_widget.perform_dimensioning_radio_button.isChecked())
        dimension_label_format = form.dimension_label_format.text()
        dimension_font_family = form.dimension_font_family.currentText()
        dimension_font_size = form.dimension_font_size.value()
        dimension_text_color = form.dimension_text_color.property(
            "color").getRgbF()
        dimension_stroke_width = FreeCAD.Units.Quantity(
            form.dimension_stroke_width.text()).Value
        dimension_line_style = form.dimension_line_style.currentText()
        dimension_line_color = form.dimension_line_color.property(
            "color").getRgbF()
        dimension_line_mid_point_symbol = (
            form.dimension_line_mid_point_symbol.currentText())
        form = self.dimension_single_multi_rebars_widget
        dimension_single_rebar_line_start_symbol = (
            form.single_rebar_dimension_line_start_symbol.currentText())
        dimension_single_rebar_line_end_symbol = (
            form.single_rebar_dimension_line_end_symbol.currentText())
        dimension_single_rebar_text_position_type = (
            form.single_rebar_text_position_type.currentText())
        dimension_single_rebar_outer_dim = (
            form.single_rebar_outer_dimension.isChecked())
        dimension_multi_rebar_line_start_symbol = (
            form.multi_rebar_dimension_line_start_symbol.currentText())
        dimension_multi_rebar_line_end_symbol = (
            form.multi_rebar_dimension_line_end_symbol.currentText())
        dimension_multi_rebar_text_position_type = (
            form.multi_rebar_text_position_type.currentText())
        dimension_multi_rebar_outer_dim = (
            form.multi_rebar_outer_dimension.isChecked())
        form = self.dimension_offsets_increments_widget
        dimension_left_offset = FreeCAD.Units.Quantity(
            form.dimension_left_offset.text()).Value
        dimension_right_offset = FreeCAD.Units.Quantity(
            form.dimension_right_offset.text()).Value
        dimension_top_offset = FreeCAD.Units.Quantity(
            form.dimension_top_offset.text()).Value
        dimension_bottom_offset = FreeCAD.Units.Quantity(
            form.dimension_bottom_offset.text()).Value
        dimension_left_offset_increment = FreeCAD.Units.Quantity(
            form.dimension_left_offset_increment.text()).Value
        dimension_right_offset_increment = FreeCAD.Units.Quantity(
            form.dimension_right_offset_increment.text()).Value
        dimension_top_offset_increment = FreeCAD.Units.Quantity(
            form.dimension_top_offset_increment.text()).Value
        dimension_bottom_offset_increment = FreeCAD.Units.Quantity(
            form.dimension_bottom_offset_increment.text()).Value

        # Get selected objects list
        selected_objects = [
            selection.Object
            for selection in FreeCADGui.Selection.getSelectionEx()
        ]
        reinforcement_objs = getReinforcementRebarObjects(selected_objects)
        if not reinforcement_objs:
            reinforcement_objs = getReinforcementRebarObjects(
                FreeCAD.ActiveDocument.Objects)

        def getFreeCADObjectsList(objects: list,
                                  # ) -> Union[Literal["None"], str]:
                                  ) -> str:
            return ("None" if not objects else "[" + ",".join(
                ["FreeCAD.ActiveDocument." + obj.Name
                 for obj in objects]) + "]")

        rebars_list = getFreeCADObjectsList(reinforcement_objs)
        FreeCADGui.addModule("ReinforcementDrawing.make_reinforcement_drawing")
        for view in views:
            FreeCADGui.doCommand(
                "ReinforcementDrawing.make_reinforcement_drawing."
                "makeStructuresReinforcementDrawing(structure_list=None, "
                f"rebars_list={rebars_list}, "
                f'view="{view}", '
                f"rebars_stroke_width={rebars_stroke_width}, "
                f'rebars_color_style="{rebars_color_style}", '
                f"rebars_color={rebars_color}, "
                f"structure_stroke_width={structure_stroke_width}, "
                f'structure_color_style="{structure_color_style}", '
                f"structure_color={structure_color}, "
                f"drawing_left_offset={drawing_left_offset}, "
                f"drawing_top_offset={drawing_top_offset}, "
                f"drawing_min_right_offset={drawing_min_right_offset}, "
                f"drawing_min_bottom_offset={drawing_min_bottom_offset}, "
                f"drawing_max_width={drawing_max_width}, "
                f"drawing_max_height={drawing_max_height}, "
                f'template_file=r"{template_file}", '
                f"perform_dimensioning={perform_dimensioning}, "
                "dimension_rebars_filter_list=None, "
                f'dimension_label_format="{dimension_label_format}",  '
                f'dimension_font_family="{dimension_font_family}", '
                f"dimension_font_size={dimension_font_size}, "
                f"dimension_stroke_width={dimension_stroke_width}, "
                f'dimension_line_style="{dimension_line_style}",'
                f" dimension_line_color={dimension_line_color}, "
                f"dimension_text_color={dimension_text_color}, "
                'dimension_single_rebar_line_start_symbol="'
                f'{dimension_single_rebar_line_start_symbol}", '
                'dimension_single_rebar_line_end_symbol="'
                f'{dimension_single_rebar_line_end_symbol}", '
                'dimension_multi_rebar_line_start_symbol="'
                f'{dimension_multi_rebar_line_start_symbol}", '
                'dimension_multi_rebar_line_end_symbol="'
                f'{dimension_multi_rebar_line_end_symbol}", '
                'dimension_line_mid_point_symbol="'
                f'{dimension_line_mid_point_symbol}", '
                f"dimension_left_offset={dimension_left_offset}, "
                f"dimension_right_offset={dimension_right_offset}, "
                f"dimension_top_offset={dimension_top_offset}, "
                f"dimension_bottom_offset={dimension_bottom_offset}, "
                "dimension_left_offset_increment="
                f"{dimension_left_offset_increment}, "
                "dimension_right_offset_increment="
                f"{dimension_right_offset_increment}, "
                "dimension_top_offset_increment="
                f"{dimension_top_offset_increment}, "
                "dimension_bottom_offset_increment="
                f"{dimension_bottom_offset_increment}, "
                "dimension_single_rebar_outer_dim="
                f"{dimension_single_rebar_outer_dim}, "
                "dimension_multi_rebar_outer_dim="
                f"{dimension_multi_rebar_outer_dim}, "
                "dimension_single_rebar_text_position_type="
                f'"{dimension_single_rebar_text_position_type}", '
                "dimension_multi_rebar_text_position_type="
                f'"{dimension_multi_rebar_text_position_type}")')
        self.form.close()
Beispiel #5
0
def editStirrup(
    Rebar,
    l_cover,
    r_cover,
    t_cover,
    b_cover,
    f_cover,
    bentAngle,
    bentFactor,
    diameter,
    rounding,
    amount_spacing_check,
    amount_spacing_value,
    structure=None,
    facename=None,
):
    sketch = Rebar.Base
    if structure and facename:
        sketch.Support = [(structure, facename)]
    # Check if sketch support is empty.
    if not sketch.Support:
        showWarning(
            "You have checked: 'Remove external geometry of base sketches when "
            "needed.'\nTo uncheck: Edit->Preferences->Arch.")
        return
    # Assigned values
    facename = sketch.Support[0][1][0]
    structure = sketch.Support[0][0]
    face = structure.Shape.Faces[getFaceNumber(facename) - 1]
    # StructurePRM = getTrueParametersOfStructure(structure)
    # Get parameters of the face where sketch of rebar is drawn
    FacePRM = getParametersOfFace(structure, facename, False)
    FaceNormal = face.normalAt(0, 0)
    # FaceNormal = face.Placement.Rotation.inverted().multVec(FaceNormal)
    # Calculate the coordinates value of Stirrup rebar
    points = getpointsOfStirrup(
        FacePRM,
        l_cover,
        r_cover,
        t_cover,
        b_cover,
        bentAngle,
        bentFactor,
        diameter,
        rounding,
        FaceNormal,
    )
    Rebar.Base.Points = points
    FreeCAD.ActiveDocument.recompute()
    Rebar.Direction = FaceNormal.negative()
    Rebar.OffsetStart = f_cover + diameter / 2
    Rebar.OffsetEnd = f_cover + diameter / 2
    Rebar.BentAngle = bentAngle
    Rebar.BentFactor = bentFactor
    Rebar.Rounding = rounding
    Rebar.Diameter = diameter
    if amount_spacing_check:
        Rebar.Amount = amount_spacing_value
        FreeCAD.ActiveDocument.recompute()
        Rebar.AmountCheck = True
    else:
        size = (ArchCommands.projectToVector(structure.Shape.copy(),
                                             face.normalAt(0, 0))).Length
        Rebar.Amount = int((size - diameter) / amount_spacing_value)
        FreeCAD.ActiveDocument.recompute()
        Rebar.AmountCheck = False
    Rebar.FrontCover = f_cover
    Rebar.LeftCover = l_cover
    Rebar.RightCover = r_cover
    Rebar.TopCover = t_cover
    Rebar.BottomCover = b_cover
    Rebar.TrueSpacing = amount_spacing_value
    FreeCAD.ActiveDocument.recompute()
    return Rebar
Beispiel #6
0
def editReinforcement(
    rebar_group,
    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,
):
    """editReinforcement(RebarGroup, SideCover, TopOffsetOfHelicalRebars,
    BottomOffsetOfHelicalRebars, Pitch, DiameterOfHelicalRebar,
    TopOffsetOfMainRebars, BottomOffsetOfMainRebars, DiameterOfMainRebars,
    NumberAngleCheck, NumberAngleValue, Structure, Facename):
    Edit the helical and straight rebars for the selected structural column
    object.
    """
    helical_rebar = rebar_group.RebarGroups[0].HelicalRebars[0]
    line = helical_rebar.Base
    if structure and facename:
        line.Support = [(structure, facename)]
    # Check if line support is empty.
    if not line.Support:
        showWarning(
            "You have checked remove external geometry of base lines when"
            " needed.\nTo unchecked Edit->Preferences->Arch.")
        return
    # Assigned values
    structure = line.Support[0][0]
    facename = line.Support[0][1][0]

    helical_rebar = editHelicalRebar(
        helical_rebar,
        s_cover,
        helical_rebar_b_offset,
        dia_of_helical_rebar,
        helical_rebar_t_offset,
        pitch,
        structure,
        facename,
    )

    if number_angle_check:
        number = number_angle_value
    else:
        number = math.ceil(360 / number_angle_value)
    base_line_list = []
    for i, rebar in enumerate(rebar_group.RebarGroups[1].MainRebars):
        if i < number:
            base_line_list.append(rebar.Base)
        else:
            FreeCAD.ActiveDocument.removeObject(rebar.Base.Name)
        FreeCAD.ActiveDocument.removeObject(rebar.Name)

    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,
        base_line_list,
    )

    rebar_group.RebarGroups[1].addObjects(main_rebars_list)
    rebar_group.RebarGroups[1].MainRebars = main_rebars_list
    rebar_group.RebarGroups[1].TopOffset = main_rebars_t_offset
    rebar_group.RebarGroups[1].BottomOffset = main_rebars_b_offset
    rebar_group.RebarGroups[1].Diameter = dia_of_main_rebars
    rebar_group.RebarGroups[1].NumberAngleCheck = number_angle_check
    rebar_group.RebarGroups[1].Number = number
    if number_angle_check:
        rebar_group.RebarGroups[1].Number = number_angle_value
        rebar_group.RebarGroups[1].Angle = 360.00 / number_angle_value
    else:
        rebar_group.RebarGroups[1].Number = math.ceil(360 / number_angle_value)
        rebar_group.RebarGroups[1].Angle = number_angle_value
    FreeCAD.ActiveDocument.recompute()
    return rebar_group
Beispiel #7
0
def editUShapeRebar(
    Rebar,
    f_cover,
    b_cover,
    r_cover,
    l_cover,
    diameter,
    t_cover,
    rounding,
    amount_spacing_check,
    amount_spacing_value,
    orientation,
    structure=None,
    facename=None,
):
    sketch = Rebar.Base
    if structure and facename:
        sketch.Support = [(structure, facename)]
    # Check if sketch support is empty.
    if not sketch.Support:
        showWarning(
            "You have checked: 'Remove external geometry of base sketches when "
            "needed.'\nTo uncheck: Edit->Preferences->Arch.")
        return
    # Assigned values
    facename = sketch.Support[0][1][0]
    structure = sketch.Support[0][0]
    face = structure.Shape.Faces[getFaceNumber(facename) - 1]
    # StructurePRM = getTrueParametersOfStructure(structure)
    # Get parameters of the face where sketch of rebar is drawn
    FacePRM = getParametersOfFace(structure, facename)
    # Get points of U-Shape rebar
    points = getpointsOfUShapeRebar(FacePRM, r_cover, l_cover, b_cover,
                                    t_cover, orientation, diameter)
    sketch.movePoint(0, 1, points[0], 0)
    FreeCAD.ActiveDocument.recompute()
    sketch.movePoint(0, 2, points[1], 0)
    FreeCAD.ActiveDocument.recompute()
    sketch.movePoint(1, 1, points[1], 0)
    FreeCAD.ActiveDocument.recompute()
    sketch.movePoint(1, 2, points[2], 0)
    FreeCAD.ActiveDocument.recompute()
    sketch.movePoint(2, 1, points[2], 0)
    FreeCAD.ActiveDocument.recompute()
    sketch.movePoint(2, 2, points[3], 0)
    FreeCAD.ActiveDocument.recompute()
    Rebar.OffsetStart = f_cover + diameter / 2
    Rebar.OffsetEnd = f_cover + diameter / 2
    if amount_spacing_check:
        Rebar.Amount = amount_spacing_value
        FreeCAD.ActiveDocument.recompute()
        Rebar.AmountCheck = True
    else:
        size = (ArchCommands.projectToVector(structure.Shape.copy(),
                                             face.normalAt(0, 0))).Length
        Rebar.Amount = int((size - diameter) / amount_spacing_value)
        FreeCAD.ActiveDocument.recompute()
        Rebar.AmountCheck = False
    Rebar.Diameter = diameter
    Rebar.FrontCover = f_cover
    Rebar.RightCover = r_cover
    Rebar.LeftCover = l_cover
    Rebar.BottomCover = b_cover
    Rebar.TopCover = t_cover
    Rebar.Rounding = rounding
    Rebar.TrueSpacing = amount_spacing_value
    Rebar.Orientation = orientation
    FreeCAD.ActiveDocument.recompute()
    return Rebar
Beispiel #8
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
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
def editTwoTiesSixRebars(
        rebar_group,
        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,
):
    """editTwoTiesSixRebars(RebarGroup, LeftCoverOfTies, RightCoverOfTies,
    TopCoverOfTies, BottomCoverOfTies, OffsetofTies, BentAngleOfTies,
    ExtensionFactorOfTies, DiameterOfTies, NumberSpacingCheck,
    NumberSpacingValue, DiameterOfMainRebars, TopOffsetOfMainRebars,
    BottomOffsetOfRebars, MainRebarsType, LShapeHookOrientation,
    HookExtendAlong, LShapeRebarRounding, LShapeHookLength, TiesSequence,
    Structure, Facename):
    """
    if len(rebar_group.RebarGroups) == 0:
        return rebar_group
    for i, tmp_rebar_group in enumerate(rebar_group.RebarGroups):
        if hasattr(tmp_rebar_group, "Ties"):
            if len(tmp_rebar_group.Ties) > 0:
                Tie = tmp_rebar_group.Ties[0]
                break
            else:
                showWarning("You have deleted ties. Please recreate the"
                            "ColumnReinforcement.")
                return rebar_group
        elif i == len(rebar_group.RebarGroups) - 1:
            showWarning("You have deleted ties group. Please recreate the"
                        "ColumnReinforcement.")
            return rebar_group

    if not structure and not facename:
        structure = Tie.Base.Support[0][0]
        facename = Tie.Base.Support[0][1][0]

    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

    # Edit tie2
    tie2 = rebar_group.RebarGroups[0].Ties[1]
    rounding = (float(dia_of_ties) / 2 + dia_of_main_rebars / 2) / dia_of_ties
    tie2 = editStirrup(
        tie2,
        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_rebar_group = rebar_group.RebarGroups[1]
    main_rebars = editMainRebars(
        main_rebar_group,
        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,
    )

    # Edit SingleTieFourRebars
    rebar_group = editSingleTieFourRebars(
        rebar_group,
        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,
    )
    rebar_group.RebarGroups[0].Ties[0].OffsetEnd = (end_offset_of_tie1 +
                                                    dia_of_ties / 2)

    if main_rebars:
        main_rebar_group.addObjects(main_rebars)
        prev_main_rebars = main_rebar_group.MainRebars
        prev_main_rebars.extend(main_rebars)
        main_rebar_group.MainRebars = prev_main_rebars

    rebar_group.RebarGroups[0].LeftCover = l_cover_of_ties
    rebar_group.RebarGroups[0].RightCover = r_cover_of_ties
    rebar_group.RebarGroups[0].TopCover = t_cover_of_ties
    rebar_group.RebarGroups[0].BottomCover = b_cover_of_ties
    rebar_group.RebarGroups[0].TiesSequence = ties_sequence

    FreeCAD.ActiveDocument.recompute()
    return rebar_group
def makeFootingReinforcement(
    parallel_rebar_type: str,
    parallel_front_cover: float,
    parallel_rear_cover: float,
    parallel_left_cover: float,
    parallel_right_cover: float,
    parallel_top_cover: float,
    parallel_bottom_cover: float,
    parallel_diameter: float,
    parallel_amount_spacing_check: bool,
    parallel_amount_spacing_value: Union[float, int],
    cross_rebar_type: str,
    cross_front_cover: float,
    cross_rear_cover: float,
    cross_left_cover: float,
    cross_right_cover: float,
    cross_top_cover: float,
    cross_bottom_cover: float,
    cross_diameter: float,
    cross_amount_spacing_check: bool,
    column_front_spacing: float,
    column_left_spacing: float,
    column_right_spacing: float,
    column_rear_spacing: float,
    tie_top_cover: float,
    tie_bottom_cover: float,
    tie_bent_angle: int,
    tie_extension_factor: int,
    tie_diameter: float,
    tie_number_spacing_check: bool,
    tie_number_spacing_value: Union[float, int],
    column_main_rebar_diameter: float,
    column_main_rebars_t_offset: float,
    cross_amount_spacing_value: Union[float, int],
    column_width: float,
    column_length: float,
    xdir_column_amount_spacing_check: bool = True,
    xdir_column_amount_spacing_value: Union[float, int] = 1,
    ydir_column_amount_spacing_check: bool = True,
    ydir_column_amount_spacing_value: Union[float, int] = 1,
    parallel_rounding: Optional[int] = 2,
    parallel_l_shape_hook_orintation: Optional[str] = "Alternate",
    cross_rounding: Optional[int] = 2,
    cross_l_shape_hook_orintation: Optional[str] = "Alternate",
    column_main_rebars_type: Optional[str] = "StraightRebar",
    column_main_hook_orientation: Optional[str] = "Bottom Outside",
    column_main_hook_extend_along: Optional[str] = "x-axis",
    column_l_main_rebar_rounding: Optional[int] = 2,
    column_main_hook_extension: Optional[float] = 40,
    column_sec_rebar_check: Optional[bool] = False,
    column_sec_rebars_t_offset: Optional[Tuple[float, float]] = (400, 400),
    column_sec_rebars_number_diameter: Optional[Tuple[float, float]] = (
        "1#8mm+1#8mm+1#8mm",
        "1#8mm+1#8mm+1#8mm",
    ),
    column_sec_rebars_type: Optional[Tuple[str, str]] = (
        "StraightRebar",
        "StraightRebar",
    ),
    column_sec_hook_orientation: Optional[Tuple[str, str]] = (
        "Top Inside",
        "Top Inside",
    ),
    column_l_sec_rebar_rounding: Optional[Tuple[int, int]] = (2, 2),
    column_sec_hook_extension: Optional[Tuple[float, float]] = (40, 40),
    mesh_cover_along: str = "Bottom",
    structure: Optional[Tuple] = None,
    facename: Optional[str] = None,
):
    """Generate Footing Reinforcement

    Parameters
    ----------
    parallel_rebar_type: str
        Type of rebar for parallel rebars for Footing reinforcement.
        It can have four values 'StraightRebar','LShapeRebar', 'UShapeRebar'.
    parallel_front_cover: float
        The distance between parallel rebar and selected face.
    parallel_rear_cover: float
        Rear cover for footing reinforcement of parallel rebars.
    parallel_left_cover: float
        The distance between the left end of the parallel rebar to the left face of
        the structure.
    parallel_right_cover: float
        The distance between the right end of the parallel rebar to right face of
        the structure.
    parallel_top_cover: float
        The distance between parallel rebars from the top face of the structure.
    parallel_bottom_cover: float
        The distance between parallel rebars from the bottom face of the structure.
    parallel_diameter: float
        Diameter of parallel rebars.
    parallel_amount_spacing_check: bool
        If is set to True, then value of parallel_amount_spacing_value is used as
        rebars count else parallel_amount_spacing_value's value is used as spacing
        in parallel rebars.
    parallel_amount_spacing_value: float or int
        It contains count of rebars or spacing between parallel rebars based on
        value of amount_spacing_check.
    cross_rebar_type: str
        Type of rebar for cross rebars for slab reinforcement.
        It can have four values 'StraightRebar','LShapeRebar', 'UShapeRebar'.
    cross_front_cover: float
        The distance between cross rebar and cross_face (face perpendicular to selected face).
    cross_rear_cover: float
        Rear cover for footing reinforcement of cross rebars.
    cross_left_cover: float
        The distance between the left end of the cross rebar to the left face of
        the structure.
    cross_right_cover: float
        The distance between the right end of the rebar to right face of
        the structure relative to cross_face.
    cross_top_cover: float
        The distance between cross rebar from the top face of the structure.
    cross_bottom_cover: float
        The distance between cross rebar from the bottom face of the structure.
    cross_diameter: float
        Diameter of cross rebars.
    cross_amount_spacing_check: bool
        If is set to True, then value of cross_amount_spacing_value is used as
        rebars count else cross_amount_spacing_value's value is used as spacing
        in rebars.
    cross_amount_spacing_value: float or int
        It contains count of rebars or spacing between rebars based on
        value of cross_amount_spacing_check.
    cross_rounding: int
        A rounding value to be applied to the corners of the bars, expressed
        in times the cross_diameter.
    cross_l_shape_hook_orintation: str
        It represents orintation of hook of cross L-Shape rebar if cross_rebar_type
        is LShapeRebar.
        It can have tree values "Left", "Right", "Alternate"
    parallel_rounding: int
        A rounding value to be applied to the corners of the bars, expressed
        in times the parallel_diameter.
    parallel_l_shape_hook_orintation: str
        It represents orintation of hook of parallel L-Shape rebar if parallel_rebar_type
        is LShapeRebar.
        It can have tree values "Left", "Right", "Alternate".
    column_front_spacing: float
        Distance between selected face and front columns.
    column_left_spacing: float,
        Distance between left face and left columns.
    column_right_spacing: float
        Distance between right face and right columns.
    column_rear_spacing: float
        Distance between rear face and rear columns.
    tie_top_cover: float
        Top cover for ties outside footing.
    tie_bottom_cover: float
        Bottom cover of ties from Bottom footing rebars mesh.
    tie_bent_angle: int
        Bent angle for ties.
    tie_extension_factor: int
        Extension factor for ties extended edge.
    tie_diameter: float
        Diameter of ties.
    tie_number_spacing_check: bool
        If is set to True, then value of tie_number_spacing_value is used as
        rebars count else tie_number_spacing_value's value is used as spacing
        in ties.
    tie_number_spacing_value: float
        It contains count of rebars or spacing between ties based on
        value of tie_number_spacing_check.
    column_main_rebar_diameter: float
        Diameter of main rebars in columns.
    column_main_rebars_t_offset: float
        Top offset of main rebars in column outside footing.
    column_width: float
        Width of columns.
    column_length: float
        Length of columns.
    xdir_column_amount_spacing_check: bool
        If is set to True, then value of xdir_column_amount_spacing_value is used as
        column count else xdir_column_amount_spacing_value's value is used as spacing
        between columns in x direction.
    xdir_column_amount_spacing_value: int
        It contains count of columns or spacing between columns in x direction based on
        value of xdir_column_amount_spacing_check.
    ydir_column_amount_spacing_check: bool
        If is set to True, then value of ydir_column_amount_spacing_value is used as
        columns count else ydir_column_amount_spacing_value's value is used as spacing
        between columns in y direction.
    ydir_column_amount_spacing_value: int
        It contains count of columns or spacing between  between columns in y direction based on
        value of ydir_column_amount_spacing_check.
    column_main_rebars_type: Optional[str] ,
        Rebar type for main rebars of column. It takes two different inputs for 'StraightRebar',
        'LShapeRebar'. Default  is StraightRebar.
    column_main_hook_orientation: Optional[str],
        Hook orientation of main rebars in columns if column_main_rebars_type is 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'.
    column_main_hook_extend_along: Optional[str],
        Direction of main rebar (LShapeRebar) hook. it has two option "x-axis" and "y-axis".
    column_l_main_rebar_rounding: Optional[int],
        A rounding value to be applied to the corners of the bars, expressed
        in times the column_main_rebar_diameter.
    column_main_hook_extension: Optional[float],
        It specifies length of hook of main rebar (LShapeRebar).
    column_sec_rebar_check: Optional[bool]
        If True add secondary x and y direction rebars in columns.
    column_sec_rebars_t_offset: Optional[Tuple[ float,float]],
        Top offset for secounday rebars of column.
        Syntax: (<value_for_sec_xdir_rebars>, <value_for_sec_ydir_rebars>)
    column_sec_rebars_number_diameter: Optional[Tuple[ float,float]],
        Diameter of secondary rebars of columns.
        Syntax: (<value_for_sec_xdir_rebars>, <value_for_sec_ydir_rebars>)
    column_sec_rebars_type: Optional[Tuple[ str,str]],
        Rebar type of secondary rebars of columns.
        Syntax: (<value_for_sec_xdir_rebars>, <value_for_sec_ydir_rebars>)
    column_sec_hook_orientation: Optional[Tuple[ str,str]],
        Hook Orientation of secondary rebars of columns.
        In column_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'.
        Syntax: (<value_for_sec_xdir_rebars>, <value_for_sec_ydir_rebars>)
    column_l_sec_rebar_rounding: Optional[Tuple[ int,int]],
        A rounding value to be applied to the corners of the bars, expressed
        in times the column_sec_rebars_number_diameter.
        Syntax: (<value_for_sec_xdir_rebars>, <value_for_sec_ydir_rebars>)
    column_sec_hook_extension: Optional[Tuple[ float,float]],
        Hook length of secondary rebars (LShapeRebar) of columns.
        Syntax: (<value_for_sec_xdir_rebars>, <value_for_sec_ydir_rebars>)
    mesh_cover_along: str
        It can have two values "Top", "Bottom" and "Both". It represent alignment of
        rebar mesh along top or bottom face of structure.
        If "Both" is used as input then footing mesh will be added to top and bottom of footing.
    structure: Arch structure object
        Arch structure object.
        Default is None
    facename: str
        selected face of structure.
        Default is None

    Note: Type of
        column_sec_rebars_t_offset
        column_sec_rebars_number_diameter
        column_sec_rebars_type
        column_sec_hook_orientation
        column_l_sec_rebar_rounding
        column_sec_hook_extension arguments is a tuple.
    Syntax: (<value_for_sec_xdir_rebars>, <value_for_sec_ydir_rebars>).
    """
    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

    footingReinforcementGroup = FootingReinforcementGroup().Object
    if FreeCAD.GuiUp:
        _FootingReinforcementViewProviderGroup(
            footingReinforcementGroup.ViewObject)

    footingReinforcementGroup.IsMakeOrEditRequired = False
    footingReinforcementGroup.MeshCoverAlong = mesh_cover_along
    footingReinforcementGroup.Facename = facename
    footingReinforcementGroup.Structure = structure
    footingReinforcementGroup.ParallelRebarType = parallel_rebar_type
    footingReinforcementGroup.ParallelFrontCover = parallel_front_cover
    footingReinforcementGroup.ParallelRearCover = parallel_rear_cover
    footingReinforcementGroup.ParallelLeftCover = parallel_left_cover
    footingReinforcementGroup.ParallelRightCover = parallel_right_cover
    footingReinforcementGroup.ParallelTopCover = parallel_top_cover
    footingReinforcementGroup.ParallelBottomCover = parallel_bottom_cover
    footingReinforcementGroup.ParallelDiameter = parallel_diameter
    footingReinforcementGroup.ParallelAmountSpacingCheck = (
        parallel_amount_spacing_check)
    if parallel_amount_spacing_check:
        footingReinforcementGroup.ParallelAmountValue = (
            parallel_amount_spacing_value)
    else:
        footingReinforcementGroup.ParallelSpacingValue = (
            parallel_amount_spacing_value)

    if parallel_rounding:
        footingReinforcementGroup.ParallelRounding = parallel_rounding
    if parallel_l_shape_hook_orintation:
        footingReinforcementGroup.ParallelLShapeHookOrintation = (
            parallel_l_shape_hook_orintation)

    footingReinforcementGroup.CrossRebarType = cross_rebar_type
    footingReinforcementGroup.CrossFrontCover = cross_front_cover
    footingReinforcementGroup.CrossRearCover = cross_rear_cover
    footingReinforcementGroup.CrossLeftCover = cross_left_cover
    footingReinforcementGroup.CrossRightCover = cross_right_cover
    footingReinforcementGroup.CrossTopCover = cross_top_cover
    footingReinforcementGroup.CrossBottomCover = cross_bottom_cover
    footingReinforcementGroup.CrossDiameter = cross_diameter
    footingReinforcementGroup.CrossAmountSpacingCheck = (
        cross_amount_spacing_check)
    if cross_amount_spacing_check:
        footingReinforcementGroup.CrossAmountValue = cross_amount_spacing_value
    else:
        footingReinforcementGroup.CrossSpacingValue = cross_amount_spacing_value
    if cross_rounding:
        footingReinforcementGroup.CrossRounding = cross_rounding
    if cross_l_shape_hook_orintation:
        footingReinforcementGroup.CrossLShapeHookOrintation = (
            cross_l_shape_hook_orintation)

    footingReinforcementGroup.ColumnFrontSpacing = column_front_spacing
    footingReinforcementGroup.ColumnLeftSpacing = column_left_spacing
    footingReinforcementGroup.ColumnRightSpacing = column_right_spacing
    footingReinforcementGroup.ColumnRearSpacing = column_rear_spacing
    footingReinforcementGroup.TieTopCover = tie_top_cover
    footingReinforcementGroup.TieBottomCover = tie_bottom_cover
    footingReinforcementGroup.TieBentAngle = tie_bent_angle
    footingReinforcementGroup.TieExtensionFactor = tie_extension_factor
    footingReinforcementGroup.TieDiameter = tie_diameter
    footingReinforcementGroup.TieNumberSpacingCheck = tie_number_spacing_check
    if tie_number_spacing_check:
        footingReinforcementGroup.TieAmountValue = tie_number_spacing_value
    else:
        footingReinforcementGroup.TieSpacingValue = tie_number_spacing_value
    footingReinforcementGroup.ColumnMainRebarsDiameter = (
        column_main_rebar_diameter)
    footingReinforcementGroup.ColumnMainRebarsTopOffset = (
        column_main_rebars_t_offset)
    footingReinforcementGroup.ColumnWidth = column_width
    footingReinforcementGroup.ColumnLength = column_length
    footingReinforcementGroup.XDirColumnNumberSpacingCheck = (
        xdir_column_amount_spacing_check)
    if xdir_column_amount_spacing_check:
        footingReinforcementGroup.XDirColumnAmountValue = (
            xdir_column_amount_spacing_value)
    else:
        footingReinforcementGroup.XDirColumnSpacingValue = (
            xdir_column_amount_spacing_value)
    footingReinforcementGroup.YDirColumnNumberSpacingCheck = (
        ydir_column_amount_spacing_check)
    if ydir_column_amount_spacing_check:
        footingReinforcementGroup.YDirColumnAmountValue = (
            ydir_column_amount_spacing_value)
    else:
        footingReinforcementGroup.YDirColumnSpacingValue = (
            ydir_column_amount_spacing_value)
    if column_main_rebars_type:
        footingReinforcementGroup.ColumnMainRebarType = column_main_rebars_type
    if column_main_hook_orientation:
        footingReinforcementGroup.ColumnMainHookOrientation = (
            column_main_hook_orientation)
    if column_main_hook_extend_along:
        footingReinforcementGroup.ColumnMainHookExtendAlong = (
            column_main_hook_extend_along)
    if column_l_main_rebar_rounding:
        footingReinforcementGroup.ColumnMainLRebarRounding = (
            column_l_main_rebar_rounding)
    if column_main_hook_extension:
        footingReinforcementGroup.ColumnMainHookExtension = (
            column_main_hook_extension)
    if column_sec_rebar_check:
        footingReinforcementGroup.ColumnSecRebarsCheck = column_sec_rebar_check
    if column_sec_rebars_t_offset:
        footingReinforcementGroup.ColumnSecRebarsTopOffset = (
            column_sec_rebars_t_offset)
    if column_sec_rebars_number_diameter:
        footingReinforcementGroup.ColumnSecRebarsNumberDiameter = (
            column_sec_rebars_number_diameter)
    if column_sec_rebars_type:
        footingReinforcementGroup.ColumnSecRebarsType = column_sec_rebars_type
    if column_sec_hook_orientation:
        footingReinforcementGroup.ColumnSecHookOrientation = (
            column_sec_hook_orientation)
    if column_l_sec_rebar_rounding:
        footingReinforcementGroup.ColumnSecLRebarRounding = (
            column_l_sec_rebar_rounding)
    footingReinforcementGroup.IsMakeOrEditRequired = True
    if column_sec_hook_extension:
        footingReinforcementGroup.ColumnSecHookExtension = (
            column_sec_hook_extension)
    FreeCAD.ActiveDocument.recompute()
    return footingReinforcementGroup
def makeSlabReinforcement(
    parallel_rebar_type: str,
    parallel_front_cover: float,
    parallel_rear_cover: float,
    parallel_left_cover: float,
    parallel_right_cover: float,
    parallel_top_cover: float,
    parallel_bottom_cover: float,
    parallel_diameter: float,
    parallel_amount_spacing_check: bool,
    parallel_amount_spacing_value: Union[float, int],
    cross_rebar_type: str,
    cross_front_cover: float,
    cross_rear_cover: float,
    cross_left_cover: float,
    cross_right_cover: float,
    cross_top_cover: float,
    cross_bottom_cover: float,
    cross_diameter: float,
    cross_amount_spacing_check: bool,
    cross_amount_spacing_value: Union[float, int],
    cross_rounding: Optional[int] = 2,
    cross_bent_bar_length: Optional[int] = 50,
    cross_bent_bar_angle: Optional[int] = 135,
    cross_l_shape_hook_orintation: Optional[str] = "Alternate",
    cross_distribution_rebars_check: Optional[bool] = False,
    cross_distribution_rebars_diameter: Optional[float] = 8,
    cross_distribution_rebars_amount_spacing_check: Optional[bool] = True,
    cross_distribution_rebars_amount_spacing_value: Optional[int] = 2,
    parallel_rounding: Optional[int] = 2,
    parallel_bent_bar_length: Optional[int] = 50,
    parallel_bent_bar_angle: Optional[int] = 135,
    parallel_l_shape_hook_orintation: Optional[str] = "Alternate",
    parallel_distribution_rebars_check: Optional[bool] = False,
    parallel_distribution_rebars_diameter: Optional[float] = 8,
    parallel_distribution_rebars_amount_spacing_check: Optional[bool] = True,
    parallel_distribution_rebars_amount_spacing_value: Optional[int] = 2,
    mesh_cover_along: str = "Bottom",
    structure: Optional[Tuple] = None,
    facename: Optional[str] = None,
):
    """Generate Slab Reinforcement

    Parameters
    ----------
    parallel_rebar_type: str
        Type of rebar for parallel rebars for slab reinforcement.
        It can have four values 'StraightRebar','LShapeRebar', 'UShapeRebar',
        'BentShapeRebar'.
    parallel_front_cover: float
        The distance between parallel rebar and selected face.
    parallel_rear_cover: float
        Rear cover for slab reinforcement of parallel rebars.
    parallel_left_cover: float
        The distance between the left end of the parallel rebar to the left face of
        the structure.
    parallel_right_cover: float
        The distance between the right end of the parallel rebar to right face of
        the structure.
    parallel_top_cover: float
        The distance between parallel rebars from the top face of the structure.
    parallel_bottom_cover: float
        The distance between parallel rebars from the bottom face of the structure.
    parallel_diameter: float
        Diameter of parallel rebars.
    parallel_amount_spacing_check: bool
        If is set to True, then value of parallel_amount_spacing_value is used as
        rebars count else parallel_amount_spacing_value's value is used as spacing
        in parallel rebars.
    parallel_amount_spacing_value: float or int
        It contains count of rebars or spacing between parallel rebars based on
        value of amount_spacing_check.
    cross_rebar_type: str
        Type of rebar for cross rebars for slab reinforcement.
        It can have four values 'StraightRebar','LShapeRebar', 'UShapeRebar',
        'BentShapeRebar'.
    cross_front_cover: float
        The distance between cross rebar and cross_face (face perpendicular to selected face).
    cross_rear_cover: float
        Rear cover for slab reinforcement of cross rebars.
    cross_left_cover: float
        The distance between the left end of the cross rebar to the left face of
        the structure.
    cross_right_cover: float
        The distance between the right end of the rebar to right face of
        the structure relative to cross_face.
    cross_top_cover: float
        The distance between cross rebar from the top face of the structure.
    cross_bottom_cover: float
        The distance between cross rebar from the bottom face of the structure.
    cross_diameter: float
        Diameter of cross rebars.
    cross_amount_spacing_check: bool
        If is set to True, then value of cross_amount_spacing_value is used as
        rebars count else cross_amount_spacing_value's value is used as spacing
        in rebars.
    cross_amount_spacing_value: float or int
        It contains count of rebars or spacing between rebars based on
        value of cross_amount_spacing_check.
    cross_rounding: int
        A rounding value to be applied to the corners of the bars, expressed
        in times the cross_diameter.
    cross_bent_bar_length: float
        It represents arm's length of bent shape cross rebar when cross_rebar_type is
        BentShapeRebar
    cross_bent_bar_angle: int
        It represents angle for bent shape cross rebar when cross_rebar_type is
        BentShapeRebar
    cross_l_shape_hook_orintation: str
        It represents orintation of hook of cross L-Shape rebar if cross_rebar_type
        is LShapeRebar.
        It can have tree values "Left", "Right", "Alternate"
    cross_distribution_rebars_check: bool
        If True add distribution rebars for cross bent shape rebars.
        Default is False.
    cross_distribution_rebars_diameter: float
        Diameter for distribution rebars for cross bent shape rebars.
    cross_distribution_rebars_amount_spacing_check: bool
        If is set to True, then value of cross_distribution_rebars_amount_spacing_value
        is used as rebars count else cross_distribution_rebars_amount_spacing_value's
        value is used as spacing in cross_distribution_rebars.
        Default is True.
    cross_distribution_rebars_amount_spacing_value: int or float
        It contains count or spacing between distribution rebars for one side of cross
        bent shape rebars based on value of cross_distribution_rebars_check.
        Default is 2.
    parallel_rounding: int
        A rounding value to be applied to the corners of the bars, expressed
        in times the parallel_diameter.
    parallel_bent_bar_length: float
        It represents arm's length of bent shape parallel rebar when parallel_rebar_type is
        BentShapeRebar
    parallel_bent_bar_angle: int
        It represents angle for bent shape parallel rebar when parallel_rebar_type is
        BentShapeRebar
    parallel_l_shape_hook_orintation: str
        It represents orintation of hook of parallel L-Shape rebar if parallel_rebar_type
        is LShapeRebar.
        It can have tree values "Left", "Right", "Alternate"
    parallel_distribution_rebars_check: bool
        If True add distribution rebars for parallel bent shape rebars.
        Default is False.
    parallel_distribution_rebars_diameter: float
        Diameter of distribution rebars for parallel bent shape rebars.
    parallel_distribution_rebars_amount_spacing_check: bool
        If is set to True, then value of parallel_distribution_rebars_amount_spacing_value
        is used as rebars count else parallel_distribution_rebars_amount_spacing_value's
        value is used as spacing in parallel_distribution_rebars.
        Default is True.
    parallel_distribution_rebars_amount_spacing_value: int or float
        It contains count or spacing between distribution rebars for one side of parallel
        bent shape rebars based on value of parallel_distribution_rebars_check.
        Default is 2.
    mesh_cover_along: str
        It can have two values "Top" and "Bottom". It represent alignment of
        rebar mesh along top or bottom face of structure.
    structure: Arch structure object
        Arch structure object.
        Default is None
    facename: str
        selected face of structure.
        Default is None
    """
    # create instance of SlabReinforcementGroup
    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

    slabReinforcementGroup = SlabReinforcementGroup().Object
    if FreeCAD.GuiUp:
        _SlabReinforcementViewProviderGroup(slabReinforcementGroup.ViewObject)

    slabReinforcementGroup.MeshCoverAlong = mesh_cover_along
    slabReinforcementGroup.Structure = structure
    slabReinforcementGroup.Facename = facename
    slabReinforcementGroup.ParallelRebarType = parallel_rebar_type
    slabReinforcementGroup.ParallelFrontCover = parallel_front_cover
    slabReinforcementGroup.ParallelRearCover = parallel_rear_cover
    slabReinforcementGroup.ParallelLeftCover = parallel_left_cover
    slabReinforcementGroup.ParallelRightCover = parallel_right_cover
    slabReinforcementGroup.ParallelTopCover = parallel_top_cover
    slabReinforcementGroup.ParallelBottomCover = parallel_bottom_cover
    slabReinforcementGroup.ParallelDiameter = parallel_diameter
    slabReinforcementGroup.ParallelAmountSpacingCheck = (
        parallel_amount_spacing_check)
    if parallel_amount_spacing_check:
        slabReinforcementGroup.ParallelAmountValue = (
            parallel_amount_spacing_value)
    else:
        slabReinforcementGroup.ParallelSpacingValue = (
            parallel_amount_spacing_value)

    if parallel_rounding:
        slabReinforcementGroup.ParallelRounding = parallel_rounding
    if parallel_bent_bar_length:
        slabReinforcementGroup.ParallelBentBarLength = parallel_bent_bar_length
    if parallel_bent_bar_angle:
        slabReinforcementGroup.ParallelBentBarAngle = parallel_bent_bar_angle
    if parallel_l_shape_hook_orintation:
        slabReinforcementGroup.ParallelLShapeHookOrintation = (
            parallel_l_shape_hook_orintation)

    if parallel_distribution_rebars_check:
        slabReinforcementGroup.ParallelDistributionRebarsCheck = (
            parallel_distribution_rebars_check)

    if parallel_distribution_rebars_diameter:
        slabReinforcementGroup.ParallelDistributionRebarsDiameter = (
            parallel_distribution_rebars_diameter)

    if parallel_distribution_rebars_amount_spacing_check:
        slabReinforcementGroup.ParallelDistributionRebarsAmountSpacingCheck = (
            parallel_distribution_rebars_amount_spacing_check)

    if parallel_distribution_rebars_amount_spacing_check:
        if parallel_distribution_rebars_amount_spacing_value:
            slabReinforcementGroup.ParallelDistributionRebarsAmount = (
                parallel_distribution_rebars_amount_spacing_value)
    else:
        if parallel_distribution_rebars_amount_spacing_value:
            slabReinforcementGroup.ParallelDistributionRebarsSpacing = (
                parallel_distribution_rebars_amount_spacing_value)

    slabReinforcementGroup.CrossRebarType = cross_rebar_type
    slabReinforcementGroup.CrossFrontCover = cross_front_cover
    slabReinforcementGroup.CrossLeftCover = cross_left_cover
    slabReinforcementGroup.CrossRightCover = cross_right_cover
    slabReinforcementGroup.CrossRearCover = cross_rear_cover
    slabReinforcementGroup.CrossTopCover = cross_top_cover
    slabReinforcementGroup.CrossBottomCover = cross_bottom_cover
    slabReinforcementGroup.CrossDiameter = cross_diameter
    slabReinforcementGroup.CrossAmountSpacingCheck = cross_amount_spacing_check
    if cross_amount_spacing_check:
        slabReinforcementGroup.CrossAmountValue = cross_amount_spacing_value
    else:
        slabReinforcementGroup.CrossSpacingValue = cross_amount_spacing_value

    if cross_rounding:
        slabReinforcementGroup.CrossRounding = cross_rounding
    if cross_bent_bar_length:
        slabReinforcementGroup.CrossBentBarLength = cross_bent_bar_length
    if cross_bent_bar_angle:
        slabReinforcementGroup.CrossBentBarAngle = cross_bent_bar_angle
    if cross_l_shape_hook_orintation:
        slabReinforcementGroup.CrossLShapeHookOrintation = (
            cross_l_shape_hook_orintation)
    if cross_distribution_rebars_check:
        slabReinforcementGroup.CrossDistributionRebarsCheck = (
            cross_distribution_rebars_check)
    if cross_distribution_rebars_diameter:
        slabReinforcementGroup.CrossDistributionRebarsDiameter = (
            cross_distribution_rebars_diameter)
    if cross_distribution_rebars_amount_spacing_check:
        slabReinforcementGroup.CrossDistributionRebarsAmountSpacingCheck = (
            cross_distribution_rebars_amount_spacing_check)
    slabReinforcementGroup.IsMakeOrEditRequired = True
    if cross_distribution_rebars_amount_spacing_check:
        if cross_distribution_rebars_amount_spacing_value:
            slabReinforcementGroup.CrossDistributionRebarsAmount = (
                cross_distribution_rebars_amount_spacing_value)
    else:
        if cross_distribution_rebars_amount_spacing_value:
            slabReinforcementGroup.CrossDistributionRebarsSpacing = (
                cross_distribution_rebars_amount_spacing_value)
    FreeCAD.ActiveDocument.recompute()

    return slabReinforcementGroup