Mecode/ua

From RepRap
Jump to: navigation, search

Mecode - це бібліотека з відкритим вихідним кодом для створення GCode. Вона написана на python та ліцензована за ліцензією MIT.

Ви можете знайти вихідний код на github: https://github.com/jminardi/mecode

Mecode призначена для спрощення отримання GCode. Це не слайсер, тому він не може конвертувати моделі CAD у готовий код для 3D-принтера. Вона забезпечує зручну, зрозумілу для людини оболонку над GCode. Якщо ви часто виявляєте, що вручну пишете свій власний GCode, тоді mecode для вас. Mecode може генерувати базові команди GCode, такі як line та arc, а також складові команди, такі як прямокутники та звивини.

Основне застосування

To use, simply instantiate the `G` object and use its methods to trace your desired tool path.

from mecode import G
g = G()
g.move(10, 10)  # move 10mm in x and 10mm in y
g.arc(x=10, y=5, radius=20, direction='CCW')  # counterclockwise arc with a radius of 5
g.meander(5, 10, spacing=1)  # trace a rectangle meander with 1mm spacing between passes
g.abs_move(x=1, y=1)  # move the tool head to position (1, 1)
g.home()  # move the tool head to the origin (0, 0)

By default mecode simply prints the generated GCode to stdout. If instead you want to generate a file, you can pass a filename and turn off the printing when instantiating the `G` object.

g = G(outfile='шлях/до/файлу.gcode', print_lines=False)
  • ПРИМІТКА: `g.teardown()` має викликатися після виконання всіх команд, якщо ви виконуєте запис у файл. Це може бути виконано автоматично за допомогою G як контекстний менеджер таким чином:
з G(outfile='файл.gcode') як g:
    g.move(10)

Коли блок буде завершено, автоматично буде викликаний g.teardown().

Результуючу траєкторію руху інструменту можна візуалізувати в 3D за допомогою пакету `matplotlib` або `mayavi` за допомогою методу `view()`:

g = G()
g.meander(10, 10, 1)
g.view()

The graphics backend can be specified when calling the `view()` method, e.g. `g.view('matplotlib')`. `'mayavi'` is the default graphics backend.

Усі методи GCode

Усі методи мають докладну документацію та приклади.

  • set_home()
  • reset_home()
  • feed()
  • dwell()
  • home()
  • move()
  • abs_move()
  • arc()
  • abs_arc()
  • rect()
  • meander()
  • clip()
  • triangular_wave()

Матричні перетворення

A wrapper class, `GMatrix` will run all move and arc commands through a 2D transformation matrix before forwarding them to `G`.

To use, simply instantiate a `GMatrix` object instead of a `G` object:

g = GMatrix()
g.push_matrix() # збережіть поточну матрицю перетворення в стеку.
g.rotate(math.pi/2) # повернути нашу матрицю перетворення на 90 градусів.
g.move(0, 1)         # same as moves (1,0) before the rotate.
g.pop_matrix()       # revert to the prior transformation matrix.

The transformation matrix is 2D instead of 3D to simplify arc support.

Renaming Axes

When working with a machine that has more than one Z-Axis, it is useful to use the `rename_axis()` function. Using this function your code can always refer to the vertical axis as 'Z', but you can dynamically rename it.

Учасники

Mecode в даний час підтримується Джеком Мінарді на Voxel8.