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 runRebarDistribution(self, front_cover=None):
    if front_cover is None:
        front_cover = self.form.frontCover.text()
        front_cover = FreeCAD.Units.Quantity(front_cover).Value
    face = self.SelectedObj.Shape.Faces[getFaceNumber(self.FaceName) - 1]
    size = (ArchCommands.projectToVector(self.SelectedObj.Shape.copy(),
                                         face.normalAt(0, 0))).Length
    dialog = _RebarDistributionDialog(front_cover, size)
    dialog.setupUi(self.CustomSpacing)
    dialog.form.exec_()
    try:
        self.CustomSpacing = dialog.CustomSpacing
    except AttributeError:
        pass
Пример #4
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
Пример #5
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
Пример #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 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
Пример #9
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