Giter VIP home page Giter VIP logo

plotink's Introduction

plotink

Python helper routines for driving AxiDraw, EggBot, WaterColorBot, and similar plotter-based machines.

This repository maintained by Windell H. Oskay, Bantam Tools.

Source code and issue tracker are hosted at github.

Installation

Releases are available on PyPI.

To install the latest release, use pip install plotink

Overview

These library files are intended to provide a single place to edit routines that are common to the EggBot extensions for Inkscape, the WaterColorBot extensions for Inkscape, the AxiDraw extensions for Inkscape, and derivative machines. Hosting these in a single place means less duplication of code, and (more importantly) reduces the number of cases where identical code changes need to be made in multiple places.

The library files are:

  • ebb_serial.py - General routines for communicating with the EiBotBoard by USB serial.
  • ebb_motion.py - Motion-related routines for interacting with the robot.
  • plot_utils.py - Additional helper functions for managing plots and their data.
  • text_utils.py - Additional helper functions for managing text.
  • rtree.py - Minimal R-tree spatial index class for calculating intersecting regions.
  • spatial_grid.py - Specialized flat grid spatial index class for finding nearest neighbors.

Python version support

Latest version requires Python 3.6 or newer.

A previous release, Plotink version 1.0.1, supports python 2.7 as well.

Logging

This library uses the standard python logging module. Suggested configurations follow.

For stand-alone machine control, print info, warnings, and errors to stdout:

import logging

logging.basicConfig(level=logging.INFO, format='%(message)s')

For running as an Inkscape extension, print errors to Inkscape's extension errors log:

import logging

logging.basicConfig(level=logging.ERR,
        format='%(message)s'),
        filename = "~/.config/inkscape/extension-errors.log")

plotink's People

Contributors

berleant avatar cabalist avatar claui avatar lwander avatar masonium avatar oskay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

plotink's Issues

plot_utils.clip_segment: Endless loop on small boundary values

Working with python 3.9 in an interactive session, we can try:

from plotink import plot_utils
segment = [[1,1],[-1,-1]]
bounds = [[0,0], [3, 3]]
plot_utils.clip_segment(segment, bounds)

Which returns (True, [[1, 1], [0, 0.0]]).

With bounds = [[1e-6,1e-6], [3, 3]], we get (True, [[1, 1], [1e-06, 1.0000000000287557e-06]]).

However, with bounds = [[1e-9, 1e-9], [3, 3]], a (seemingly) endless loop can occur that needs to be manually aborted.

Printing out the new segment generated at the end of each iteration yields:

[[1, 1], [1e-09, 9.999999717180685e-10]]
[[1, 1], [9.999999717180685e-10, 1e-09]]
[[1, 1], [1e-09, 9.999999717180685e-10]]
[[1, 1], [9.999999717180685e-10, 1e-09]]
[[1, 1], [1e-09, 9.999999717180685e-10]]
[[1, 1], [9.999999717180685e-10, 1e-09]]
[...]

This is clearly a repeating cycle, driven by comparisons that approach the edges of numeric precision.

Cohen–Sutherland clipping normally resolves in two iterations, and edge cases could can be constructed that take four iterations. To resolve the issue -- which is critical -- it seems reasonable to add a failsafe loop counter, that exits with True and the current clipped segment after four iterations.

Restructure to avoid direct error reporting

ebb_serial.query and ebb_serial.command both have inkex.errormsg calls that directly print error messages.

Those, in turn are called widely in the various functions in ebb_motion.

For handling a wider variety of use cases, we need to revise these functions so that they no longer directly print error messages.

Possible solutions:
(1) Modify these functions (and those that call them) to return an error message.

(2) Add the functions to a class, such that the error status can be added to a string variable in that class, something along the lines of ebb_serial.error_msg, that can be accessed by scripts that import ebb_serial.

dependency on cspsubdiv

maybe add a note about this to the README? (speaking of README suggestions, currently the word "both" is followed by a list of more than 2 things.)

How to make a pancake printer into an inkscape extension

I see that you have provided a lot of inkscape extension files. Thank you very much for your help! But I had a problem. I'm currently using a pancake printer called pancakebot, and I want to make it into an inkscape extension file, I need to extend the function of the plugin, don't need many layers, just need it to draw the line path!
I'm not a programmer, so I talked to programmers around me, and they all said it's hard, they can't make it, I don't know if you can make it, but if you can, you're awesome! You can be the teacher of many programmers!!

This link is the software information for the pancake printer, which is open source.

https://github.com/pancakebot

Code question

Hello,

I haven't see this convention before at the file level. In ebb_serial.py:

def __init__(self):
    ebbVersion = "none"

Is this intentional? This is usually not found outside a Class.

ebb_serial: Catch exception in comports

When comports has an error, we should handle that error gracefully.

Partial traceback:

  File "/home/ubuntu/.config/inkscape/extensions/axidraw_deps/plotink/ebb_serial.py", line 57, in findPort

    com_ports_list = list(comports())

  File "/home/ubuntu/.config/inkscape/extensions/axidraw_deps/serial/tools/list_ports_linux.py", line 102, in comports

    for info in [SysFS(d) for d in devices]

  File "/home/ubuntu/.config/inkscape/extensions/axidraw_deps/serial/tools/list_ports_linux.py", line 102, in <listcomp>

    for info in [SysFS(d) for d in devices]

  File "/home/ubuntu/.config/inkscape/extensions/axidraw_deps/serial/tools/list_ports_linux.py", line 48, in __init__

    num_if = int(self.read_line(self.usb_device_path, 'bNumInterfaces'))

TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

The TypeError itself is pyserial/pyserial#550 and occurs whenever no ports are found on Linux.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.