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

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

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

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

        rebars_list = getFreeCADObjectsList(reinforcement_objs)
        FreeCADGui.addModule("ReinforcementDrawing.make_reinforcement_drawing")
        for view in views:
            FreeCADGui.doCommand(
                "ReinforcementDrawing.make_reinforcement_drawing."
                "makeStructuresReinforcementDrawing(structure_list=None, "
                f"rebars_list={rebars_list}, "
                f'view="{view}", '
                f"rebars_stroke_width={rebars_stroke_width}, "
                f'rebars_color_style="{rebars_color_style}", '
                f"rebars_color={rebars_color}, "
                f"structure_stroke_width={structure_stroke_width}, "
                f'structure_color_style="{structure_color_style}", '
                f"structure_color={structure_color}, "
                f"drawing_left_offset={drawing_left_offset}, "
                f"drawing_top_offset={drawing_top_offset}, "
                f"drawing_min_right_offset={drawing_min_right_offset}, "
                f"drawing_min_bottom_offset={drawing_min_bottom_offset}, "
                f"drawing_max_width={drawing_max_width}, "
                f"drawing_max_height={drawing_max_height}, "
                f'template_file=r"{template_file}", '
                f"perform_dimensioning={perform_dimensioning}, "
                "dimension_rebars_filter_list=None, "
                f'dimension_label_format="{dimension_label_format}",  '
                f'dimension_font_family="{dimension_font_family}", '
                f"dimension_font_size={dimension_font_size}, "
                f"dimension_stroke_width={dimension_stroke_width}, "
                f'dimension_line_style="{dimension_line_style}",'
                f" dimension_line_color={dimension_line_color}, "
                f"dimension_text_color={dimension_text_color}, "
                'dimension_single_rebar_line_start_symbol="'
                f'{dimension_single_rebar_line_start_symbol}", '
                'dimension_single_rebar_line_end_symbol="'
                f'{dimension_single_rebar_line_end_symbol}", '
                'dimension_multi_rebar_line_start_symbol="'
                f'{dimension_multi_rebar_line_start_symbol}", '
                'dimension_multi_rebar_line_end_symbol="'
                f'{dimension_multi_rebar_line_end_symbol}", '
                'dimension_line_mid_point_symbol="'
                f'{dimension_line_mid_point_symbol}", '
                f"dimension_left_offset={dimension_left_offset}, "
                f"dimension_right_offset={dimension_right_offset}, "
                f"dimension_top_offset={dimension_top_offset}, "
                f"dimension_bottom_offset={dimension_bottom_offset}, "
                "dimension_left_offset_increment="
                f"{dimension_left_offset_increment}, "
                "dimension_right_offset_increment="
                f"{dimension_right_offset_increment}, "
                "dimension_top_offset_increment="
                f"{dimension_top_offset_increment}, "
                "dimension_bottom_offset_increment="
                f"{dimension_bottom_offset_increment}, "
                "dimension_single_rebar_outer_dim="
                f"{dimension_single_rebar_outer_dim}, "
                "dimension_multi_rebar_outer_dim="
                f"{dimension_multi_rebar_outer_dim}, "
                "dimension_single_rebar_text_position_type="
                f'"{dimension_single_rebar_text_position_type}", '
                "dimension_multi_rebar_text_position_type="
                f'"{dimension_multi_rebar_text_position_type}")')
        self.form.close()
Exemplo n.º 2
0
    def accept(self):
        """This function is executed when 'OK' button is clicked from UI. It
        execute a function to generate bar bending schedule."""
        # Validate entered units
        units_valid_flag = True
        for unit_h_layout in self.column_units_layouts:
            unit_field = unit_h_layout.itemAt(1).widget()
            if not unit_field.isValidUnit():
                unit_text = unit_field.text()
                unit_field.setText(unit_text +
                                   (" (Invalid Unit)" if " (Invalid Unit)"
                                    not in unit_text else ""))
                units_valid_flag = False
        if not self.rebar_edge_dimension_units_widget.isValidUnit():
            unit_text = self.rebar_edge_dimension_units_widget.text()
            self.rebar_edge_dimension_units_widget.setText(unit_text + (
                " (Invalid Unit)" if " (Invalid Unit)" not in unit_text else ""
            ))
            units_valid_flag = False
        if not units_valid_flag:
            return

        # Check if output file is selected or not
        output_file = self.form.svgOutputFile.text()
        if not output_file:
            self.form.svgOutputFile.setStyleSheet("border: 1px solid red;")
            return

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

        rebar_length_type = self.form.rebarLengthType.currentText()
        reinforcement_group_by = self.form.reinforcementGroupBy.currentText()
        column_units = self.getColumnUnits()
        column_headers = self.getColumnConfigData()
        font_family = self.form.fontFamily.currentText()
        font_size = self.form.fontSize.value()
        column_width = FreeCAD.Units.Quantity(
            self.form.columnWidth.text()).Value
        row_height = FreeCAD.Units.Quantity(self.form.rowHeight.text()).Value
        rebar_shape_column_header = self.form.rebarShapeColumnHeader.text()
        stirrup_extended_edge_offset = FreeCAD.Units.Quantity(
            self.form.stirrupExtendedEdgeOffset.text()).Value
        rebars_stroke_width = FreeCAD.Units.Quantity(
            self.form.rebarsStrokeWidth.text()).Value
        if self.form.shapeColorRadio.isChecked():
            rebars_color_style = "shape color"
        else:
            rebars_color_style = Draft.getrgb(
                self.form.rebarsColor.property("color").getRgbF())
        include_dimensions = self.form.includeDimensions.isChecked()
        include_units_in_dimension_label = (
            self.form.includeUnitsInDimensionLabel.isChecked())
        rebar_shape_dimension_font_size = self.form.dimensionFontSize.value()
        rebar_edge_dimension_units = FreeCAD.Units.Quantity(
            self.rebar_edge_dimension_units_widget.text()).Value
        rebar_edge_dimension_precision = (
            self.form.rebarEdgeDimensionPrecision.value())
        bent_angle_dimension_exclude_list_str = (
            self.form.bentAngleDimensionExcludeList.text())
        bent_angle_dimension_exclude_list = []
        for angle in bent_angle_dimension_exclude_list_str.split(","):
            try:
                bent_angle_dimension_exclude_list.append(float(angle.strip()))
            except ValueError:
                pass
        helical_rebar_dimension_label_format = (
            self.form.helicalRebarDimensionLabelFormat.text())

        output_file = self.form.svgOutputFile.text()
        getBarBendingSchedule(
            reinforcement_objs,
            column_headers=column_headers,
            column_units=column_units,
            rebar_length_type=rebar_length_type,
            reinforcement_group_by=reinforcement_group_by,
            font_family=font_family,
            font_size=font_size,
            column_width=column_width,
            row_height=row_height,
            rebar_shape_column_header=rebar_shape_column_header,
            rebar_shape_stirrup_extended_edge_offset=(
                stirrup_extended_edge_offset),
            rebar_shape_color_style=rebars_color_style,
            rebar_shape_stroke_width=rebars_stroke_width,
            rebar_shape_include_dimensions=include_dimensions,
            rebar_shape_dimension_font_size=rebar_shape_dimension_font_size,
            rebar_shape_edge_dimension_units=rebar_edge_dimension_units,
            rebar_shape_edge_dimension_precision=rebar_edge_dimension_precision,
            include_edge_dimension_units_in_dimension_label=(
                include_units_in_dimension_label),
            rebar_shape_bent_angle_dimension_exclude_list=(
                bent_angle_dimension_exclude_list),
            helical_rebar_dimension_label_format=(
                helical_rebar_dimension_label_format),
            output_file=output_file,
        )

        self.form.close()
Exemplo n.º 3
0
def getBarBendingSchedule(
    rebar_objects: Optional[List] = None,
    column_headers: Optional[Dict[str, Tuple[str, int]]] = None,
    column_units: Optional[Dict[str, str]] = None,
    dia_weight_map: Optional[Dict[float, FreeCAD.Units.Quantity]] = None,
    rebar_length_type: Optional[Literal["RealLength",
                                        "LengthWithSharpEdges"]] = None,
    reinforcement_group_by: Optional[Literal["Mark", "Host"]] = None,
    font_family: Optional[str] = None,
    font_size: float = 5,
    column_width: float = 60,
    row_height: float = 30,
    rebar_shape_column_header: str = "Rebar Shape (mm)",
    rebar_shape_view_directions: Union[
        Union[FreeCAD.Vector, WorkingPlane.Plane],
        List[Union[FreeCAD.Vector,
                   WorkingPlane.Plane]], ] = FreeCAD.Vector(0, 0, 0),
    rebar_shape_stirrup_extended_edge_offset: float = 2,
    rebar_shape_color_style: str = "shape color",
    rebar_shape_stroke_width: float = 0.35,
    rebar_shape_include_dimensions: bool = True,
    rebar_shape_dimension_font_size: float = 3,
    rebar_shape_edge_dimension_units: str = "mm",
    rebar_shape_edge_dimension_precision: int = 0,
    include_edge_dimension_units_in_dimension_label: bool = False,
    rebar_shape_bent_angle_dimension_exclude_list: Union[List[float],
                                                         Tuple[float,
                                                               ...]] = (45, 90,
                                                                        180),
    helical_rebar_dimension_label_format: str = "%L,r=%R,pitch=%P",
    output_file: Optional[str] = None,
) -> ElementTree.Element:
    """Generate Bar Bending Schedule svg.

    Parameters
    ----------
    rebar_objects : list of <ArchRebar._Rebar> and <rebar2.BaseRebar>, optional
        Rebars list to generate bar bending schedule.
        If None, then all ArchRebars and rebar2.BaseRebar objects with unique
        Mark from ActiveDocument will be selected and rebars with no Mark
        assigned will be ignored.
        Default is None.
    column_headers : Dict[str, Tuple[str, int]], optional
        A dictionary with keys: "Mark", "RebarsCount", "Diameter",
        "RebarLength", "RebarsTotalLength" and values are tuple of column_header
        and its sequence number.
            e.g. {
                    "Host": ("Member", 1),
                    "Mark": ("Mark", 2),
                    "RebarsCount": ("No. of Rebars", 3),
                    "Diameter": ("Diameter in mm", 4),
                    "RebarLength": ("Length in m/piece", 5),
                    "RebarsTotalLength": ("Total Length in m", 6),
                }
            set column sequence number to 0 to hide column.
        Default is None, to select from FreeCAD Reinforcement BOM preferences.
    column_units : Dict[str, str], optional
        column_units is a dictionary with keys: "Diameter", "RebarLength",
        "RebarsTotalLength" and their corresponding units as value.
            e.g. {
                    "Diameter": "mm",
                    "RebarLength": "m",
                    "RebarsTotalLength": "m",
                }
        Default is None, to select from FreeCAD Reinforcement BOM preferences.
    dia_weight_map : Dict[float, FreeCAD.Units.Quantity], optional
        A dictionary with diameter as key and corresponding weight (kg/m) as
        value.
            e.g. {
                    6: FreeCAD.Units.Quantity("0.222 kg/m"),
                    8: FreeCAD.Units.Quantity("0.395 kg/m"),
                    10: FreeCAD.Units.Quantity("0.617 kg/m"),
                    12: FreeCAD.Units.Quantity("0.888 kg/m"),
                    ...,
                }
        Default is None, to select from FreeCAD Reinforcement BOM preferences.
    rebar_length_type : {"RealLength", "LengthWithSharpEdges"}, optional
        The rebar length calculations type.
        "RealLength": length of rebar considering rounded edges.
        "LengthWithSharpEdges": length of rebar assuming sharp edges of rebar.
        Default is None, to select from FreeCAD Reinforcement BOM preferences.
    reinforcement_group_by: {"Mark", "Host"}, optional
        Specifies how reinforcement objects should be grouped.
        Default is None, to select from FreeCAD Reinforcement BOM preferences.
    font_family : str, optional
        The font-family of text.
        Default is None, to select from FreeCAD Reinforcement BOM preferences.
    font_size : float
        The font-size of text.
        Default is 5
    column_width : float
        The width of each column in bar shape cut list.
        Default is 60
    row_height : float
        The height of each row in bar shape cut list.
        Default is 30
    rebar_shape_column_header : str
        The column header for rebar shape column.
        Default is "Rebar Shape (mm)"
    rebar_shape_view_directions : FreeCAD.Vector or WorkingPlane.Plane
                                  OR their list
        The view point directions for each rebar shape.
        Default is FreeCAD.Vector(0, 0, 0) to automatically choose
        view_directions.
    rebar_shape_stirrup_extended_edge_offset : float
        The offset of extended end edges of stirrup, so that end edges of
        stirrup with 90 degree bent angle do not overlap with stirrup edges.
        Default is 2
    rebar_shape_color_style : {"shape color", "color_name","hex_value_of_color"}
        The color style of rebars in rebar shape svg.
        "shape color" means select color of rebar shape.
    rebar_shape_stroke_width : float
        The stroke-width of rebars in rebar shape svg.
        Default is 0.35
    rebar_shape_include_dimensions : bool
        If True, then each rebar edge dimensions and bent angle dimensions will
        be included in rebar shape svg.
        Default is True.
    rebar_shape_dimension_font_size: float
        The font size of dimension text in rebar shape svg.
        Default is 3
    rebar_shape_edge_dimension_units : str
        The units to be used for rebar length dimensions in rebar shape svg.
        Default is "mm".
    rebar_shape_edge_dimension_precision : int
        The number of decimals that should be shown for rebar length as
        dimension label in rebar shape svg. Set it to None to use user preferred
        unit precision from FreeCAD unit preferences.
        Default is 0
    include_edge_dimension_units_in_dimension_label : bool
        If it is True, then rebar length units will be shown in dimension label
        in rebar shape svg.
        Default is False.
    rebar_shape_bent_angle_dimension_exclude_list : tuple of float
        The tuple of bent angles to not include their dimensions in rebar shape.
        Default is (45, 90, 180).
    helical_rebar_dimension_label_format : str
        The format of helical rebar dimension label in rebar shape svg.
            %L -> Length of helical rebar
            %R -> Helix radius of helical rebar
            %P -> Helix pitch of helical rebar
        Default is "%L,r=%R,pitch=%P".
    output_file: str, optional
        The output file to write generated svg.

    Returns
    -------
    ElementTree.Element
        The generated bar bending schedule svg.
    """
    rebar_objects = getReinforcementRebarObjects(rebar_objects)
    bom_preferences = BOMPreferences()
    if not column_headers:
        column_headers = bom_preferences.getColumnHeaders()
    if not column_units:
        column_units = bom_preferences.getColumnUnits()
    column_units = fixColumnUnits(column_units or {})
    if not reinforcement_group_by:
        reinforcement_group_by = bom_preferences.getReinforcementGroupBy()

    svg_pref = bom_preferences.getSVGPrefGroup()
    if not font_family:
        font_family = svg_pref.GetString("FontFamily")
    if not font_size:
        font_size = svg_pref.GetFloat("FontSize")

    svg = getSVGRootElement()
    bbs_svg = ElementTree.Element("g", attrib={"id": "BBS"})
    svg.append(bbs_svg)

    bom_svg = makeBillOfMaterialSVG(
        column_headers,
        column_units,
        dia_weight_map,
        rebar_length_type,
        font_family,
        font_size=font_size,
        column_width=column_width,
        row_height=row_height,
        rebar_objects=rebar_objects,
        reinforcement_group_by=reinforcement_group_by,
        return_svg_only=True,
    )
    bom_table_svg = bom_svg.find("./g[@id='BOM_table']")
    bbs_svg.append(bom_table_svg)

    bom_width = float(bom_svg.get("width").replace("mm", ""))
    column_header_height = row_height * (2 if "RebarsTotalLength"
                                         in column_headers else 1)
    # Add column header for rebar shape cut list
    rebar_shape_cut_list_header = getSVGDataCell(
        rebar_shape_column_header,
        bom_width,
        0,
        column_width,
        column_header_height,
        font_family,
        font_size,
        font_weight="bold",
    )
    bbs_svg.append(rebar_shape_cut_list_header)

    base_rebars_list = []
    if reinforcement_group_by == "Mark":
        base_rebars_list = getBaseRebarsList(rebar_objects)
    else:
        host_reinforcement_dict = getHostReinforcementsDict(rebar_objects)
        for reinforcement_list in host_reinforcement_dict.values():
            base_rebars_list.extend(getBaseRebarsList(reinforcement_list))

    bar_cut_list_svg = getRebarShapeCutList(
        base_rebars_list,
        rebar_shape_view_directions,
        False if "Mark" in column_headers and column_headers["Mark"][1] != 0
        else True,
        rebar_shape_stirrup_extended_edge_offset,
        rebar_shape_stroke_width,
        rebar_shape_color_style,
        rebar_shape_include_dimensions,
        rebar_shape_edge_dimension_units,
        rebar_shape_edge_dimension_precision,
        include_edge_dimension_units_in_dimension_label,
        rebar_shape_bent_angle_dimension_exclude_list,
        font_family,
        rebar_shape_dimension_font_size,
        helical_rebar_dimension_label_format,
        row_height,
        column_width,
        column_count=1,
        horizontal_rebar_shape=True,
    ).find("./g[@id='RebarShapeCutList']")
    bbs_svg.append(bar_cut_list_svg)

    # Translate rebar shape cut list to last column and set top offset =
    # height of column headers
    bar_cut_list_svg.set(
        "transform", "translate({} {})".format(bom_width,
                                               column_header_height))

    total_separator = bom_svg.find(
        ".//*[@id='bom_table_cell_column_separator']", )
    total_separator_width = float(total_separator.get("width"))
    total_separator.set("width", str(total_separator_width + column_width))
    total_separator_y = float(total_separator.get("y"))
    total_separator_height = float(total_separator.get("height"))
    for x in range(0, 3):
        bbs_svg.append(
            getSVGRectangle(
                bom_width,
                total_separator_y + total_separator_height + x * row_height,
                column_width,
                row_height,
            ))

    bom_height = float(bom_svg.get("height").replace("mm", ""))
    svg_width = bom_width + column_width
    svg.set("width", str(svg_width) + "mm")
    svg.set("height", str(bom_height) + "mm")
    svg.set("viewBox", "0 0 {} {}".format(svg_width, bom_height))

    if output_file:
        svg_sheet = minidom.parseString(
            ElementTree.tostring(svg,
                                 encoding="unicode")).toprettyxml(indent="  ")
        try:
            with open(output_file, "w", encoding="utf-8") as svg_output_file:
                svg_output_file.write(svg_sheet)
        except OSError:
            FreeCAD.Console.PrintError("Error writing svg to file " +
                                       str(svg_output_file) + "\n")

    return svg
Exemplo n.º 4
0
    def accept(self):
        """This function is executed when 'OK' button is clicked from UI. It
        execute a function to generate rebar shape cut list."""
        # Validate entered units
        if not self.rebar_edge_dimension_units_widget.isValidUnit():
            unit_text = self.rebar_edge_dimension_units_widget.text()
            self.rebar_edge_dimension_units_widget.setText(unit_text + (
                " (Invalid Unit)" if " (Invalid Unit)" not in unit_text else ""
            ))
            return
        # Check if output file is selected or not
        output_file = self.form.svgOutputFile.text()
        if not output_file:
            self.form.svgOutputFile.setStyleSheet("border: 1px solid red;")
            return

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

        stirrup_extended_edge_offset = FreeCAD.Units.Quantity(
            self.form.stirrupExtendedEdgeOffset.text()).Value
        rebars_stroke_width = FreeCAD.Units.Quantity(
            self.form.rebarsStrokeWidth.text()).Value
        if self.form.shapeColorRadio.isChecked():
            rebars_color_style = "shape color"
        else:
            rebars_color_style = Draft.getrgb(
                self.form.rebarsColor.property("color").getRgbF())
        row_height = FreeCAD.Units.Quantity(self.form.rowHeight.text()).Value
        column_width = FreeCAD.Units.Quantity(
            self.form.columnWidth.text()).Value
        if self.form.rowCountCheckBox.isChecked():
            column_count = "row_count"
        else:
            column_count = self.form.columnCount.value()
        self.side_padding = FreeCAD.Units.Quantity(
            self.form.sidePadding.text()).Value
        self.horizontal_rebar_shape = self.form.horizontalRebarShape.isChecked(
        )
        include_mark = self.form.includeMark.isChecked()
        include_dimensions = self.form.includeDimensions.isChecked()
        include_units_in_dimension_label = (
            self.form.includeUnitsInDimensionLabel.isChecked())
        rebar_edge_dimension_units = (FreeCAD.Units.Quantity(
            self.rebar_edge_dimension_units_widget.text()).toStr().split(" ")
                                      [-1])
        rebar_edge_dimension_precision = (
            self.form.rebarEdgeDimensionPrecision.value())
        dimension_font_family = self.form.dimensionFontFamily.currentText()
        dimension_font_size = self.form.dimensionFontSize.value()
        bent_angle_dimension_exclude_list_str = (
            self.form.bentAngleDimensionExcludeList.text())
        bent_angle_dimension_exclude_list = []
        for angle in bent_angle_dimension_exclude_list_str.split(","):
            try:
                bent_angle_dimension_exclude_list.append(float(angle.strip()))
            except ValueError:
                pass
        helical_rebar_dimension_label_format = (
            self.form.helicalRebarDimensionLabelFormat.text())

        getRebarShapeCutList(
            base_rebars_list=base_rebars_list,
            include_mark=include_mark,
            stirrup_extended_edge_offset=stirrup_extended_edge_offset,
            rebars_stroke_width=rebars_stroke_width,
            rebars_color_style=rebars_color_style,
            include_dimensions=include_dimensions,
            rebar_edge_dimension_units=rebar_edge_dimension_units,
            rebar_edge_dimension_precision=rebar_edge_dimension_precision,
            include_units_in_dimension_label=include_units_in_dimension_label,
            bent_angle_dimension_exclude_list=(
                bent_angle_dimension_exclude_list),
            dimension_font_family=dimension_font_family,
            dimension_font_size=dimension_font_size,
            helical_rebar_dimension_label_format=(
                helical_rebar_dimension_label_format),
            row_height=row_height,
            column_width=column_width,
            column_count=column_count,
            side_padding=self.side_padding,
            horizontal_rebar_shape=self.horizontal_rebar_shape,
            output_file=output_file,
        )

        self.form.close()