Пример #1
0
                x_prev, y_prev, z_prev = 0, 0, 0
                for z_plane in self.paths:
                    z, coords_list = z_plane
                    for coords in coords_list:
                        move = True
                        for coor in coords:
                            x, y = coor
                            if not move:
                                e += np.sqrt(
                                    sum(
                                        list(
                                            map(lambda a: (a[0] - a[1])**2,
                                                [(x, x_prev), (y, y_prev),
                                                 (z, z_prev)])))) * self.unit_E
                            else:
                                move = False
                            x_prev, y_prev, z_prev = x, y, z
                            f.write('G1 X' + str(x) + ' Y' + str(y) + ' Z' +
                                    str(z) + ' E' + str(e) + '\n')
        except Exception as e:
            print(e)


if __name__ == "__main__":
    import sys
    gcode_gen = GcodeGenerater()
    app = QtWidgets.QApplication(sys.argv)
    ui = Ui_MainWindow(gcode_gen)
    ui.show()
    sys.exit(app.exec_())