def effect( self ): '''Main entry point: check to see which mode/tab is selected, and act accordingly.''' self.versionString = "AxiDraw Naming - Version 2.1.0 dated 2019-05-15" # Input sanitization: self.options.mode = self.options.mode.strip("\"") self.options.nickname = self.options.nickname.strip("\"") if (self.options.mode == "about"): return ad = axidraw.AxiDraw() ad.getoptions([]) ad.called_externally = True # Pass the document off for plotting ad.document = self.document ad.options.mode = "manual" if (self.options.mode == "list_names"): ad.options.manual_cmd = "list_names" if (self.options.mode == "write_name"): ad.options.manual_cmd = "write_name" + self.options.nickname ad.effect()
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ''' import random from axidrawinternal import axidraw ad = axidraw.AxiDraw() # Create class instance """ Compose an SVG document as a string. The head and tail are "boilerplate" for an A4 size page, 297 x 210 mm in landscape format. We will add to the document a circle, rectangle, and two paths, hardcoded We will also add a random ellipse, that will be different each time that you run the script """ svg_head = """<?xml version="1.0" encoding="UTF-8" standalone="no"?>
def plot_to_axidraw( self, port, primary): # if primary: # pass # else: # inkex.errormsg('Skipping secondary. ' ) # return # Skip secondary units, without opening class or serial connection ad = axidraw.AxiDraw(params=self.params, default_logging=self.default_logging) ad.getoptions([]) prim = "primary" if primary else "secondary" logger.info("plot_to_axidraw started, at port %s (%s)", port, prim) # Many plotting parameters to pass through: ad.options.mode = self.options.mode ad.options.speed_pendown = self.options.speed_pendown ad.options.speed_penup = self.options.speed_penup ad.options.accel = self.options.accel ad.options.pen_pos_up = self.options.pen_pos_up ad.options.pen_pos_down = self.options.pen_pos_down ad.options.pen_rate_raise = self.options.pen_rate_raise ad.options.pen_rate_lower = self.options.pen_rate_lower ad.options.pen_delay_up = self.options.pen_delay_up ad.options.pen_delay_down = self.options.pen_delay_down ad.options.no_rotate = self.options.no_rotate ad.options.const_speed = self.options.const_speed ad.options.report_time = self.options.report_time ad.options.manual_cmd = self.options.manual_cmd ad.options.walk_dist = self.options.walk_dist ad.options.layer = self.options.layer ad.options.copies = self.options.copies ad.options.page_delay = self.options.page_delay ad.options.preview = self.options.preview ad.options.rendering = self.options.rendering ad.options.model = self.options.model ad.options.port = port ad.options.setup_type = self.options.setup_type ad.options.resume_type = self.options.resume_type ad.options.auto_rotate = self.options.auto_rotate ad.options.resolution = self.options.resolution ad.options.reordering = self.options.reordering # Special case for this wrapper function: # If the port is None, change the port config option # to be "use first available AxiDraw": if port is None: ad.options.port_config = 1 # Use first available AxiDraw else: ad.options.port_config = 2 # Use AxiDraw specified by port ad.document = self.document ad.original_document = self.document if not primary: ad.set_secondary() # Suppress general message reporting; suppress time reporting # Plot the document using axidraw.py ad.effect() if primary: # Collect output from axidraw.py self.document = ad.document self.outdoc = ad.get_output() else: if ad.error_out: if port is not None: logger.error('Error on AxiDraw at port "' + port + '":' + ad.error_out) else: logger.error('Error on secondary AxiDraw: ' + ad.error_out)
ad.disconnect() # Close connection to AxiDraw All options except port and port_config can be changed after connect(). However, you must call update() after changing the options and before calling any additional motion commands. ''' import sys from axidrawinternal import axidraw ad = axidraw.AxiDraw() # Initialize class ad.interactive() # Enter interactive mode connected = ad.connect() # Open serial port to AxiDraw if not connected: sys.exit() # end script ad.moveto(2,1) # Absolute pen-up move, to (2 inch, 1 inch) version = ad.usb_query("V\r") # Query firmware version print("Firmware version data: " + version) step_pos = ad.usb_query("QS\r") # Query step position print("Step pos: " + step_pos)