def setupUi(self):
     """This function is used to set values in ui."""
     # Set values of number and diameter from rebars_widget
     self.NumberDiameter = self.rebars_widget.numberDiameter.text()
     number_diameter_list = gettupleOfNumberDiameter(self.NumberDiameter)
     number_diameter_list.extend(
         [(0, 0) for _ in range(3 - len(number_diameter_list))]
     )
     self.form.number1.setValue(number_diameter_list[0][0])
     self.form.diameter1.setText(str(number_diameter_list[0][1]) + " mm")
     self.form.number2.setValue(number_diameter_list[1][0])
     self.form.diameter2.setText(str(number_diameter_list[1][1]) + " mm")
     self.form.number3.setValue(number_diameter_list[2][0])
     self.form.diameter3.setText(str(number_diameter_list[2][1]) + " mm")
     self.form.numberDiameter.setText(self.NumberDiameter)
     self.connectSignalSlots()
 def setupUi(self):
     """This function is used to set values in ui."""
     try:
         # Try to set values of number and diameter from rebars_widget
         self.NumberDiameter = self.rebars_widget.numberDiameter.text()
         number_diameter_list = gettupleOfNumberDiameter(self.NumberDiameter)
         self.form.number1.setValue(number_diameter_list[0][0])
         self.form.diameter1.setText(str(number_diameter_list[0][1]) + " mm")
         self.form.number2.setValue(number_diameter_list[1][0])
         self.form.diameter2.setText(str(number_diameter_list[1][1]) + " mm")
         self.form.number3.setValue(number_diameter_list[2][0])
         self.form.diameter3.setText(str(number_diameter_list[2][1]) + " mm")
         self.form.numberDiameter.setText(self.NumberDiameter)
     except:
         pass
     self.connectSignalSlots()
Example #3
0
def editXDirRebars(
    xdir_rebars_list,
    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,
):
    # Find parameters of selected face
    FacePRM = getParametersOfFace(structure, facename)

    facename_for_xdir_rebars = getFacenameforRebar(
        "y-axis", facename, structure
    )

    # find list of tuples of number and diameter of xdir rebars
    xdir_rebars_number_diameter_list = gettupleOfNumberDiameter(
        xdir_rebars_number_diameter
    )
    xdir_rebars_number_diameter_list.reverse()

    # Calculate spacing between xdir-rebars
    xdir_span_length = (
        FacePRM[0][0]
        - l_cover_of_tie
        - r_cover_of_tie
        - 2 * dia_of_tie
        - 2 * dia_of_main_rebars
    )
    req_space_for_xdir_rebars = sum(
        x[0] * x[1] for x in xdir_rebars_number_diameter_list
    )
    xdir_rebars_number = sum(
        number for number, _ in xdir_rebars_number_diameter_list
    )
    spacing_in_xdir_rebars = (xdir_span_length - req_space_for_xdir_rebars) / (
        xdir_rebars_number + 1
    )

    # Set parameter values for Straight/LShape xdir_rebars
    list_coverAlong = ["Right Side", "Left Side"]

    if xdir_rebars_type == "StraightRebar":
        r_cover = t_cover_of_tie + dia_of_tie
        l_cover = b_cover_of_tie + dia_of_tie
        rl_cover = [r_cover, l_cover]

        index = 0
        for i, coverAlong in enumerate(list_coverAlong):
            for j, (number, dia) in enumerate(xdir_rebars_number_diameter_list):
                if j == 0:
                    f_cover_of_xdir_rebars = (
                        r_cover_of_tie
                        + dia_of_tie
                        + dia_of_main_rebars
                        + spacing_in_xdir_rebars
                    )
                rear_cover_of_xdir_rebars = (
                    FacePRM[0][0]
                    - f_cover_of_xdir_rebars
                    - number * dia
                    - (number - 1) * spacing_in_xdir_rebars
                )

                editStraightRebar(
                    xdir_rebars_list[index],
                    f_cover_of_xdir_rebars,
                    (coverAlong, rl_cover[i]),
                    xdir_rebars_t_offset,
                    xdir_rebars_b_offset,
                    dia,
                    True,
                    number,
                    "Vertical",
                    structure,
                    facename_for_xdir_rebars,
                )

                xdir_rebars_list[index].OffsetEnd = (
                    rear_cover_of_xdir_rebars + dia / 2
                )
                f_cover_of_xdir_rebars += (
                    number * dia + number * spacing_in_xdir_rebars
                )
                index += 1
    elif xdir_rebars_type == "LShapeRebar":
        face_length = getParametersOfFace(structure, facename_for_xdir_rebars)[
            0
        ][0]
        l_rebar_orientation_cover_list = []
        for i, (number, dia_of_rebars) in enumerate(
            xdir_rebars_number_diameter_list
        ):
            l_rebar_orientation_cover_list.append(
                getLRebarOrientationLeftRightCover(
                    xdir_hook_orientation,
                    xdir_hook_extension,
                    "y-axis",
                    l_cover_of_tie,
                    r_cover_of_tie,
                    t_cover_of_tie,
                    b_cover_of_tie,
                    dia_of_tie,
                    dia_of_rebars,
                    l_xdir_rebar_rounding,
                    face_length,
                )
            )
        list_orientation = l_rebar_orientation_cover_list[0]["list_orientation"]
        l_cover_list = []
        for l_rebar_orientation_cover in l_rebar_orientation_cover_list:
            l_cover_list.append(l_rebar_orientation_cover["l_cover"])

        r_cover_list = []
        for l_rebar_orientation_cover in l_rebar_orientation_cover_list:
            r_cover_list.append(l_rebar_orientation_cover["r_cover"])

        index = 0
        for i, orientation in enumerate(list_orientation):
            for j, (number, dia) in enumerate(xdir_rebars_number_diameter_list):
                if j == 0:
                    f_cover_of_xdir_rebars = (
                        r_cover_of_tie
                        + dia_of_tie
                        + dia_of_main_rebars
                        + spacing_in_xdir_rebars
                    )
                rear_cover_of_xdir_rebars = (
                    FacePRM[0][0]
                    - f_cover_of_xdir_rebars
                    - number * dia
                    - (number - 1) * spacing_in_xdir_rebars
                )
                editLShapeRebar(
                    xdir_rebars_list[index],
                    f_cover_of_xdir_rebars,
                    xdir_rebars_b_offset,
                    l_cover_list[j][i],
                    r_cover_list[j][i],
                    dia,
                    xdir_rebars_t_offset,
                    l_xdir_rebar_rounding,
                    True,
                    number,
                    orientation,
                    structure,
                    facename_for_xdir_rebars,
                )
                xdir_rebars_list[index].OffsetEnd = (
                    rear_cover_of_xdir_rebars + dia / 2
                )
                f_cover_of_xdir_rebars += (
                    number * dia + number * spacing_in_xdir_rebars
                )
                index += 1
    FreeCAD.ActiveDocument.recompute()
Example #4
0
def 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,
):
    """Adds the rebars along y-direction to the structural column object."""
    ydir_rebars = []
    facename_for_ydir_rebars = getFacenameforRebar(
        "x-axis", facename, structure
    )

    # Find parameters of selected face
    FacePRM = getParametersOfFace(structure, facename)

    # find list of tuples of number and diameter of ydir rebars
    ydir_rebars_number_diameter_list = gettupleOfNumberDiameter(
        ydir_rebars_number_diameter
    )

    # Calculate spacing between ydir-rebars
    ydir_span_length = (
        FacePRM[0][1]
        - t_cover_of_tie
        - b_cover_of_tie
        - 2 * dia_of_tie
        - 2 * dia_of_main_rebars
    )
    req_space_for_ydir_rebars = sum(
        x[0] * x[1] for x in ydir_rebars_number_diameter_list
    )
    ydir_rebars_number = sum(
        number for number, _ in ydir_rebars_number_diameter_list
    )
    spacing_in_ydir_rebars = (ydir_span_length - req_space_for_ydir_rebars) / (
        ydir_rebars_number + 1
    )

    # Set parameter values for Straight/LShape ydir_rebars
    list_coverAlong = ["Right Side", "Left Side"]

    if ydir_rebars_type == "StraightRebar":
        # Set parameter values for Straight ydir_rebars
        r_cover = r_cover_of_tie + dia_of_tie
        l_cover = l_cover_of_tie + dia_of_tie
        rl_cover = [r_cover, l_cover]

        # Create Straight rebars along y-direction
        for i, coverAlong in enumerate(list_coverAlong):
            for j, (number, dia) in enumerate(ydir_rebars_number_diameter_list):
                if j == 0:
                    f_cover_of_ydir_rebars = (
                        b_cover_of_tie
                        + dia_of_tie
                        + dia_of_main_rebars
                        + spacing_in_ydir_rebars
                    )
                rear_cover_of_ydir_rebars = (
                    FacePRM[0][1]
                    - f_cover_of_ydir_rebars
                    - number * dia
                    - (number - 1) * spacing_in_ydir_rebars
                )

                ydir_rebars.append(
                    makeStraightRebar(
                        f_cover_of_ydir_rebars,
                        (coverAlong, rl_cover[i]),
                        ydir_rebars_t_offset,
                        ydir_rebars_b_offset,
                        dia,
                        True,
                        number,
                        "Vertical",
                        structure,
                        facename_for_ydir_rebars,
                    )
                )
                ydir_rebars[-1].OffsetEnd = rear_cover_of_ydir_rebars + dia / 2
                f_cover_of_ydir_rebars += (
                    number * dia + number * spacing_in_ydir_rebars
                )
    elif ydir_rebars_type == "LShapeRebar":
        face_length = getParametersOfFace(structure, facename_for_ydir_rebars)[
            0
        ][0]
        l_rebar_orientation_cover_list = []
        for i, (number, dia_of_rebars) in enumerate(
            ydir_rebars_number_diameter_list
        ):
            l_rebar_orientation_cover_list.append(
                getLRebarOrientationLeftRightCover(
                    ydir_hook_orientation,
                    ydir_hook_extension,
                    "x-axis",
                    l_cover_of_tie,
                    r_cover_of_tie,
                    t_cover_of_tie,
                    b_cover_of_tie,
                    dia_of_tie,
                    dia_of_rebars,
                    l_ydir_rebar_rounding,
                    face_length,
                )
            )
        list_orientation = l_rebar_orientation_cover_list[0]["list_orientation"]
        l_cover_list = []
        for l_rebar_orientation_cover in l_rebar_orientation_cover_list:
            l_cover_list.append(l_rebar_orientation_cover["l_cover"])

        r_cover_list = []
        for l_rebar_orientation_cover in l_rebar_orientation_cover_list:
            r_cover_list.append(l_rebar_orientation_cover["r_cover"])

        # Create LShape rebars along y-direction
        for i, orientation in enumerate(list_orientation):
            for j, (number, dia) in enumerate(ydir_rebars_number_diameter_list):
                if j == 0:
                    f_cover_of_ydir_rebars = (
                        r_cover_of_tie
                        + dia_of_tie
                        + dia_of_main_rebars
                        + spacing_in_ydir_rebars
                    )
                rear_cover_of_ydir_rebars = (
                    FacePRM[0][1]
                    - f_cover_of_ydir_rebars
                    - number * dia
                    - (number - 1) * spacing_in_ydir_rebars
                )
                ydir_rebars.append(
                    makeLShapeRebar(
                        f_cover_of_ydir_rebars,
                        ydir_rebars_b_offset,
                        l_cover_list[j][i],
                        r_cover_list[j][i],
                        dia,
                        ydir_rebars_t_offset,
                        l_ydir_rebar_rounding,
                        True,
                        number,
                        orientation,
                        structure,
                        facename_for_ydir_rebars,
                    )
                )
                ydir_rebars[-1].OffsetEnd = rear_cover_of_ydir_rebars + dia / 2
                f_cover_of_ydir_rebars += (
                    number * dia + number * spacing_in_ydir_rebars
                )
    FreeCAD.ActiveDocument.recompute()
    return ydir_rebars