Ejemplo n.º 1
0
    def get_all_grouped(self):
        # create x-raster
        for rib in self.ribs:
            rib.rotate(90, radians=False)

        panels = self.panels
        ribs = Layout.stack_row(self.ribs, self.config.patterns_align_dist_x)
        dribs = Layout.stack_row(self.dribs.values(),
                                 self.config.patterns_align_dist_x)
        straps = Layout.stack_row(self.straps.values(),
                                  self.config.patterns_align_dist_x)

        panels_grouped = panels.copy().group_materials()
        ribs_grouped = ribs.group_materials()
        dribs_grouped = dribs.group_materials()
        straps_grouped = straps.group_materials()

        panels_border = panels.draw_border(append=False)
        ribs_border = ribs.draw_border(append=False)
        dribs_border = dribs.draw_border(append=False)
        straps_border = straps.draw_border(append=False)

        for material_name, layout in panels_grouped.items():
            layout.parts.append(panels_border.copy())
            layout.add_text("panels_" + material_name)

        for material_name, layout in ribs_grouped.items():
            layout.parts.append(ribs_border.copy())
            layout.add_text("ribs_" + material_name)

        for material_name, layout in dribs_grouped.items():
            layout.parts.append(dribs_border.copy())
            layout.add_text("dribs_" + material_name)

        for material_name, layout in straps_grouped.items():
            layout.parts.append(straps_border.copy())
            layout.add_text("straps_" + material_name)

        panels.add_text("panels_all")

        all_layouts = [panels]
        all_layouts += panels_grouped.values()
        all_layouts += ribs_grouped.values()
        all_layouts += dribs_grouped.values()
        all_layouts += straps_grouped.values()

        return Layout.stack_column(all_layouts, 0.01, center_x=False)
Ejemplo n.º 2
0
    def unwrap(self, outdir, glider=None):
        def fn(filename):
            return os.path.join(outdir, filename)

        subprocess.call("mkdir -p {}".format(outdir), shell=True)

        if self.config.profile_numpoints:
            self.glider_2d.num_profile = self.config.profile_numpoints

        glider = glider or self.glider_2d.get_glider_3d()

        drawings = self._get_sketches(outdir, glider)

        if self.config.complete_glider:
            glider_complete = glider.copy_complete()
            glider_complete.rename_parts()
            plots = PlotMaker(glider_complete, config=self.config)
            glider_complete.lineset.iterate_target_length()
        else:
            plots = PlotMaker(glider, config=self.config)
            glider.lineset.iterate_target_length()
            
        plots.unwrap()
        all_patterns = plots.get_all_grouped()

        # with open(fn("patterns.json"), "w") as outfile:
        #     jsonify.dump(plots, outfile)

        designs = Layout.stack_column(drawings, self.config.patterns_align_dist_y)
        all_patterns.append_left(designs, distance=self.config.patterns_align_dist_x*2)

        print("export patterns")

        all_patterns.scale(1000)
        all_patterns.export_svg(fn("plots_all.svg"))
        all_patterns.export_dxf(fn("plots_all_dxf2000.dxf"))
        all_patterns.export_dxf(fn("plots_all_dxf2007.dxf"), "AC1021")
        all_patterns.export_ntv(fn("plots_all.ntv"))



        # ribs = packer.pack_parts(parts["ribs"].parts, sheet_size=sheet_size)
        # panels = packer.pack_parts(parts["panels"].parts, sheet_size=sheet_size)

        # for sheet_no, sheet in enumerate(ribs):
        #     openglider.plots.create_svg(sheet, fn("ribs_{}".format(sheet_no)))
        # for sheet_no, sheet in enumerate(panels):
        #     openglider.plots.create_svg(sheet, fn("panels_{}".format(sheet_no)))

        # sketches = openglider.plots.sketches.get_all_plots(self.glider_2d, glider)
        #
        # for sketch_name in ("design_upper", "design_lower"):
        #     sketch = sketches.pop(sketch_name)
        #     sketch.drawing.scale_a4()
        #     sketch.drawing.export_svg(fn(sketch_name+".svg"), add_styles=True)
        #
        # for sketch_name, sketch in sketches.items():
        #     sketch.drawing.scale_a4()
        #     sketch.drawing.export_svg(fn(sketch_name+".svg"), add_styles=False)

        print("output spreadsheets")
        excel = openglider.plots.spreadsheets.get_glider_data(glider)
        excel.saveas(os.path.join(outdir, "data.ods"))