# Path: lasercut/helper.py
# def biggest_area_faces(freecad_shape):
#     sorted_list = sort_area_shape_faces(freecad_shape)
#     biggest_area_face = sorted_list[-1]
# #       contains : 0:normal, 1:area mm2, 2; list of faces
#     return biggest_area_face


from FreeCAD import Gui
from lasercut.helper import biggest_area_faces
import FreeCAD
import FreeCADGui
import os
import math
import Draft
        new_doc = FreeCAD.newDocument("export_shape")
        self.export_list(parts_list, new_doc)
        FreeCADGui.getDocument(new_doc.Name).ActiveView.fitAll()
        return

    def export_list(self, parts_list, freecad_document):
        x_pos = 0.
        y_pos = 0.
        margin = 10.
        max_line_y = 0
        z_fix = 30
        new_parts_list = []
        per_line = int(math.sqrt(len(parts_list)))
        for i in range(len(parts_list)):
            part = parts_list[i]
            new_part = freecad_document.addObject("Part::Feature", "test")

            transform_shape(part, new_part, freecad_document)
            bound_box = new_part.Shape.BoundBox
            shift_vector = FreeCAD.Vector(-bound_box.XMin + x_pos, -bound_box.YMin + y_pos, z_fix - bound_box.ZMin)
            x_pos += bound_box.XLength + margin
            new_part.Placement.Base = new_part.Placement.Base.add(shift_vector)
            bound_box = new_part.Shape.BoundBox
            freecad_document.recompute()

            if (bound_box.YLength + y_pos) > max_line_y:
                max_line_y = bound_box.YLength + y_pos

            if (i+1) % per_line == 0:
                y_pos = max_line_y + margin

# Path: lasercut/helper.py
# def biggest_area_faces(freecad_shape):
#     sorted_list = sort_area_shape_faces(freecad_shape)
#     biggest_area_face = sorted_list[-1]
# #       contains : 0:normal, 1:area mm2, 2; list of faces
#     return biggest_area_face


# Path: ExportPanel.py
from FreeCAD import Gui
from lasercut.helper import biggest_area_faces
import FreeCAD
import FreeCADGui
import os
import math
import Draft

        new_doc = FreeCAD.newDocument("export_shape")
        self.export_list(parts_list, new_doc)
        FreeCADGui.getDocument(new_doc.Name).ActiveView.fitAll()
        return

    def export_list(self, parts_list, freecad_document):
        x_pos = 0.
        y_pos = 0.
        margin = 10.
        max_line_y = 0
        z_fix = 30
        new_parts_list = []
        per_line = int(math.sqrt(len(parts_list)))
        for i in range(len(parts_list)):
            part = parts_list[i]
            new_part = freecad_document.addObject("Part::Feature", "test")

            transform_shape(part, new_part, freecad_document)
            bound_box = new_part.Shape.BoundBox
            shift_vector = FreeCAD.Vector(-bound_box.XMin + x_pos, -bound_box.YMin + y_pos, z_fix - bound_box.ZMin)
            x_pos += bound_box.XLength + margin
            new_part.Placement.Base = new_part.Placement.Base.add(shift_vector)
            bound_box = new_part.Shape.BoundBox
            freecad_document.recompute()

            if (bound_box.YLength + y_pos) > max_line_y:
                max_line_y = bound_box.YLength + y_pos

            if (i+1) % per_line == 0:
                y_pos = max_line_y + margin

                x_pos = 0