wheecode


Namewheecode JSON
Version 0.5.0 PyPI version JSON
download
home_pagehttps://github.com/xloem/wheecode
SummarySimple GCode generator
upload_time2023-05-10 23:10:59
maintainer
docs_urlNone
authorWheeeeeeeee!!
requires_python
license
keywords gcode 3dprinting cnc reprap additive
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            Wheecode
======
  `
[![Unit Tests](https://github.com/xloem/wheecode/actions/workflows/python-package.yml/badge.svg)](https://github.com/xloem/wheecode/actions/workflows/python-package.yml)

### GCode for all

Wheecode is a fork of [mecode][1], designed to simplify GCode generation.  It
is not a slicer, thus it can not convert CAD models to 3D printer ready code.
It simply provides a convenient, human-readable layer just above GCode. If you
often find yourself manually writing your own GCode, then wheecode is for you.

[1]: https://github.com/jminardi/mecode

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

```python
from wheecode 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 20
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 `wheecode` simply prints the generated GCode to stdout. If instead you
want to generate a file, you can pass a filename when
instantiating the `G` object.

```python
g = G(outfile='path/to/file.gcode')
```

*NOTE:* When using the option direct_write=True or when writing to a file, 
`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:

```python
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 `mayavi` or `matplotlib`
package with the `view()` method:

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

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

Direct control via serial communication
---------------------------------------

With the option `direct_write=True`, a serial connection to the controlled device 
is established via USB serial at a virtual COM port of the computer and the 
g-code commands are sent directly to the connected device using a serial 
communication protocol:

```python
import wheecode
g = wheecode.G(
    direct_write=True, 
    direct_write_mode="serial", 
    printer_port="/dev/tty.usbmodem1411", 
    baudrate=115200
)  # Under MS Windows, use printer_port="COMx" where x has to be replaced by the port number of the virtual COM port the device is connected to according to the device manager.
g.write("M302 S0")  # send g-Code. Here: allow cold extrusion. Danger: Make sure extruder is clean without filament inserted 
g.absolute()  # Absolute positioning mode
g.move(x=10, y=10, z=10, F=500)  # move 10mm in x and 10mm in y and 10mm in z at a feedrate of 500 mm/min
g.retract(10)  # Move extruder motor
g.write("M400")  # IMPORTANT! wait until execution of all commands is finished
g.teardown()  # Disconnect (close serial connection)
```

All GCode Methods
-----------------

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:

```python
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.

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.

Installation
------------

The easiest method to install wheecode is with pip:

```bash
pip install wheecode
```

To install from source:

```bash
$ git clone https://github.com/xloem/wheecode.git
$ cd wheecode
$ pip install -r requirements.txt
$ python setup.py install
```

Optional Dependencies
---------------------
The following dependencies are optional, and are only needed for
visualization. An easy way to install them is to use [conda][3].

* numpy
* matplotlib
* vpython
* mayavi

[2]: https://www.anaconda.com/

TODO
----

- [ ] add pressure box comport to `__init__()` method
- [ ] build out multi-nozzle support
    - [ ] include multi-nozzle support in view method.
- [ ] factor out aerotech specific methods into their own class
- [ ] auto set MFO=100% before each print
- [ ] add ability to read current status of aerotech
  - [ ] turn off omnicure after aborted runs
- [ ] add formal sphinx documentation
- [ ] create github page


Credits
-------
This software was originally developed by the [Lewis Lab][3] at Harvard University, likely by Jack Minardi, and then forked and added on to by many people and organizations listed in the commit history.

[3]: http://lewisgroup.seas.harvard.edu/

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/xloem/wheecode",
    "name": "wheecode",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "gcode,3dprinting,cnc,reprap,additive",
    "author": "Wheeeeeeeee!!",
    "author_email": "0xloem@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/98/fe/2a05443664d721b227ed538d1f609eab4fd148e53c43084c88a40c705211/wheecode-0.5.0.tar.gz",
    "platform": null,
    "description": "Wheecode\n======\n  `\n[![Unit Tests](https://github.com/xloem/wheecode/actions/workflows/python-package.yml/badge.svg)](https://github.com/xloem/wheecode/actions/workflows/python-package.yml)\n\n### GCode for all\n\nWheecode is a fork of [mecode][1], designed to simplify GCode generation.  It\nis not a slicer, thus it can not convert CAD models to 3D printer ready code.\nIt simply provides a convenient, human-readable layer just above GCode. If you\noften find yourself manually writing your own GCode, then wheecode is for you.\n\n[1]: https://github.com/jminardi/mecode\n\nBasic Use\n---------\nTo use, simply instantiate the `G` object and use its methods to trace your\ndesired tool path.\n\n```python\nfrom wheecode import G\ng = G()\ng.move(10, 10)  # move 10mm in x and 10mm in y\ng.arc(x=10, y=5, radius=20, direction='CCW')  # counterclockwise arc with a radius of 20\ng.meander(5, 10, spacing=1)  # trace a rectangle meander with 1mm spacing between passes\ng.abs_move(x=1, y=1)  # move the tool head to position (1, 1)\ng.home()  # move the tool head to the origin (0, 0)\n```\n\nBy default `wheecode` simply prints the generated GCode to stdout. If instead you\nwant to generate a file, you can pass a filename when\ninstantiating the `G` object.\n\n```python\ng = G(outfile='path/to/file.gcode')\n```\n\n*NOTE:* When using the option direct_write=True or when writing to a file, \n`g.teardown()` must be called after all commands are executed. If you\nare writing to a file, this can be accomplished automatically by using G as\na context manager like so:\n\n```python\nwith G(outfile='file.gcode') as g:\n    g.move(10)\n```\n\nWhen the `with` block is exited, `g.teardown()` will be automatically called.\n\nThe resulting toolpath can be visualized in 3D using the `mayavi` or `matplotlib`\npackage with the `view()` method:\n\n```python\ng = G()\ng.meander(10, 10, 1)\ng.view()\n```\n\nThe graphics backend can be specified when calling the `view()` method, e.g. `g.view('mayavi')`.\n\nDirect control via serial communication\n---------------------------------------\n\nWith the option `direct_write=True`, a serial connection to the controlled device \nis established via USB serial at a virtual COM port of the computer and the \ng-code commands are sent directly to the connected device using a serial \ncommunication protocol:\n\n```python\nimport wheecode\ng = wheecode.G(\n    direct_write=True, \n    direct_write_mode=\"serial\", \n    printer_port=\"/dev/tty.usbmodem1411\", \n    baudrate=115200\n)  # Under MS Windows, use printer_port=\"COMx\" where x has to be replaced by the port number of the virtual COM port the device is connected to according to the device manager.\ng.write(\"M302 S0\")  # send g-Code. Here: allow cold extrusion. Danger: Make sure extruder is clean without filament inserted \ng.absolute()  # Absolute positioning mode\ng.move(x=10, y=10, z=10, F=500)  # move 10mm in x and 10mm in y and 10mm in z at a feedrate of 500 mm/min\ng.retract(10)  # Move extruder motor\ng.write(\"M400\")  # IMPORTANT! wait until execution of all commands is finished\ng.teardown()  # Disconnect (close serial connection)\n```\n\nAll GCode Methods\n-----------------\n\nAll methods have detailed docstrings and examples.\n\n* `set_home()`\n* `reset_home()`\n* `feed()`\n* `dwell()`\n* `home()`\n* `move()`\n* `abs_move()`\n* `arc()`\n* `abs_arc()`\n* `rect()`\n* `meander()`\n* `clip()`\n* `triangular_wave()`\n\nMatrix Transforms\n-----------------\n\nA wrapper class, `GMatrix` will run all move and arc commands through a \n2D transformation matrix before forwarding them to `G`.\n\nTo use, simply instantiate a `GMatrix` object instead of a `G` object:\n\n```python\ng = GMatrix()\ng.push_matrix()      # save the current transformation matrix on the stack.\ng.rotate(math.pi/2)  # rotate our transformation matrix by 90 degrees.\ng.move(0, 1)         # same as moves (1,0) before the rotate.\ng.pop_matrix()       # revert to the prior transformation matrix.\n```\n\nThe transformation matrix is 2D instead of 3D to simplify arc support.\n\nRenaming Axes\n-------------\n\nWhen working with a machine that has more than one Z-Axis, it is\nuseful to use the `rename_axis()` function. Using this function your\ncode can always refer to the vertical axis as 'Z', but you can dynamically\nrename it.\n\nInstallation\n------------\n\nThe easiest method to install wheecode is with pip:\n\n```bash\npip install wheecode\n```\n\nTo install from source:\n\n```bash\n$ git clone https://github.com/xloem/wheecode.git\n$ cd wheecode\n$ pip install -r requirements.txt\n$ python setup.py install\n```\n\nOptional Dependencies\n---------------------\nThe following dependencies are optional, and are only needed for\nvisualization. An easy way to install them is to use [conda][3].\n\n* numpy\n* matplotlib\n* vpython\n* mayavi\n\n[2]: https://www.anaconda.com/\n\nTODO\n----\n\n- [ ] add pressure box comport to `__init__()` method\n- [ ] build out multi-nozzle support\n    - [ ] include multi-nozzle support in view method.\n- [ ] factor out aerotech specific methods into their own class\n- [ ] auto set MFO=100% before each print\n- [ ] add ability to read current status of aerotech\n  - [ ] turn off omnicure after aborted runs\n- [ ] add formal sphinx documentation\n- [ ] create github page\n\n\nCredits\n-------\nThis software was originally developed by the [Lewis Lab][3] at Harvard University, likely by Jack Minardi, and then forked and added on to by many people and organizations listed in the commit history.\n\n[3]: http://lewisgroup.seas.harvard.edu/\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Simple GCode generator",
    "version": "0.5.0",
    "project_urls": {
        "Download": "https://github.com/xloem/wheecode/tarball/main",
        "Homepage": "https://github.com/xloem/wheecode"
    },
    "split_keywords": [
        "gcode",
        "3dprinting",
        "cnc",
        "reprap",
        "additive"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "079de47ae264705c895464ae887b198e703b01b7531f16d0de9161a788128cce",
                "md5": "d878966e1a600bef5dd250fb8a2d8e32",
                "sha256": "c65a4e0c0128ff1bb893d8a414b7587c929e47a2b8b8c28e35d223974f947a8e"
            },
            "downloads": -1,
            "filename": "wheecode-0.5.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d878966e1a600bef5dd250fb8a2d8e32",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 39193,
            "upload_time": "2023-05-10T23:10:56",
            "upload_time_iso_8601": "2023-05-10T23:10:56.963361Z",
            "url": "https://files.pythonhosted.org/packages/07/9d/e47ae264705c895464ae887b198e703b01b7531f16d0de9161a788128cce/wheecode-0.5.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "98fe2a05443664d721b227ed538d1f609eab4fd148e53c43084c88a40c705211",
                "md5": "c8a019640e8b380a9741267e9200dda3",
                "sha256": "8a07854c5feb8f8d6bf947dda811cca0539b6eb42268cff32c1c10d6f7d38c34"
            },
            "downloads": -1,
            "filename": "wheecode-0.5.0.tar.gz",
            "has_sig": false,
            "md5_digest": "c8a019640e8b380a9741267e9200dda3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 38367,
            "upload_time": "2023-05-10T23:10:59",
            "upload_time_iso_8601": "2023-05-10T23:10:59.111656Z",
            "url": "https://files.pythonhosted.org/packages/98/fe/2a05443664d721b227ed538d1f609eab4fd148e53c43084c88a40c705211/wheecode-0.5.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-10 23:10:59",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "xloem",
    "github_project": "wheecode",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": true,
    "circle": true,
    "requirements": [],
    "lcname": "wheecode"
}
        
Elapsed time: 0.17626s