Mecode/ru

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)  # переместить 10 мм по x и 10 мм по 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='path/to/file.gcode', print_lines=False)
  • NOTE: `g.teardown()` must be called after all commands are executed if you are writing to a file. This can be accomplished automatically by using G as a context manager like so:
with G(outfile='file.gcode') as g:
    g.move(10)

When the with block is exited, g.teardown() will be automatically called.

The resulting toolpath can be visualized in 3D using the `matplotlib` or `mayavi` package with the `view()` method:

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

All methods have detailed docstrings and examples.

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

Matrix Transforms

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()      # save the current transformation matrix on the stack.
g.rotate(math.pi/2)  # rotate our transformation matrix by 90 degrees.
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.

Переименование осей

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.

Credits

Mecode в настоящее время поддерживается Джеком Минарди на Voxel8.