Inkcut now embeds an IPython console which greatly helps debugging. You can access the entire runtime state of the application via python's inspection tools and the enaml workbench's plugin api.
It's often helpful to be able to manually send commands the the device.
To do this from the console use:
from inkcut.core.workbench import InkcutWorkbench
# Get device handle
device = InkcutWorkbench.instance().get_plugin('inkcut.device').device
device.connect() # Or click the connect button in the Control tab
device.connection.write("D100,100")
# Some time later...
device.disconnect()
You can use this to run scripts if needed. See the IPython docs for more on IPython.
Note: Since Inkcut does not use threads writing is all asyncronously. To wait for a write to complete, use the returned deferred
This is documentation is intended for developers wishing to modify or extend Inkcut.
To build from source use the commands below.
We intend to support both Python 2 (with qt 4) and Python 3 (with qt 5), however using Python 3 is recommended. On 32-bit systems only Python 2 works, since PyQt5 only has a 64-bit package.
virtualenv -p python3 venv
source venv/bin/activate
# Install native dependencies
sudo apt install libxml2-dev libxslt-dev libcups2-dev
# Install python dependencies
pip install PyQt5
# Run inkcut from sources
python main.py
# Install inkcut
pip install .
cd /path/to/inkcut/folder
pip install .
gives an error regarding enamlx, you may need to install enamlx, then re-run pip install .
pip install git+https://github.com/frmdstryr/enamlx.git
.virtualenv -p python2 venv
source venv/bin/activate
# Install lxml
sudo apt install libxml2-dev libxslt-dev
# Only on Python 2 - you must install and link pyqt4
sudo apt install python-qt4
#: Replace ~/.virtualenvs/cv with venv/ on linux
ln -s /usr/lib/python2.7/dist-packages/PyQt4/ ~/.virtualenvs/cv/lib/python2.7/site-packages/
ln -s /usr/lib/python2.7/dist-packages/sip.so ~/.virtualenvs/cv/lib/python2.7/site-packages/
#: Install inkcut
pip install .
source ~/.profile #" loads virtual environment profile settings
workon cv #" opens virtual environment cv
# Install lxml
sudo apt install libxml2-dev libxslt-dev
# Only on Python 2 - you must install and link pyqt4
sudo apt install python-qt4
#: Replace ~/.virtualenvs/cv with venv/ on linux
ln -s /usr/lib/python2.7/dist-packages/PyQt4/ ~/.virtualenvs/cv/lib/python2.7/site-packages/
ln -s /usr/lib/python2.7/dist-packages/sip.so ~/.virtualenvs/cv/lib/python2.7/site-packages/
#: Install inkcut
pip install .
# On the raspberry pi, install RPI.GPIO (if using the motor control driver)
pip install RPi.GPIO
# Install zbar (pi only for crop mark registration)
pip install git+https://github.com/npinchot/zbar.git
Inkcut is designed entirely using plugins using enaml's workbench framework. The inkcut source is separated into packages where each is a plugin (and any plugins that plugin adds).
The default plugins allow developers to define:
These plugins can interact with all builtin plugins using the enaml workbench interface.
You can define plugins and install them using python entry points. Inkcut loads external plugins from the inkcut.plugin
entry point. Using this you can create python packages usesrs can install to extend Inkcut. The entry point implementation shall return an enaml PluginManifest
factory (either the PluginManifest subclass or a function that when called returns a PluginManifest instance).
See a nice intro on entry points here using-plugins
Inkcut was redesigned to have separation between the device job processing, device connection, the protocol used, and the configuration of each. All of these can be completely customized as is needed for your specific hardware.
This extensibility should allow Inkcut to be used for more than vinyl cutters and plotters as discussed below.
Custom device "drivers" can be implemented to enable Inkcut to control specific device. A custom stepper motor driver for Inkcut using the raspberry pi demonstrates the usage of this. DeviceDrivers must implement the Device interface.
The driver may have it's own configuration and UI for editing the configuration without needing to modify any core functionality. Adding a driver is done by simply registering it with a plugin.
A driver may also transform, manipulate, and do any post processing of a path before it is sent to the device. The actual connecting, sending, and processing can all be overridden as is needed by the driver.
If the builtin driver is sufficient for processing the job but uses a custom communication protocol. The custom protocol can be added as an external plugins or to the builtin device protocols (such as HPGL, DMPL, etc.. ) in the inkcut.device.protocols plugin. The protocol must implement the basic DeviceProtocol interface.
The protocol may have it's own configuration options and UI for editing the options without needing to modify any core functionality.
Connections (such as Serial port, Printer, etc.. ) are added in the inkcut.device.transports packages. Connections are simply an interface used to communicate with "some device".
Serial and printer connections are included by default. More can be added by external plugins. The plugin must implement the basic DeviceTransport interface.
Each connection may have it's own configuration and UI for editing the configuration without needing to modify any core functionality.
Filters are used to do preprocessing of the job before it is converted to commands to be sent to the device. Examples of filters are blade offset
and overcut
compensation.
New filters should be added to the inkcut.device.filters packages. Or they can be added by external plugins. The plugin must implement the basic DeviceFilter interface.
Filters are applied to the "path model" (QPainterPath) either before or after it is converted to a polygon for sending to the device.
Each filter may have it's own configuration and UI for editing the configuration without needing to modify any core functionality.
Inkcut now uses the concept of a "Job" to represent an SVG graphic and the configuration settings required to create the final output. The core piece of this is the svg parser that generates a QPainterPath. The QPainterPath is used to internally represent the paths that must eventually be sent to the device.
Contributions are welcome. Please document any enhancements using markdown.
Note: The
site.json
in the docs folder is no longer used.
Cd to the folder and
git add <file/path>
git commit -m "Some message"
git push origin master
#: Config is in .git/config
Build:
rm -r dist
python setup.py sdist
python setup.py bdist_wheel --universal
To do a test release:
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
Then install and test it (on other machines) with:
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple inkcut
To do the actual release:
twine upload dist/*
See also:
I put a lot of work into this project. Initial development started in 2015 and Inkcut was
completely rewritten 4 times since then, improving every iteration. Please consider
donating or sponsoring the development of Inkcut here.