コード例 #1
0
def makeStraightRebars(
    s_cover,
    t_offset,
    b_offset,
    dia_of_main_rebars,
    number_angle_check,
    number_angle_value,
    structure,
    facename,
    base_line_list=None,
):
    """makeStraightRebars(SideCover, TopOffset, BottomOffset, Diameter,
    NumberAngleCheck, NumberAngleValue, Structure, Facename, BaseLineObjList):
    Adds the straight rebars in circular column structural object.
    """
    face = structure.Shape.Faces[(getFaceNumber(facename) - 1)]
    FacePRM = getParametersOfFace(structure, facename, False)
    column_size = ArchCommands.projectToVector(structure.Shape.copy(),
                                               face.normalAt(0, 0)).Length
    radius = FacePRM[0][0] / 2 - s_cover
    points_list = getPointsOfStraightRebars(
        FacePRM,
        s_cover,
        t_offset,
        b_offset,
        column_size,
        dia_of_main_rebars,
        number_angle_check,
        number_angle_value,
    )
    import Arch, Draft

    pl = FreeCAD.Placement()
    pl.Rotation.Q = (0.5, 0.5, 0.5, 0.5)
    main_rebars_list = []
    for i, points in enumerate(points_list):
        if not base_line_list or i >= len(base_line_list):
            line = Draft.makeWire(
                points,
                placement=pl,
                closed=False,
                face=True,
                support=[(structure, facename)],
            )
        else:
            line = base_line_list[i]
            line.Start = points[0]
            line.End = points[1]
        main_rebars_list.append(
            Arch.makeRebar(structure, line, dia_of_main_rebars, amount=1))
        main_rebars_list[-1].Label = "StraightRebar"
        main_rebars_list[-1].OffsetStart = 0
        main_rebars_list[-1].OffsetEnd = 0

    return main_rebars_list
コード例 #2
0
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
コード例 #3
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
コード例 #4
0
def makeStirrup(
    l_cover,
    r_cover,
    t_cover,
    b_cover,
    f_cover,
    bentAngle,
    bentFactor,
    diameter,
    rounding,
    amount_spacing_check,
    amount_spacing_value,
    structure=None,
    facename=None,
):
    """makeStirrup(LeftCover, RightCover, TopCover, BottomCover, FrontCover,
    BentAngle, BentFactor, Diameter, Rounding, AmountSpacingCheck,
    AmountSpacingValue, Structure, Facename):
    Adds the Stirrup reinforcement bar to the selected structural object."""
    if not structure and not facename:
        selected_obj = FreeCADGui.Selection.getSelectionEx()[0]
        structure = selected_obj.Object
        facename = selected_obj.SubElementNames[0]
    face = structure.Shape.Faces[getFaceNumber(facename) - 1]
    # StructurePRM = getTrueParametersOfStructure(structure)
    FacePRM = getParametersOfFace(structure, facename, False)
    FaceNormal = face.normalAt(0, 0)
    # FaceNormal = face.Placement.Rotation.inverted().multVec(FaceNormal)
    if not FacePRM:
        FreeCAD.Console.PrintError(
            "Cannot identified shape or from which base object sturctural "
            "element is derived\n")
        return
    # Calculate the coordinate values of Stirrup
    points = getpointsOfStirrup(
        FacePRM,
        l_cover,
        r_cover,
        t_cover,
        b_cover,
        bentAngle,
        bentFactor,
        diameter,
        rounding,
        FaceNormal,
    )
    import Draft

    line = Draft.makeWire(points, closed=False, face=True, support=None)
    import Arch

    line.Support = [(structure, facename)]
    if amount_spacing_check:
        rebar = Arch.makeRebar(
            structure,
            line,
            diameter,
            amount_spacing_value,
            f_cover + diameter / 2,
            name="Stirrup",
        )
    else:
        size = (ArchCommands.projectToVector(structure.Shape.copy(),
                                             face.normalAt(0, 0))).Length
        rebar = Arch.makeRebar(
            structure,
            line,
            diameter,
            int((size - diameter) / amount_spacing_value),
            f_cover + diameter / 2,
            name="Stirrup",
        )
    rebar.Direction = FaceNormal.negative()
    rebar.Rounding = rounding
    # Adds properties to the rebar object
    rebar.addProperty(
        "App::PropertyEnumeration",
        "RebarShape",
        "RebarDialog",
        QT_TRANSLATE_NOOP("App::Property", "Shape of rebar"),
    ).RebarShape = RebarTypes.tolist()
    rebar.RebarShape = "Stirrup"
    rebar.setEditorMode("RebarShape", 2)
    rebar.addProperty(
        "App::PropertyDistance",
        "LeftCover",
        "RebarDialog",
        QT_TRANSLATE_NOOP("App::Property", "Left Side cover of rebar"),
    ).LeftCover = l_cover
    rebar.setEditorMode("LeftCover", 2)
    rebar.addProperty(
        "App::PropertyDistance",
        "RightCover",
        "RebarDialog",
        QT_TRANSLATE_NOOP("App::Property", "Right Side cover of rebar"),
    ).RightCover = r_cover
    rebar.setEditorMode("RightCover", 2)
    rebar.addProperty(
        "App::PropertyDistance",
        "TopCover",
        "RebarDialog",
        QT_TRANSLATE_NOOP("App::Property", "Top Side cover of rebar"),
    ).TopCover = t_cover
    rebar.setEditorMode("TopCover", 2)
    rebar.addProperty(
        "App::PropertyDistance",
        "BottomCover",
        "RebarDialog",
        QT_TRANSLATE_NOOP("App::Property", "Bottom Side cover of rebar"),
    ).BottomCover = b_cover
    rebar.setEditorMode("BottomCover", 2)
    rebar.addProperty(
        "App::PropertyDistance",
        "FrontCover",
        "RebarDialog",
        QT_TRANSLATE_NOOP("App::Property", "Top cover of rebar"),
    ).FrontCover = f_cover
    rebar.setEditorMode("FrontCover", 2)
    rebar.addProperty(
        "App::PropertyInteger",
        "BentAngle",
        "RebarDialog",
        QT_TRANSLATE_NOOP("App::Property",
                          "Bent angle between at the end of rebar"),
    ).BentAngle = bentAngle
    rebar.setEditorMode("BentAngle", 2)
    rebar.addProperty(
        "App::PropertyInteger",
        "BentFactor",
        "RebarDialog",
        QT_TRANSLATE_NOOP("App::Property",
                          "Bent Length is the equal to BentFactor * Diameter"),
    ).BentFactor = bentFactor
    rebar.setEditorMode("BentFactor", 2)
    rebar.addProperty(
        "App::PropertyBool",
        "AmountCheck",
        "RebarDialog",
        QT_TRANSLATE_NOOP("App::Property", "Amount radio button is checked"),
    )
    rebar.setEditorMode("AmountCheck", 2)
    rebar.addProperty(
        "App::PropertyDistance",
        "TrueSpacing",
        "RebarDialog",
        QT_TRANSLATE_NOOP("App::Property", "Spacing between of rebars"),
    ).TrueSpacing = amount_spacing_value
    rebar.setEditorMode("TrueSpacing", 2)
    if amount_spacing_check:
        rebar.AmountCheck = True
    else:
        rebar.AmountCheck = False
        rebar.TrueSpacing = amount_spacing_value
    FreeCAD.ActiveDocument.recompute()
    return rebar
コード例 #5
0
def makeReinforcement(
    s_cover,
    helical_rebar_t_offset,
    helical_rebar_b_offset,
    pitch,
    dia_of_helical_rebar,
    main_rebars_t_offset,
    main_rebars_b_offset,
    dia_of_main_rebars,
    number_angle_check,
    number_angle_value,
    structure=None,
    facename=None,
):
    """makeReinforcement(SideCover, TopOffsetOfHelicalRebars,
    BottomOffsetOfHelicalRebars, Pitch, DiameterOfHelicalRebar,
    TopOffsetOfMainRebars, BottomOffsetOfMainRebars, DiameterOfMainRebars,
    NumberAngleCheck, NumberAngleValue, Structure, Facename):
    Adds the helical and straight rebars to the selected structural column
    object.
    """
    if not structure and not facename:
        if FreeCAD.GuiUp:
            selected_obj = FreeCADGui.Selection.getSelectionEx()[0]
            structure = selected_obj.Object
            facename = selected_obj.SubElementNames[0]
        else:
            FreeCAD.Console.PrintError(
                "Error: Pass structure and facename arguments")
            return
    FacePRM = getParametersOfFace(structure, facename, sketch=False)
    if not FacePRM:
        FreeCAD.Console.PrintError(
            "Cannot identified shape or from which base object"
            "sturctural element is derived\n")
        return
    helical_rebar = makeHelicalRebar(
        s_cover,
        helical_rebar_b_offset,
        dia_of_helical_rebar,
        helical_rebar_t_offset,
        pitch,
        structure,
        facename,
    )

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

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

    properties_values = []
    properties_values.append(("TopOffset", main_rebars_t_offset))
    properties_values.append(("BottomOffset", main_rebars_b_offset))
    properties_values.append(("Diameter", dia_of_main_rebars))
    properties_values.append(("NumberAngleCheck", number_angle_check))
    if number_angle_check:
        properties_values.append(("Number", number_angle_value))
        properties_values.append(("Angle", 360.00 / number_angle_value))
    else:
        properties_values.append(
            ("Number", math.ceil(360 / number_angle_value)))
        properties_values.append(("Angle", number_angle_value))
    setGroupPropertiesValues(
        properties_values,
        CircularColumnReinforcementRebarGroup.main_rebars_group,
    )
    FreeCAD.ActiveDocument.recompute()
    return CircularColumnReinforcementRebarGroup
コード例 #6
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
コード例 #7
0
def makeUShapeRebar(
    f_cover,
    b_cover,
    r_cover,
    l_cover,
    diameter,
    t_cover,
    rounding,
    amount_spacing_check,
    amount_spacing_value,
    orientation="Bottom",
    structure=None,
    facename=None,
):
    """makeUShapeRebar(FrontCover, BottomCover, RightCover, LeftCover, Diameter,
    Topcover, Rounding, AmountSpacingCheck, AmountSpacingValue, Orientation,
    Structure, Facename):
    Adds the U-Shape reinforcement bar to the selected structural object.

    It takes four different types of orientations as input i.e 'Bottom', 'Top',
    'Right', 'Left'.
    """
    if not structure and not facename:
        selected_obj = FreeCADGui.Selection.getSelectionEx()[0]
        structure = selected_obj.Object
        facename = selected_obj.SubElementNames[0]
    face = structure.Shape.Faces[getFaceNumber(facename) - 1]
    # StructurePRM = getTrueParametersOfStructure(structure)
    FacePRM = getParametersOfFace(structure, facename)
    if not FacePRM:
        FreeCAD.Console.PrintError(
            "Cannot identified shape or from which base object sturctural "
            "element is derived\n")
        return
    # Get points of U-Shape rebar
    points = getpointsOfUShapeRebar(FacePRM, r_cover, l_cover, b_cover,
                                    t_cover, orientation, diameter)
    import Part
    import Arch

    sketch = FreeCAD.activeDocument().addObject("Sketcher::SketchObject",
                                                "Sketch")
    sketch.MapMode = "FlatFace"
    sketch.Support = [(structure, facename)]
    FreeCAD.ActiveDocument.recompute()
    sketch.addGeometry(Part.LineSegment(points[0], points[1]), False)
    sketch.addGeometry(Part.LineSegment(points[1], points[2]), False)

    sketch.addGeometry(Part.LineSegment(points[2], points[3]), False)
    if amount_spacing_check:
        rebar = Arch.makeRebar(
            structure,
            sketch,
            diameter,
            amount_spacing_value,
            f_cover + diameter / 2,
            name="UShapeRebar",
        )
        FreeCAD.ActiveDocument.recompute()
    else:
        size = (ArchCommands.projectToVector(structure.Shape.copy(),
                                             face.normalAt(0, 0))).Length
        rebar = Arch.makeRebar(
            structure,
            sketch,
            diameter,
            int((size - diameter) / amount_spacing_value),
            f_cover + diameter / 2,
            name="UShapeRebar",
        )
    rebar.Rounding = rounding
    # Adds properties to the rebar object
    rebar.addProperty(
        "App::PropertyEnumeration",
        "RebarShape",
        "RebarDialog",
        QT_TRANSLATE_NOOP("App::Property", "Shape of rebar"),
    ).RebarShape = RebarTypes.tolist()
    rebar.RebarShape = "UShapeRebar"
    rebar.setEditorMode("RebarShape", 2)
    rebar.addProperty(
        "App::PropertyDistance",
        "FrontCover",
        "RebarDialog",
        QT_TRANSLATE_NOOP("App::Property", "Front cover of rebar"),
    ).FrontCover = f_cover
    rebar.setEditorMode("FrontCover", 2)
    rebar.addProperty(
        "App::PropertyDistance",
        "RightCover",
        "RebarDialog",
        QT_TRANSLATE_NOOP("App::Property", "Right Side cover of rebar"),
    ).RightCover = r_cover
    rebar.setEditorMode("RightCover", 2)
    rebar.addProperty(
        "App::PropertyDistance",
        "LeftCover",
        "RebarDialog",
        QT_TRANSLATE_NOOP("App::Property", "Left Side cover of rebar"),
    ).LeftCover = l_cover
    rebar.setEditorMode("LeftCover", 2)
    rebar.addProperty(
        "App::PropertyDistance",
        "BottomCover",
        "RebarDialog",
        QT_TRANSLATE_NOOP("App::Property", "Bottom cover of rebar"),
    ).BottomCover = b_cover
    rebar.setEditorMode("BottomCover", 2)
    rebar.addProperty(
        "App::PropertyBool",
        "AmountCheck",
        "RebarDialog",
        QT_TRANSLATE_NOOP("App::Property", "Amount radio button is checked"),
    )
    rebar.setEditorMode("AmountCheck", 2)
    rebar.addProperty(
        "App::PropertyDistance",
        "TopCover",
        "RebarDialog",
        QT_TRANSLATE_NOOP("App::Property", "Top cover of rebar"),
    ).TopCover = t_cover
    rebar.setEditorMode("TopCover", 2)
    rebar.addProperty(
        "App::PropertyDistance",
        "TrueSpacing",
        "RebarDialog",
        QT_TRANSLATE_NOOP("App::Property", "Spacing between of rebars"),
    ).TrueSpacing = amount_spacing_value
    rebar.setEditorMode("TrueSpacing", 2)
    rebar.addProperty(
        "App::PropertyString",
        "Orientation",
        "RebarDialog",
        QT_TRANSLATE_NOOP("App::Property", "Shape of rebar"),
    ).Orientation = orientation
    rebar.setEditorMode("Orientation", 2)
    if amount_spacing_check:
        rebar.AmountCheck = True
    else:
        rebar.AmountCheck = False
        rebar.TrueSpacing = amount_spacing_value
    FreeCAD.ActiveDocument.recompute()
    return rebar
コード例 #8
0
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
コード例 #9
0
def 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_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,
):
    """editSingleTieFourRebars(RebarGroup, LeftCoverOfTie, RightCoverOfTie,
    TopCoverOfTie, BottomCoverOfTie, OffsetofTie, BentAngle, ExtensionFactor,
    DiameterOfTie, NumberSpacingCheck, NumberSpacingValue, DiameterOfRebars,
    TopOffsetofRebars, BottomOffsetofRebars, RebarType, LShapeHookOrientation,
    HookExtendAlong, LShapeRebarRounding, LShapeHookLength, Structure,
    Facename):
    Edit the Single Tie reinforcement for 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'.
    """
    Tie = rebar_group.RebarGroups[0].Ties[0]
    prev_rebar_type = (
        rebar_group.RebarGroups[1].MainRebars[0].ViewObject.RebarShape
    )
    if not structure and not facename:
        structure = Tie.Base.Support[0][0]
        facename = Tie.Base.Support[0][1][0]

    # Check if main rebar_type changed or not
    if prev_rebar_type == rebar_type:
        change_rebar_type = False
    else:
        change_rebar_type = True

    # Edit Tie
    rounding = (float(dia_of_tie) / 2 + dia_of_rebars / 2) / dia_of_tie
    f_cover = offset_of_tie
    ties = editStirrup(
        Tie,
        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,
    )

    # 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/Edit 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]

        if change_rebar_type:
            # Delete previously created LShaped rebars
            for Rebar in rebar_group.RebarGroups[1].MainRebars[:2]:
                base_name = Rebar.Base.Name
                FreeCAD.ActiveDocument.removeObject(Rebar.Name)
                FreeCAD.ActiveDocument.removeObject(base_name)
            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
                )
            rebar_group.RebarGroups[1].addObjects(main_rebars)
        else:
            main_rebars = []
            for Rebar in rebar_group.RebarGroups[1].MainRebars[:2]:
                main_rebars.append(Rebar)
            for i, coverAlong in enumerate(list_coverAlong):
                editStraightRebar(
                    main_rebars[i],
                    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

        if change_rebar_type:
            # Delete previously created Straight rebars
            for Rebar in rebar_group.RebarGroups[1].MainRebars[:2]:
                base_name = Rebar.Base.Name
                FreeCAD.ActiveDocument.removeObject(Rebar.Name)
                FreeCAD.ActiveDocument.removeObject(base_name)
            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
                    )
            rebar_group.RebarGroups[1].addObjects(main_rebars)
        else:
            main_rebars = []
            for Rebar in rebar_group.RebarGroups[1].MainRebars[:2]:
                main_rebars.append(Rebar)
            for i, orientation in enumerate(list_orientation):
                editLShapeRebar(
                    main_rebars[i],
                    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
                    )

    # Set properties values for ties in ties_group object
    ties_group = rebar_group.RebarGroups[0]
    ties_group.LeftCover = l_cover_of_tie
    ties_group.RightCover = r_cover_of_tie
    ties_group.TopCover = t_cover_of_tie
    ties_group.BottomCover = b_cover_of_tie

    # Set properties values for main_rebars in main_rebars_group object
    main_rebars_group = rebar_group.RebarGroups[1]
    main_rebars_group.MainRebars = main_rebars
    main_rebars_group.RebarType = rebar_type
    main_rebars_group.TopOffset = t_offset_of_rebars
    main_rebars_group.BottomOffset = b_offset_of_rebars
    main_rebars_group.HookOrientation = hook_orientation
    main_rebars_group.HookExtendAlong = hook_extend_along
    if not hook_extension:
        hook_extension = "0.00 mm"
    main_rebars_group.HookExtension = hook_extension

    FreeCAD.ActiveDocument.recompute()
    return rebar_group
コード例 #10
0
def makeStraightRebar(
    f_cover,
    coverAlong,
    rt_cover,
    lb_cover,
    diameter,
    amount_spacing_check,
    amount_spacing_value,
    orientation="Horizontal",
    structure=None,
    facename=None,
):
    """Adds the straight reinforcement bar to the selected structural object.

    Case I: When orientation of straight rebar is 'Horizontal':
        makeStraightRebar(FrontCover, CoverAlong, RightCover, LeftCover,
        Diameter, AmountSpacingCheck, AmountSpacingValue, Orientation =
        "Horizontal", Structure, Facename)
        Note: Type of CoverAlong argument is a tuple. Syntax: (<Along>,
        <Value>). Here we have horizontal orientation so we can pass Top Side
        and Bottom Side to <Along> arguments.
        For eg. ("Top Side", 20) and ("Bottom Side", 20)

    Case II: When orientation of straight rebar is 'Vertical':
        makeStraightRebar(FrontCover, CoverAlong, TopCover, BottomCover,
        Diameter, AmountSpacingCheck, AmountSpacingValue, Orientation =
        "Horizontal", Structure, Facename)
        Note: Type of CoverAlong argument is a tuple. Syntax: (<Along>,
        <Value>). Here we have vertical orientation so we can pass Left Side
        and Right Side to <Along> arguments.
        For eg. ("Left Side", 20) and ("Right Side", 20)
    """
    if not structure and not facename:
        selected_obj = FreeCADGui.Selection.getSelectionEx()[0]
        structure = selected_obj.Object
        facename = selected_obj.SubElementNames[0]
    face = structure.Shape.Faces[getFaceNumber(facename) - 1]
    # StructurePRM = getTrueParametersOfStructure(structure)
    FacePRM = getParametersOfFace(structure, facename)
    if not FacePRM:
        FreeCAD.Console.PrintError(
            "Cannot identify shape or from which base object structural "
            "element is derived\n")
        return
    # Get points of Straight rebar
    points = getpointsOfStraightRebar(
        FacePRM,
        rt_cover,
        lb_cover,
        coverAlong,
        orientation,
        diameter,
        facenormalDirection(structure, facename),
    )
    import Part
    import Arch

    sketch = FreeCAD.activeDocument().addObject("Sketcher::SketchObject",
                                                "Sketch")
    sketch.MapMode = "FlatFace"
    sketch.Support = [(structure, facename)]
    FreeCAD.ActiveDocument.recompute()
    sketch.addGeometry(Part.LineSegment(points[0], points[1]), False)
    if amount_spacing_check:
        rebar = Arch.makeRebar(
            structure,
            sketch,
            diameter,
            amount_spacing_value,
            f_cover + diameter / 2,
            name="StraightRebar",
        )
        FreeCAD.ActiveDocument.recompute()
    else:
        size = (ArchCommands.projectToVector(structure.Shape.copy(),
                                             face.normalAt(0, 0))).Length
        rebar = Arch.makeRebar(
            structure,
            sketch,
            diameter,
            get_rebar_amount_from_spacing(size, diameter,
                                          amount_spacing_value),
            f_cover + diameter / 2,
            name="StraightRebar",
        )
    # Adds properties to the rebar object
    rebar.addProperty(
        "App::PropertyEnumeration",
        "RebarShape",
        "RebarDialog",
        QT_TRANSLATE_NOOP("App::Property", "Shape of rebar"),
    ).RebarShape = RebarTypes.tolist()
    rebar.RebarShape = "StraightRebar"
    rebar.setEditorMode("RebarShape", 2)
    rebar.addProperty(
        "App::PropertyDistance",
        "FrontCover",
        "RebarDialog",
        QT_TRANSLATE_NOOP("App::Property", "Front cover of rebar"),
    ).FrontCover = f_cover
    rebar.setEditorMode("FrontCover", 2)
    rebar.addProperty(
        "App::PropertyDistance",
        "RightTopCover",
        "RebarDialog",
        QT_TRANSLATE_NOOP("App::Property", "Right/Top Side cover of rebar"),
    ).RightTopCover = rt_cover
    rebar.setEditorMode("RightTopCover", 2)
    rebar.addProperty(
        "App::PropertyDistance",
        "LeftBottomCover",
        "RebarDialog",
        QT_TRANSLATE_NOOP("App::Property", "Left/Bottom Side cover of rebar"),
    ).LeftBottomCover = lb_cover
    rebar.setEditorMode("LeftBottomCover", 2)
    rebar.addProperty(
        "App::PropertyString",
        "CoverAlong",
        "RebarDialog",
        QT_TRANSLATE_NOOP("App::Property", "Cover along"),
    ).CoverAlong = coverAlong[0]
    rebar.setEditorMode("CoverAlong", 2)
    rebar.addProperty(
        "App::PropertyDistance",
        "Cover",
        "RebarDialog",
        QT_TRANSLATE_NOOP("App::Property",
                          "Cover of rebar along user selected side"),
    ).Cover = coverAlong[1]
    rebar.setEditorMode("Cover", 2)
    rebar.addProperty(
        "App::PropertyBool",
        "AmountCheck",
        "RebarDialog",
        QT_TRANSLATE_NOOP("App::Property", "Amount radio button is checked"),
    )
    rebar.setEditorMode("AmountCheck", 2)
    rebar.addProperty(
        "App::PropertyDistance",
        "TrueSpacing",
        "RebarDialog",
        QT_TRANSLATE_NOOP("App::Property", "Spacing between of rebars"),
    ).TrueSpacing = amount_spacing_value
    rebar.setEditorMode("TrueSpacing", 2)
    rebar.addProperty(
        "App::PropertyString",
        "Orientation",
        "RebarDialog",
        QT_TRANSLATE_NOOP("App::Property", "Shape of rebar"),
    ).Orientation = orientation
    rebar.setEditorMode("Orientation", 2)
    if amount_spacing_check:
        rebar.AmountCheck = True
    else:
        rebar.AmountCheck = False
        rebar.TrueSpacing = amount_spacing_value
    FreeCAD.ActiveDocument.recompute()
    return rebar
コード例 #11
0
def makeHelicalRebar(
    s_cover, b_cover, diameter, t_cover, pitch, structure=None, facename=None
):
    """makeHelicalRebar(SideCover, BottomCover, Diameter, TopCover, Pitch,
    Structure, Facename):
    Adds the Helical reinforcement bar to the selected structural object."""
    if not structure and not facename:
        selected_obj = FreeCADGui.Selection.getSelectionEx()[0]
        structure = selected_obj.Object
        facename = selected_obj.SubElementNames[0]
    face = structure.Shape.Faces[getFaceNumber(facename) - 1]
    # StructurePRM = getTrueParametersOfStructure(structure)
    FacePRM = getParametersOfFace(structure, facename, False)
    if not FacePRM:
        FreeCAD.Console.PrintError(
            "Cannot identify shape or from which base object structural "
            "element is derived\n"
        )
        return
    size = (
        ArchCommands.projectToVector(
            structure.Shape.copy(), face.normalAt(0, 0)
        )
    ).Length
    normal = face.normalAt(0, 0)
    # normal = face.Placement.Rotation.inverted().multVec(normal)
    import Arch

    helix = createHelicalWire(
        FacePRM, s_cover, b_cover, t_cover, pitch, size, normal, diameter
    )
    helix.Support = [(structure, facename)]
    rebar = Arch.makeRebar(
        structure, helix, diameter, 1, diameter / 2, name="HelicalRebar"
    )
    rebar.OffsetStart = diameter / 2
    rebar.OffsetEnd = diameter / 2
    FreeCAD.ActiveDocument.recompute()
    # Adds properties to the rebar object
    rebar.addProperty(
        "App::PropertyEnumeration",
        "RebarShape",
        "RebarDialog",
        QT_TRANSLATE_NOOP("App::Property", "Shape of rebar"),
    ).RebarShape = RebarTypes.tolist()
    rebar.RebarShape = "HelicalRebar"
    rebar.setEditorMode("RebarShape", 2)
    rebar.addProperty(
        "App::PropertyDistance",
        "SideCover",
        "RebarDialog",
        QT_TRANSLATE_NOOP("App::Property", "Front cover of rebar"),
    ).SideCover = s_cover
    rebar.setEditorMode("SideCover", 2)
    rebar.addProperty(
        "App::PropertyDistance",
        "Pitch",
        "RebarDialog",
        QT_TRANSLATE_NOOP("App::Property", "Left Side cover of rebar"),
    ).Pitch = pitch
    rebar.setEditorMode("Pitch", 2)
    rebar.addProperty(
        "App::PropertyDistance",
        "BottomCover",
        "RebarDialog",
        QT_TRANSLATE_NOOP("App::Property", "Bottom cover of rebar"),
    ).BottomCover = b_cover
    rebar.setEditorMode("BottomCover", 2)
    rebar.addProperty(
        "App::PropertyDistance",
        "TopCover",
        "RebarDialog",
        QT_TRANSLATE_NOOP("App::Property", "Top cover of rebar"),
    ).TopCover = t_cover
    rebar.setEditorMode("TopCover", 2)
    FreeCAD.ActiveDocument.recompute()
    return rebar
コード例 #12
0
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
コード例 #13
0
def 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,
):
    prev_main_rebars_type = main_rebar_group.RebarType
    prev_hook_extend_along = main_rebar_group.HookExtendAlong
    if prev_main_rebars_type == main_rebars_type:
        recreate_main_rebars = False
    else:
        recreate_main_rebars = True
    main_rebars = []

    if recreate_main_rebars:
        for rebar in main_rebar_group.MainRebars[2:]:
            base_name = rebar.Base.Name
            FreeCAD.ActiveDocument.removeObject(rebar.Name)
            FreeCAD.ActiveDocument.removeObject(base_name)
        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,
        )
    else:
        for rebar in main_rebar_group.MainRebars[2:]:
            main_rebars.append(rebar)
        # Calculate common parameters for Straight/LShaped rebars
        t_cover = t_offset_of_rebars
        b_cover = b_offset_of_rebars
        rebar_number_spacing_check = True

        # Edit Straight Rebars
        if main_rebars_type == "StraightRebar":
            hook_extend_along = "x-axis"
            facename_for_rebars = getFacenameforRebar(hook_extend_along,
                                                      facename, structure)
            f_cover = b_cover_of_ties + dia_of_ties
            r_cover = r_cover_of_ties + dia_of_ties
            orientation = "Vertical"
            rebar_number_spacing_value = 2

            editStraightRebar(
                main_rebars[-1],
                f_cover,
                ("Right Side", r_cover),
                t_cover,
                b_cover,
                dia_of_main_rebars,
                rebar_number_spacing_check,
                rebar_number_spacing_value,
                orientation,
                structure,
                facename_for_rebars,
            )
            main_rebars[-1].OffsetEnd = (t_cover_of_ties + dia_of_ties +
                                         dia_of_main_rebars / 2)

        # Edit L-Shaped Rebars
        elif main_rebars_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_ties + dia_of_ties
            else:
                f_cover = r_cover_of_ties + dia_of_ties
            # 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_main_rebars
            if not l_rebar_rounding:
                l_rebar_rounding = (float(dia_of_ties) / 2 +
                                    dia_of_main_rebars / 2) / dia_of_ties
            l_rebar_orientation_cover = getLRebarOrientationLeftRightCover(
                hook_orientation,
                hook_extension,
                hook_extend_along,
                l_cover_of_ties,
                r_cover_of_ties,
                t_cover_of_ties,
                b_cover_of_ties,
                dia_of_ties,
                dia_of_main_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

            if hook_extend_along == "x-axis":
                if prev_hook_extend_along == "y-axis":
                    rebar = main_rebars.pop()
                    base_name = rebar.Base.Name
                    FreeCAD.ActiveDocument.removeObject(rebar.Name)
                    FreeCAD.ActiveDocument.removeObject(base_name)
                rebar_number_spacing_value = 2
                orientation = list_orientation[1]
                editLShapeRebar(
                    main_rebars[-1],
                    f_cover,
                    b_cover,
                    l_cover[1],
                    r_cover[1],
                    dia_of_main_rebars,
                    t_cover,
                    l_rebar_rounding,
                    rebar_number_spacing_check,
                    rebar_number_spacing_value,
                    orientation,
                    structure,
                    facename_for_rebars,
                )
                main_rebars[-1].OffsetEnd = (t_cover_of_ties + dia_of_ties +
                                             dia_of_main_rebars / 2)
            elif hook_extend_along == "y-axis":
                rebar_number_spacing_value = 1
                orientation = list_orientation[1]
                for i, orientation in enumerate(list_orientation):
                    if len(main_rebars) > i:
                        editLShapeRebar(
                            main_rebars[i],
                            f_cover,
                            b_cover,
                            l_cover[i],
                            r_cover[i],
                            dia_of_main_rebars,
                            t_cover,
                            l_rebar_rounding,
                            rebar_number_spacing_check,
                            rebar_number_spacing_value,
                            orientation,
                            structure,
                            facename_for_rebars,
                        )
                    else:
                        main_rebars.append(
                            makeLShapeRebar(
                                f_cover,
                                b_cover,
                                l_cover[i],
                                r_cover[i],
                                dia_of_main_rebars,
                                t_cover,
                                l_rebar_rounding,
                                rebar_number_spacing_check,
                                rebar_number_spacing_value,
                                orientation,
                                structure,
                                facename_for_rebars,
                            ))
                    main_rebars[i].OffsetEnd = (l_cover_of_ties + dia_of_ties +
                                                dia_of_main_rebars / 2)
    FreeCAD.ActiveDocument.recompute()
    return main_rebars
コード例 #14
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
コード例 #15
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
コード例 #16
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()
コード例 #17
0
def 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,
):
    # Calculate common parameters for Straight/LShaped rebars
    t_cover = t_offset_of_rebars
    b_cover = b_offset_of_rebars
    rebar_number_spacing_check = True
    main_rebars = []

    # Create Straight Rebars
    if main_rebars_type == "StraightRebar":
        hook_extend_along = "x-axis"
        facename_for_rebars = getFacenameforRebar(hook_extend_along, facename,
                                                  structure)
        f_cover = b_cover_of_ties + dia_of_ties
        r_cover = r_cover_of_ties + dia_of_ties
        orientation = "Vertical"
        rebar_number_spacing_value = 2

        main_rebars.append(
            makeStraightRebar(
                f_cover,
                ("Right Side", r_cover),
                t_cover,
                b_cover,
                dia_of_main_rebars,
                rebar_number_spacing_check,
                rebar_number_spacing_value,
                orientation,
                structure,
                facename_for_rebars,
            ))
        main_rebars[-1].OffsetEnd = (t_cover_of_ties + dia_of_ties +
                                     dia_of_main_rebars / 2)

    # Create L-Shaped Rebars
    elif main_rebars_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_ties + dia_of_ties
        else:
            f_cover = r_cover_of_ties + dia_of_ties
        # 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_main_rebars
        if not l_rebar_rounding:
            l_rebar_rounding = (float(dia_of_ties) / 2 +
                                dia_of_main_rebars / 2) / dia_of_ties
        l_rebar_orientation_cover = getLRebarOrientationLeftRightCover(
            hook_orientation,
            hook_extension,
            hook_extend_along,
            l_cover_of_ties,
            r_cover_of_ties,
            t_cover_of_ties,
            b_cover_of_ties,
            dia_of_ties,
            dia_of_main_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

        if hook_extend_along == "x-axis":
            rebar_number_spacing_value = 2
            orientation = list_orientation[1]
            main_rebars.append(
                makeLShapeRebar(
                    f_cover,
                    b_cover,
                    l_cover[1],
                    r_cover[1],
                    dia_of_main_rebars,
                    t_cover,
                    l_rebar_rounding,
                    rebar_number_spacing_check,
                    rebar_number_spacing_value,
                    orientation,
                    structure,
                    facename_for_rebars,
                ))
            main_rebars[-1].OffsetEnd = (t_cover_of_ties + dia_of_ties +
                                         dia_of_main_rebars / 2)
        elif hook_extend_along == "y-axis":
            rebar_number_spacing_value = 1
            orientation = list_orientation[1]
            for i, orientation in enumerate(list_orientation):
                main_rebars.append(
                    makeLShapeRebar(
                        f_cover,
                        b_cover,
                        l_cover[i],
                        r_cover[i],
                        dia_of_main_rebars,
                        t_cover,
                        l_rebar_rounding,
                        rebar_number_spacing_check,
                        rebar_number_spacing_value,
                        orientation,
                        structure,
                        facename_for_rebars,
                    ))
                main_rebars[i].OffsetEnd = (l_cover_of_ties + dia_of_ties +
                                            dia_of_main_rebars / 2)
    FreeCAD.ActiveDocument.recompute()
    return main_rebars