Welcome to PolyChemPrint3’s User Guide and Software Documentation!¶
PolyChemPrint3 is an open source benchtop additive manufacturing software developed at the University of Illinois by Bijal Patel and Dr. Ying Diao. For more information, please visit the project homepage and Diao Research Group homepage.
- This readthedocs.io page contains:
A ‘user guide’ with instructions on setting up and operating the program.
A ‘software guide’ intended as a programming aid that contains the organized python docstrings for the modules, classes, and methods of this object-oriented program.
Note: If you use this software/code, please cite the original paper listed on the project homepage! It really helps!
Program Overview¶
PolyChemPrint3 (PCP3) is a command-line interface (CLI) Windows/Linux program that handles communication between the user and additive manufacturing(AM) hardware. In some ways, PCP3 offers overlapping functionality with 3D printer control software such as pronterface and 3D slicing programs such as slic3r or Cura, but optimized for AM research with unconventional, non-FDM toolheads such as pneumatic (melt) extruders, LASERs, syringe pumps, etc.

At the most basic level, users can directly send commands to the motion axes and toolhead to execute GCode move sequences and simple tool on/off/ power set commands. The next level up is to use parameterized, hardcoded ‘sequences’ to execute specific 2D and 3D patterns such as meanderlines, cuboids, electrode patterns, etc. For more complex 2D/3D patterns, GCode files created by slicers such as GCodeTools in Inkscape and Cura/ Slic3r can be imported as sequences. Finally, any combination of sequences can be chained together into ‘Recipes’, offering a ‘code-free’ way to build-up complex patterns. Automatic data-logging exports print parameters to text files to optimize parameter screening.
Note: Even if you have identical hardware to the original developers, the software will need some initial setup - so pay careful attention to the “Installation and Setup” section. Best of luck!
Installation and Setup¶
Requirements/Supported OS¶
PCP3 is designed to run on Windows and Linux distributions with Python 3 on even very low spec hardware. At the end of the day, for just sending commands between hardware, there really isn’t much you need in terms of specialized system specs. Just serial ports that can be connected to your desired hardware.
In our lab, we have run PCP3 on Debian 9/ Mint 19 Linux PCs and on Windows 10 using Ananconda as the python environment.
Installing Anaconda (optional)¶
To use polychemprint3, you need to have a python 3 environment set up. If you are on Linux, your distribution most likely has python 3 installed out of the box. If not, a simple way to set things up is to use Anaconda, a free and open source python distribution comonly used in data science.
After successfully installing Anaconda, open Anaconda Navigator and launch anaconda prompt. Boxed in red below:

Installing PCP3 from PyPi via pip¶
After opening the appropriate terminal window (Anaconda Prompt/Terminal/Command Prompt), enter:
pip install --no-cache-dir --pre --upgrade polychemprint3
Press enter and polychemprint3 should install with any required dependencies automatically.
To run the program, just type
polychemprint3
into the terminal window and the program should launch

Run from Source (from Github)¶
All source code (for PCP3 and this manual) is posted on github at https://github.com/BijalBPatel/PolyChemPrint3 . Three branches are maintained:
- Master: The main stable release
- Beta: A test release which may have new features we are testing. This is the version we run in our lab.
- Dev: Testing release for new and semi/not working features.
If you are new to github, there are many quick tutorials online - such as this.
Setting up new Hardware¶
PCP3 as written uses pySerial to communicate with hardware devices. To add a new tool, begin by cloning and renaming one of the existing tool.py files in the polychemprint3/tools directory. We will then go line by line and replace comment text and parameters such as device address, baudrate, etc with the values that correspond to your particular hardware. Here we highlight key parameters to change:
- In the __init__ method, set the devAddress, baudRate, commsTimeOut, and other parameters to reflect your hardware.
- Next, go through each of the methods (activate, deactivate, engage, disengage, setValue, startSerial, etc), and write the necessary code to complete the communication loop with your hardware. If your device has a simple arduino based controller, these methods may be very simple (see Laser6W.py). If the device uses a special packet-based protocol, this can be more challenging, but see ultimusExtruder.py for a good example of this.
- No matter what, make sure the methods specified in the toolSpec.py abstract base class are filled out in your new code file.
- Once the tool.py file is complete, restart PCP3 and check that it properly is loaded [the starting load text will indiciate “PASS” for both conditions.
Modifying Marlin Firmware¶
If you are using a consumer 3D printer for your motion axes, there is a high likelihood you will need to modify the stock Marlin firmware to work with PCP3. Our main goal is to force the command acknowledge statement “ok ….” to only be sent from the printer AFTER all motion steps are complete. If you are running on Linux, you may also need to change the firmware baudrate for compatibility. Here is how:
Download the Marlin firmware source files either from your printer manufacturer’s webpage, or from the main Marlin Firmware webpage
If you are getting firmware from the Marlin site, see if you can find the configuration files for your printer in the MarlinFirmware Github folder that corresponds to your printer.
Dowload arduinoIDE and from Tools -> Boards -> Board Manager install the RAMBo board files.
Open all of your Firmware files in arduino IDE by running the Marlin.ino file in the Marlin folder.
If necessary, in the conditionals.h file, set the baudrate to your desired value.
Navigate to the Marlin_main.cpp file and find the “process_next_command()” method. At the very end of this method (see image), add the following statement:
stepper.synchronize(); //PAUSES UNTIL MOTION COMPLETE BEFORE SENDING OK
Compile as hex and export
Use a program such as cura to load your new firmware onto your printer.
Note: Be sure to save the old firmware, you will need it to go back to normal FDM 3D printing.
PCP3 Package Overview¶
PCP3 is written in Python following object-oriented programming (OOP) principles, meaning that data and methods are organized in terms of distinct “objects” with clearly defined attributes and behaviors, which are only instantiated (given specific values) in the __main__.py method. This modular approach (see Figure below) greatly simplifies the process of adding additional hardware and sequences by isolating these blocks of code into distinct submodules (folders) that are separate from the more complex user interface and main methods. In order to add a new sequence to the program, for example, the user can simply clone one of the existing light blue .py files, rename it and modify the contents to contain the desired motion/tool commands, and place it in the sequence folder. On startup, PCP3 automatically attempts to load any new sequences, axes, or tool .py files, after checking for compiler errors.

PCP3 also takes advantage of the OOP concept of inheritance to streamline addition of new code files to the program. The grey boxes in the Figure are effectively blueprints (‘Abstract Base Classes’, in Python) for the class declarations (light blue .py files) that inherit from them (signified by grey arrows from the parent to the child class). This system enforces a standardized format for each type of code file. All ‘sequences’ are required to behave following the rules of the parent sequenceSpec class to compile properly, or else they are not loaded when PCP3 starts. In addition to minimizing runtime errors, this approach provides another way to isolate the user from having to deal with repetitive boilerplate code common across many different objects. For example, there is no need to explicitly write logging methods for each sequence, because they already inherit them from the loggerSpec Abstract Base Class. Finally, the main method contains the data structures which hold all of the instantiated objects as well as containing all Menu classes and driving the user interface.
Sphinx Autodocumentation¶
Documentation generated using the sphinx autodoc method.
polychemprint3.commandLineInterface¶
polychemprint3.commandLineInterface.ioElementSpec module¶
Contains ioElementSpec Abstract Base Class.
-
class
polychemprint3.commandLineInterface.ioElementSpec.
ioElementSpec
(name, **kwargs)¶ Bases:
abc.ABC
Specifies the interface for CLI menus/text/etc.
-
io_Operate
()¶ Do the primary purpose of the CLI element.
Returns: an optional flag which either reflects how operation went, or is direction for future CLI operations. Return type: str
-
polychemprint3.commandLineInterface.ioMenuSpec module¶
Contains ioMenuSpec Abstract Base Class.
-
class
polychemprint3.commandLineInterface.ioMenuSpec.
ioMenuSpec
(menuTitle, menuItems, menuDesc='', menuInstruc='Choose from the following menu items:', lastCmd='', memCmd='', **kwargs)¶ Bases:
polychemprint3.commandLineInterface.ioElementSpec.ioElementSpec
,abc.ABC
Specifies the interface for CLI menus.
-
ioMenu_printMenu
(showStoredCmds=True)¶ Prints formatted menu options from menuItems dict.
-
ioMenu_updateStoredCmds
(lastCmd, memCmd)¶ Updates stored commands local to this menu item from inputs.
Parameters: - lastCmd (str) – specifying the last command entered
- memCmd (str) – specifying the command saved to memory
-
io_Operate
()¶ Performs menu operations and loops on user input. :returns: Title of next menu to present. :rtype: str
-
polychemprint3.commandLineInterface.ioTextPanel module¶
Contains ioTextPanelSpec Abstract Base Class.
-
class
polychemprint3.commandLineInterface.ioTextPanel.
ioTextPanel
(panelTitle, fullFilePath, **kwargs)¶ Bases:
polychemprint3.utility.fileHandler.fileHandler
,polychemprint3.commandLineInterface.ioElementSpec.ioElementSpec
Specifies the interface for CLI menus.
-
io_Operate
()¶ Prints formatted text from file.
-
polychemprint3.axes¶
polychemprint3.axes.axes3DSpec module¶
Specifies 3D Axes classes, implementations are for specific printers/stages.
-
class
polychemprint3.axes.axes3DSpec.
Axes3DSpec
(name, __verbose__=0, posMode='absolute', **kwargs)¶ Bases:
polychemprint3.utility.loggerSpec.loggerSpec
,abc.ABC
Abstract Base Class for 3D Axes.
-
activate
()¶ Makes required connections and returns status bool.
Returns: True if ready to use False if not ready Return type: bool
-
deactivate
()¶ Closes communication and returns status bool.
Returns: True if ready to use False if not ready Return type: bool
-
getAbsPosXY
()¶ Gets the current position (absolute) and return XY positions.
Parameters: command (String) – Gcode to write to axes Returns: [X, Y] X and Y positions as strings Return type: String
-
move
(gcodeString)¶ Moves to the specified gcodeString position.
Parameters: gCodeString (String) – Motion command in terms of Gcode G0/G1/G2/G3 supported
-
poll
(command)¶ Sends message to axes and returns response.
Parameters: command (String) – to write to axes Returns: Response from axes Return type: String
-
sendCmd
(command)¶ Writes command to axes device when ready.
Parameters: command (String) – to write to axes
-
setPosMode
(newPosMode)¶ Sets positioning mode to relative or absolute.
Parameters: newPosMode (String) – Positioning mode to use for future move cmds
-
setPosZero
()¶ Sets the current position (absolute) to (0,0,0).
-
polychemprint3.axes.lulzbotTaz6_BP module¶
Implements axes3DSpec for lulzbot taz 6 with modified firmware.
-
class
polychemprint3.axes.lulzbotTaz6_BP.
lulzbotTaz6_BP
(name='LulzbotTaz6', posMode='relative', devAddress='/dev/ttyACM0', baudRate=115200, commsTimeOut=0.001, __verbose__=1, firmwareVers='BP')¶ Bases:
polychemprint3.utility.serialDeviceSpec.serialDeviceSpec
,polychemprint3.axes.axes3DSpec.Axes3DSpec
Implemented interface for Lulzbot Taz 6 with BP modified firmware.
-
activate
()¶ Makes required connections and returns status bool.
Returns: True if ready to use False if not ready Return type: bool
-
deactivate
()¶ Closes communication and returns status bool.
Returns: True if closed succesfully False if failed Return type: bool
-
getAbsPosXY
()¶ Gets the current position (absolute) and return XY positions.
Parameters: command (String) – Gcode to write to axes Returns: [X, Y] X and Y positions as strings Return type: String
-
handShakeSerial
()¶ Perform communications handshake with serial device.
Returns: - [1, “Handshake Successful”] – success occured
- [0, ‘Handshake Failed, Rcvd + message received’] – failure occured
- [-1, “Error (Handshake with Tool Failed + error text”]) – Error received
-
move
(gcodeString)¶ Moves axes by set amount.
Parameters: - gCodeString (String) – Motion command in terms of Gcode G0/G1/G2/G3 supported
- Returns (|) –
- none (|) –
-
poll
(command)¶ Sends message to axes and parses response.
Parameters: command (String) – to write to axes Returns: Response from axes Return type: String
-
readTime
()¶ Reads in from serial device until timeout.
Returns: All text read in, empty string if nothing Return type: String
-
sendCmd
(command)¶ Writes command to axes device when ready.
Parameters: command (String) – to write to axes Returns: Response from axes Return type: String
-
setPosMode
(newPosMode)¶ Sets positioning mode to relative or absolute.
Parameters: newPosMode (String) – Positioning mode to use for future move cmds
-
setPosZero
()¶ Sets current axes position to absolute (0,0,0).
-
startSerial
()¶ Creates pySerial device.
Returns: - [1, “Serial Device Started successfully”] – started succesfully
- [-1, ‘Failed Creating pySerial…’] – could not start
-
stopSerial
()¶ Closes serial devices.
Returns: - [1, “Terminated successfully”] – started succesfully
- [-1, “Error (Serial Device could not be stopped + error text”])
-
waitReady
()¶ Looks for “ok” in input, waits indefinitely.
Returns: All text read in, empty string if nothing Return type: String
-
writeReady
(command)¶ Sends command only after rece0iving ok message.
Parameterscommand, string to write to axesReturnsinp, String read in
-
polychemprint3.axes.nullAxes module¶
Implements axes3DSpec as null axes (returns successful to all).
-
class
polychemprint3.axes.nullAxes.
nullAxes
(name='nullAxes', posMode='relative', __verbose__=0)¶ Bases:
polychemprint3.axes.axes3DSpec.Axes3DSpec
Implementing axes3D for null case.
-
activate
()¶ Makes required connections and returns status bool.
Returns: True if ready to use False if not ready Return type: bool
-
deactivate
()¶ Closes communication and returns status bool.
Returns: True if closed succesfully False if failed Return type: bool
-
getAbsPosXY
()¶ Gets the current position (absolute) and return XY positions.
Parameters: command (String) – Gcode to write to axes Returns: [X, Y] X and Y positions as strings Return type: String
-
move
(gcodeString)¶ Initializes Axes3D object.
Parameters: - gCodeString (String) – Motion command in terms of Gcode G0/G1/G2/G3 supported
- Returns (|) –
- none (|) –
-
poll
(command)¶ Sends message to axes and parses response.
Parameters: command (String) – to write to axes Returns: Response from axes Return type: String
-
sendCmd
(command)¶ Writes command to axes device when ready.
Parameters: command (String) – to write to axes
-
setPosMode
(newPosMode)¶ Sets positioning mode to relative or absolute.
Parameters: newPosMode (String) – Positioning mode to use for future move cmds
-
setPosZero
()¶ Sets current axes position to absolute (0,0,0).
-
polychemprint3.tools¶
polychemprint3.tools.laser6W module¶
Implements the Tool base class for Danny’s arduino-uno controlled 6W LASER.
-
class
polychemprint3.tools.laser6W.
laser6W
(name='BlueLASER6W', units='percent', devAddress='/dev/ttyACM1', baudRate=115200, commsTimeOut=0.001, __verbose__=1, **kwargs)¶ Bases:
polychemprint3.utility.serialDeviceSpec.serialDeviceSpec
,polychemprint3.tools.toolSpec.toolSpec
Implements the Tool base class for Danny’s 6W LASER.
-
activate
()¶ Makes required connections and returns status bool.
Returns: True if ready to use False if not ready Return type: bool
-
checkIfSerialConnectParamsSet
()¶ Goes through connection parameters and sees if all are set.
Returns: True if all parameters are set, false if any unset Return type: bool
-
deactivate
()¶ Closes communication and returns status bool.
Returns: True if deactivated False if not deactivated Return type: bool
-
disengage
()¶ Toggles Dispense off.
Returns: - [1, “Dispense Off”]
- [0, “Error (Dispense already off”])
- [-1, ‘Failed engaging dispense ‘ + inst.__str__()]
-
engage
()¶ Toggles Dispense on.
Returns: - [1, “Dispense On”]
- [0, “Error (Dispense Already On”])
- [-1, ‘Failed engaging dispense ‘ + inst.__str__()]
-
getState
()¶ Returns active state of tool.
ParametersnoneReturns[1, “Tool On”][0, “Tool Off”][-1, “Error: Tool activation state cannot be determined + Error]
-
handShakeSerial
()¶ Perform communications handshake with Tool.
Returns: - [1, “Handshake Successful”]
- [0, ‘Handshake Failed, Received (+ message received’]) – if unexpected input received
- [-1, “Error (Handshake with Tool Failed + error text”])
-
loadLogSelf
(jsonString)¶ loads json log back into dict.
Parameters: jsonString (String) – json string to be loaded back in
-
readTime
()¶ Reads in from serial device until timeout.
Returns: - [1, inp String of all text read in, empty string if nothing]
- [0, ‘Read failed + Error’ if exception caught]
-
setValue
(value)¶ Set Laser PWM value in percent 1-100.
Parameters: value (String) – New value of pressure out of 100 Returns: - [output of writeSerialCommand]
- [-1, “Error (value could not be set for LASER + error text”])
-
startSerial
()¶ Creates and connects pySerial device.
Returns: - [1, “Connected Succesfully to Serial Device”]
- [0, ‘Not all connection parameters set’]
- [-1, “Error (Could not connect to serial device: + error text”])
-
stopSerial
()¶ Terminates communication.
Returns: - [1, “Terminated successfully”]
- [-1, “Error (Tool could not be stopped + error text”])
-
writeLogSelf
()¶ Generates json string containing dict to be written to log file.
Returns: logJson – log in json string format Return type: String
-
polychemprint3.tools.nullTool module¶
Implements the Tool base class for a null Tool [no action, returns true].
-
class
polychemprint3.tools.nullTool.
nullTool
(name='nullTool', units='null', devAddress='unset', baudRate='unset', commsTimeOut=0.5, __verbose__=0, **kwargs)¶ Bases:
polychemprint3.tools.toolSpec.toolSpec
Implements the toolSpec abstract base class for a null tool, a virtual hardware device that only writes to the terminal.
-
activate
()¶ To be called in main.py to load as active tool. Makes required serial connections and returns status as True/False.
Returns: True if tool serial connection made and tool is ready to use False if error generated and tool is not ready for use Return type: bool
-
deactivate
()¶ To be called in main.py to unload as active tool. Closes serial communication and returns status as True/False.
Returns: True if tool serial connection destroyed and tool is succesfully disabled. False if error generated and serial communication could not be suspended. Return type: bool
-
disengage
()¶ Turn tool primary action off (stops dispense/LASER beam off, etc).
Returns: status – First element (int) indicates whether disengage was successful (1), already off (0), or error (-1). Second element (String) provides text explanation.
Return type: two-element list
-
engage
()¶ Turn tool primary action on (dispense/LASER beam on, etc).
Returns: status – First element (int) indicates whether engage was successful (1), already on (0) or error (-1) Second element (String) provides text explanation.
Return type: two-element list
-
getState
()¶ Returns the current dispense/action state (on/off).
Returns: status – First element indicates whether tool is on(1) or off(0) or error(-1). Second element provides text explanation.
Return type: two-element list
-
loadLogSelf
(yamlString)¶ loads json log back into dict.
Parameters: yamlString (String) – yaml string to be loaded back in
-
setValue
(value)¶ Set the primary tool action value (e.g., Laser power, extruder pressure, etc.).
Parameters: value (String) – The new value of the parameter as a string, expressed at arbitrary precision/ without leading zeros. Conversion to hardware specific format occurs internally. e.g., (use 23.456 NOT 0234”) Returns: status – First element (int) indicates whether value setting was successful (1) or error (-1). Second element provides text explanation.
Return type: two-element list
-
writeLogSelf
()¶ Generates yaml string containing dict to be written to log file.
Returns: logyaml – log in yaml string format Return type: String
-
polychemprint3.tools.toolSpec module¶
Contains toolSpec Abstract Base Class.
-
class
polychemprint3.tools.toolSpec.
toolSpec
(name, units, __verbose__, **kwargs)¶ Bases:
polychemprint3.utility.loggerSpec.loggerSpec
,abc.ABC
Abstract Base Class for all dispensing/writing tool drivers.
-
activate
()¶ To be called in main.py to load as active tool. Makes required serial connections and returns status as True/False.
Returns: True if tool serial connection made and tool is ready to use False if error generated and tool is not ready for use Return type: bool
-
deactivate
()¶ To be called in main.py to unload as active tool. Closes serial communication and returns status as True/False.
Returns: True if tool serial connection destroyed and tool disabled. False if error generated and serial communication not suspended. Return type: bool
-
disengage
()¶ Turn tool primary action off (stops dispense/LASER beam off, etc).
Returns: status – First element (int) indicates whether disengage was successful (1), already off (0), or error (-1). Second element (String) provides text explanation. Return type: two-element list
-
engage
()¶ Turn tool primary action on (dispense/LASER beam on, etc).
Returns: status – First element (int) indicates whether engage was successful (1), already on (0) or error (-1) Second element (String) provides text explanation. Return type: two-element list
-
getState
()¶ Returns the current dispense/action state (on/off).
Returns: status – First element indicates whether tool is on(1), off(0) or error(-1). Second element provides text explanation. Return type: two-element list
-
loadLogSelf
(yamlString)¶ Loads yaml log back into __dict__.
Parameters: yamlString (String) – yaml string to be loaded back in
-
setValue
(value)¶ Set the primary tool action value (e.g., Laser power, extruder pressure, etc.).
Parameters: value (String) – The new value of the parameter as a string, expressed at arbitrary precision/ without leading zeros. Conversion to hardware specific format occurs internally. e.g., (use 23.456 NOT 0234”) Returns: status – First element (int) indicates whether value setting was successful (1) or error (-1). Second element provides text explanation. Return type: two-element list
-
writeLogSelf
()¶ Generates yaml string containing __dict__ to be written to log file.
Returns: log in yaml string format Return type: String
-
polychemprint3.tools.ultimusExtruder module¶
Implements the Tool base class for Nordson EFD Ultimus V Extruder.
-
class
polychemprint3.tools.ultimusExtruder.
ultimusExtruder
(name='T_UltimusExtruder', units='kPa', devAddress='/dev/ttyS0', baudRate=115200, commsTimeOut=0.1, __verbose__=1, **kwargs)¶ Bases:
polychemprint3.utility.serialDeviceSpec.serialDeviceSpec
,polychemprint3.tools.toolSpec.toolSpec
Implements the toolSpec abstract base class for the Nordson EFD Ultimus V Extruder.
-
activate
()¶ To be called in main.py to load as active tool. Makes required serial connections and returns status as True/False.
Returns: True if tool serial connection made and tool is ready to use False if error generated and tool is not ready for use Return type: bool
-
calc_checkSum
(checkString)¶ Calculates checksum and returns as string of length 2.
Logic: subtract hex value from 0 and output least significant byte | Parameters | checkString, string to compute checksum from
ReturnsCapitalized hex string of length 2
-
checkIfSerialConnectParamsSet
()¶ Goes through connection parameters and sees if all are set.
Returns: True if all parameters are set, false if any unset Return type: bool
-
deactivate
()¶ To be called in main.py to unload as active tool. Closes serial communication and returns status as True/False.
Returns: True if tool serial connection destroyed and tool is succesfully disabled. False if error generated and serial communication could not be suspended. Return type: bool
-
decToHex
(num, bits)¶ Converts number from decimal to 2s compliment hexadecimal.
Logic: subtract hex value from 0 and output least significant byte :param num: decimal number to convert :type num: int :param bits: number of bits [python int = 32 bits] :type bits: int
Returns: number in 2s compliment hexadecimal Return type: String
-
disengage
()¶ Turn tool primary action off (stops dispense/LASER beam off, etc).
Returns: status – First element (int) indicates whether disengage was successful (1), already off (0), or error (-1). Second element (String) provides text explanation.
Return type: two-element list
-
engage
()¶ Turn tool primary action on (dispense/LASER beam on, etc).
Returns: status – First element (int) indicates whether engage was successful (1), already on (0) or error (-1) Second element (String) provides text explanation.
Return type: two-element list
-
getState
()¶ Returns active state of tool.
ParametersnoneReturns[1, “Tool On”][0, “Tool Off”][-1, “Error: Tool activation state cannot be determined + Error]
-
handShakeSerial
()¶ Perform communications handshake with Tool.
Returns: - [1, “Handshake Successful”]
- [0, ‘Handshake Failed, Received (+ message received’]) – if unexpected input received
- [-1, “Error (Handshake with Tool Failed + error text”])
-
loadLogSelf
(jsonString)¶ loads json log back into dict.
Parameters: jsonString (String) – json string to be loaded back in
-
pack
(cmdString)¶ Packages a command packet.
Proper syntax of command packet: STX + DataString + Checksum + ETXDatastring = NumBytes + CommandName + Command DataParameters: cmdString (String) – input command string, first 4 char are cmdName, rest are data Returns: packaged command string to send to extruder Return type: String
-
pressureRecode
(presStr)¶ Converts string from user-readible value to the 4 char format of the Ultimus Extruder.
Parameters: presStr (String) – Pressure value to transmit as a string of arbitrary precision and length. Returns: presRft – Pressure value reformatted as 4 char sequence expected by Ultimus Extruder Return type: String
-
readTime
(timeout)¶ Reads in from serial device until timeout.
Returns: - [1, inp String of all text read in, empty string if nothing]
- [0, ‘Read failed + Error’ if exception caught]
-
setValue
(pressureVal)¶ Set the extruder output pressure
Parameters: pressureVal (String) – The new value of the pressure as a string, expressed at arbitrary precision/ without leading zeros. Conversion to hardware specific format occurs internally. e.g., (use 23.456 NOT 0234”) Returns: status – First element (int) indicates whether value setting was successful (1) or error (-1). Second element provides text explanation.
Return type: two-element list
-
startSerial
()¶ Creates and connects pySerial device.
Returns: - [1, “Connected Successfully to Serial Device”]
- [0, ‘Not all connection parameters set’]
- [-1, “Error (Could not connect to serial device: + error text”])
-
stopSerial
()¶ Terminates communication.
Returns: - [1, “Terminated successfully”]
- [-1, “Error (Tool could not be stopped + error text”])
-
unpack
(packetIn)¶ Unpacks a command packet for cmd name and value.
Parameters: packetIn (String) – data packet from extruder - STX + DataString + Checksum + ETX Returns: - String (cmdName) – command name
- String (cmdVal) – command value [can be empty string]
-
writeLogSelf
()¶ Generates json string containing dict to be written to log file.
Returns: logJson – log in json string format Return type: String
-
writeSerialCommand
(cmdString)¶ Writes dlcommand to serial device.
Parameters: cmdString – the string to send Returns: - [1, ‘Command Sent (’ + cmdString + ‘Received: ‘ + rcvd])
- [0, “Error sending cmd (” + self.name + ‘ : ‘ + Error’]) – if exception
-
polychemprint3.recipes¶
polychemprint3.recipes.recipe module¶
Specifies modular recipe protocol to link series of sequences
-
class
polychemprint3.recipes.recipe.
recipe
(name: str = 'NoRecipeNameSet', description: str = 'NoRecipeDescriptionSet', dateCreated: str = 'NoDateSet', axes: <module 'polychemprint3.axes.axes3DSpec' from '/home/docs/checkouts/readthedocs.org/user_builds/polychemprint3/checkouts/dev/polychemprint3/axes/axes3DSpec.py'> = <polychemprint3.axes.nullAxes.nullAxes object>, tool: polychemprint3.tools.toolSpec.toolSpec = <polychemprint3.tools.nullTool.nullTool object>, seqList=None, __verbose__: bool = 0, **kwargs)¶ Bases:
polychemprint3.utility.fileHandler.fileHandler
,polychemprint3.utility.loggerSpec.loggerSpec
Class for recipes - a series of sequences joined together
-
addSeq
(beforeIndex: int, newSeq: polychemprint3.sequence.sequenceSpec.sequenceSpec)¶ Adds a copy of the provided sequence to the seqList. :param beforeIndex: :type beforeIndex: int :param newSeq: :type newSeq: sequenceSpec
-
deleteSeq
(index: int)¶ Adds a copy of the provided sequence to the seqList. :param index: :type index: int
-
genRecipe
()¶ Loads print sequence into a list into cmdList attribute.
Returns: whether successfully reached the end or not Return type: bool
-
loadLogSelf
(logString)¶ loads log back into dict.
Parameters: logString (String) – log string to be loaded back in
-
operateRecipe
(axesIn, toolIn)¶ Performs print sequence. :returns: Whether recipe successfully completed or not :rtype: bool
-
reorderSeq
(currentIndex: int, newIndex: int)¶ Moves sequence from currentIndex to newIndex in seqList. :param currentIndex: :type currentIndex: int :param newIndex: :type newIndex: int
-
writeLogSelf
()¶ Generates log string containing dict to be written to log file.
Returns: log in string format Return type: String
-
-
class
polychemprint3.recipes.recipe.
recipeStub
(name: str = 'NoRecipeNameSet', description: str = 'NoRecipeDescriptionSet', dateCreated: str = 'NoDateSet', **kwargs)¶ Bases:
polychemprint3.utility.fileHandler.fileHandler
Class for recipe stubs, just the name, description, path info
polychemprint3.sequence¶
polychemprint3.sequence.sequenceSpec module¶
Specifies modular pre-written motion and dispense sequences for common prints.
-
class
polychemprint3.sequence.sequenceSpec.
seqParam
(name, value, unit, helpString)¶ Bases:
object
Base Class for parameters used in sequences.
-
class
polychemprint3.sequence.sequenceSpec.
sequenceSpec
(axes: polychemprint3.axes.axes3DSpec.Axes3DSpec = <polychemprint3.axes.nullAxes.nullAxes object>, tool: polychemprint3.tools.toolSpec.toolSpec = <polychemprint3.tools.nullTool.nullTool object>, dictParams: dict = None, __verbose__: bool = 0, tool2: polychemprint3.tools.toolSpec.toolSpec = <polychemprint3.tools.nullTool.nullTool object>, tool3: polychemprint3.tools.toolSpec.toolSpec = <polychemprint3.tools.nullTool.nullTool object>, **kwargs)¶ Bases:
polychemprint3.utility.loggerSpec.loggerSpec
,abc.ABC
Abstract Base Class for predefined print sequences.
-
genSequence
()¶ Loads print sequence into a list into cmdList attribute.
Returns: whether successfully reached the end or not Return type: bool
-
loadLogSelf
(logString)¶ loads log back into dict.
Parameters: logString (String) – log string to be loaded back in
-
operateSeq
(**kwargs)¶ Performs print sequence. :returns: Whether sequence successfully completed or not :rtype: bool
-
updateParams
()¶
-
writeLogSelf
()¶ Generates log string containing dict to be written to log file.
Returns: log in string format Return type: String
-
polychemprint3.sequence.basicMove module¶
Moves Axes a set distance in X,Y,Z at set speed
-
class
polychemprint3.sequence.basicMove.
basicMove
(axes: <module 'polychemprint3.axes.axes3DSpec' from '/home/docs/checkouts/readthedocs.org/user_builds/polychemprint3/checkouts/dev/polychemprint3/axes/axes3DSpec.py'> = <polychemprint3.axes.nullAxes.nullAxes object>, tool: polychemprint3.tools.toolSpec.toolSpec = <polychemprint3.tools.nullTool.nullTool object>, **kwargs)¶ Bases:
polychemprint3.sequence.sequenceSpec.sequenceSpec
Sequence for a basic translation in a given direction
-
genSequence
()¶ Loads print sequence into a list into cmdList attribute.
Returns: Whether Command Generation Sequence reaches the end or not. Return type: bool
-
loadLogSelf
(logString)¶ loads log back into dict.
Parameters: logString (String) – log string to be loaded back in
-
writeLogSelf
()¶ Generates log string containing dict to be written to log file.
Returns: log in string format Return type: String
-
polychemprint3.sequence.pause module¶
Sequence for introducing a pause. The length of time can be set, or it can resume on user input.
-
class
polychemprint3.sequence.pause.
pause
(axes: polychemprint3.axes.axes3DSpec.Axes3DSpec = <polychemprint3.axes.nullAxes.nullAxes object>, tool: polychemprint3.tools.toolSpec.toolSpec = <polychemprint3.tools.nullTool.nullTool object>, **kwargs)¶ Bases:
polychemprint3.sequence.sequenceSpec.sequenceSpec
Sequence for introducing a pause. The length of time can be set, or it can resume on user input.
-
genSequence
()¶ Loads print sequence into a list into cmdList attribute.
Returns: whether successfully reached the end or not Return type: bool
-
loadLogSelf
(logString)¶ loads log back into dict.
Parameters: logString (String) – log string to be loaded back in
-
writeLogSelf
()¶ Generates log string containing dict to be written to log file.
Returns: log in string format Return type: String
-
polychemprint3.sequence.setToolState module¶
Sequence for changing tool value or dispense state.
-
class
polychemprint3.sequence.setToolState.
setToolState
(axes: polychemprint3.axes.axes3DSpec.Axes3DSpec = <polychemprint3.axes.nullAxes.nullAxes object>, tool: polychemprint3.tools.toolSpec.toolSpec = <polychemprint3.tools.nullTool.nullTool object>, **kwargs)¶ Bases:
polychemprint3.sequence.sequenceSpec.sequenceSpec
Sequence for changing tool value or dispense state.
-
genSequence
()¶ Loads print sequence into a list into cmdList attribute.
Returns: whether successfully reached the end or not Return type: bool
-
loadLogSelf
(logString)¶ loads log back into dict.
Parameters: logString (String) – log string to be loaded back in
-
writeLogSelf
()¶ Generates log string containing dict to be written to log file.
Returns: log in string format Return type: String
-
polychemprint3.sequence.gapLine module¶
Predefined print sequence for gapLines.
-
class
polychemprint3.sequence.gapLine.
gapLine
(axes: <module 'polychemprint3.axes.axes3DSpec' from '/home/docs/checkouts/readthedocs.org/user_builds/polychemprint3/checkouts/dev/polychemprint3/axes/axes3DSpec.py'> = <polychemprint3.axes.nullAxes.nullAxes object>, tool: polychemprint3.tools.toolSpec.toolSpec = <polychemprint3.tools.nullTool.nullTool object>, **kwargs)¶ Bases:
polychemprint3.sequence.sequenceSpec.sequenceSpec
Implemented print sequence for gapLines.
-
genSequence
()¶ Generates the list of python commands to execute for this sequence (shape).
Returns: whether successfully reached the end or not Return type: bool
-
loadLogSelf
(logString)¶ loads log back into dict.
Parameters: logString (String) – log string to be loaded back in
-
writeLogSelf
()¶ Generates log string containing dict to be written to log file.
Returns: log in string format Return type: String
-
polychemprint3.sequence.line module¶
While dispensing, moves axes a set distance in X,Y,Z at set speed
-
class
polychemprint3.sequence.line.
line
(axes: polychemprint3.axes.axes3DSpec.Axes3DSpec = <polychemprint3.axes.nullAxes.nullAxes object>, tool: polychemprint3.tools.toolSpec.toolSpec = <polychemprint3.tools.nullTool.nullTool object>, **kwargs)¶ Bases:
polychemprint3.sequence.sequenceSpec.sequenceSpec
Implemented print sequence for single lines.
-
genSequence
()¶ Loads print sequence into a list into cmdList attribute.
Returns: whether successfully reached the end or not Return type: bool
-
loadLogSelf
(logString)¶ loads log back into dict.
Parameters: logString (String) – log string to be loaded back in
-
writeLogSelf
()¶ Generates log string containing dict to be written to log file.
Returns: log in string format Return type: String
-
polychemprint3.sequence.circle module¶
polychemprint3.sequence.cuboid module¶
3D Cuboid with base along the XY axes
-
class
polychemprint3.sequence.cuboid.
cuboid
(axes: polychemprint3.axes.axes3DSpec.Axes3DSpec = <polychemprint3.axes.nullAxes.nullAxes object>, tool: polychemprint3.tools.toolSpec.toolSpec = <polychemprint3.tools.nullTool.nullTool object>, **kwargs)¶ Bases:
polychemprint3.sequence.sequenceSpec.sequenceSpec
3D Cuboid with base along the XY axes
-
genSequence
()¶ Loads print sequence into a list into cmdList attribute.
Returns: whether successfully reached the end or not Return type: bool
-
loadLogSelf
(logString)¶ loads log back into dict.
Parameters: logString (String) – log string to be loaded back in
-
writeLogSelf
()¶ Generates log string containing dict to be written to log file.
Returns: log in string format Return type: String
-
polychemprint3.sequence.pyramid module¶
3D Pyramid with base along XY axes.
-
class
polychemprint3.sequence.pyramid.
pyramid
(axes: polychemprint3.axes.axes3DSpec.Axes3DSpec = <polychemprint3.axes.nullAxes.nullAxes object>, tool: polychemprint3.tools.toolSpec.toolSpec = <polychemprint3.tools.nullTool.nullTool object>, **kwargs)¶ Bases:
polychemprint3.sequence.sequenceSpec.sequenceSpec
Implemented print sequence for circle.
-
genSequence
()¶ Loads print sequence into a list into cmdList attribute.
Returns: whether successfully reached the end or not Return type: bool
-
loadLogSelf
(logString)¶ loads log back into dict.
Parameters: logString (String) – log string to be loaded back in
-
writeLogSelf
()¶ Generates log string containing dict to be written to log file.
Returns: log in string format Return type: String
-
polychemprint3.sequence.rectangle module¶
2D Rectangle along the XY axes
-
class
polychemprint3.sequence.rectangle.
rectangle
(axes: polychemprint3.axes.axes3DSpec.Axes3DSpec = <polychemprint3.axes.nullAxes.nullAxes object>, tool: polychemprint3.tools.toolSpec.toolSpec = <polychemprint3.tools.nullTool.nullTool object>, **kwargs)¶ Bases:
polychemprint3.sequence.sequenceSpec.sequenceSpec
Implemented print sequence for rectangle.
-
genSequence
()¶ Loads print sequence into a list into cmdList attribute.
Returns: whether successfully reached the end or not Return type: bool
-
loadLogSelf
(logString)¶ loads log back into dict.
Parameters: logString (String) – log string to be loaded back in
-
writeLogSelf
()¶ Generates log string containing dict to be written to log file.
Returns: log in string format Return type: String
-
polychemprint3.sequence.triangle module¶
polychemprint3.sequence.plate module¶
Predefined print sequence for plates.
-
class
polychemprint3.sequence.plate.
plate
(axes: polychemprint3.axes.axes3DSpec.Axes3DSpec = <polychemprint3.axes.nullAxes.nullAxes object>, tool: polychemprint3.tools.toolSpec.toolSpec = <polychemprint3.tools.nullTool.nullTool object>, **kwargs)¶ Bases:
polychemprint3.sequence.sequenceSpec.sequenceSpec
Implemented print sequence for plates.
-
genSequence
()¶ Loads print sequence into a list into cmdList attribute.
Returns: whether successfully reached the end or not Return type: bool
-
loadLogSelf
(logString)¶ loads log back into dict.
Parameters: logString (String) – log string to be loaded back in
-
writeLogSelf
()¶ Generates log string containing dict to be written to log file.
Returns: log in string format Return type: String
-
polychemprint3.sequence.GCodeFileInkscape module¶
Parameterized code for reading in a gcode file and reprocessing for PCP3
-
class
polychemprint3.sequence.GCodeFileInkscape.
GCodeFileInkscape
(axes: polychemprint3.axes.axes3DSpec.Axes3DSpec = <polychemprint3.axes.nullAxes.nullAxes object>, tool: polychemprint3.tools.toolSpec.toolSpec = <polychemprint3.tools.nullTool.nullTool object>, **kwargs)¶ Bases:
polychemprint3.sequence.sequenceSpec.sequenceSpec
Sequence template for importing GCODE motion commands and tool triggers into PCP Recipe framework
-
genSequence
()¶ Loads print sequence into a list into cmdList attribute.
Returns: Whether successfully reached the end or not. Return type: bool
-
importFromGFile
()¶ Attempts to read line by line from GcodeFile at GCodeFilePath and return the read lines as a list.
Returns: - bool – True if read from file without an error.
- list of str – A list containing each line read in as a separate str element.
-
insertToolCode
(procGlines)¶ Augments procGlines with tool on/off/trv values based on the z-carriage height.
Returns: fullLines – The combined list of Gcode and tool commands. Return type: list of str
-
loadLogSelf
(logString)¶ loads log back into dict.
Parameters: logString (String) – log string to be loaded back in
-
processGCode
(GLines)¶ Parses each line in Glines to remove unusable commands and reconstitutes motion, feed strings with the rates the user provides in the CLI.
Returns: procGlines – A list of GCode lines processed to remove garbage and include user-specified feeds, z height. Return type: list of str
-
writeLogSelf
()¶ Generates log string containing dict to be written to log file.
Returns: log in string format Return type: String
-
polychemprint3.sequence.GCodeFile3DSlicer module¶
Parameterized code for reading in a gcode file for 3D printing and reprocessing for PCP3
-
class
polychemprint3.sequence.GCodeFile3DSlicer.
GCodeFile3DSlicer
(axes: polychemprint3.axes.axes3DSpec.Axes3DSpec = <polychemprint3.axes.nullAxes.nullAxes object>, tool: polychemprint3.tools.toolSpec.toolSpec = <polychemprint3.tools.nullTool.nullTool object>, **kwargs)¶ Bases:
polychemprint3.sequence.sequenceSpec.sequenceSpec
Sequence template for importing 3D GCODE motion commands and tool triggers into PCP Recipe framework
-
genSequence
()¶ Loads print sequence into a list into cmdList attribute.
Returns: whether successfully reached the end or not Return type: bool
-
importFromGFile
()¶ Attempts to read line by line from GcodeFile at GCodeFilePath into memory
-
insertToolCode
(procGlines)¶
-
loadLogSelf
(logString)¶ loads log back into dict.
Parameters: logString (String) – log string to be loaded back in
-
processGCode
(GLines)¶ Attempts to filter line by line from GLines to remove garbage and substitute values
-
writeLogSelf
()¶ Generates log string containing dict to be written to log file.
Returns: log in string format Return type: String
-
polychemprint3.utility¶
polychemprint3.utility.fileHandler module¶
Specifies interface for classes that will handle rw ‘data’ files.
-
class
polychemprint3.utility.fileHandler.
fileHandler
(fullFilePath=None, **kwargs)¶ Bases:
object
Class for objects that can read/write to file
-
appendToFile
(outString)¶ Appends to file with new content from outString.
Parameters: outString (String) – the string to write to the file Returns: True/False if writing passes/fails + errors Return type: bool
-
overWriteToFile
(outString)¶ Completely overwrites file with new content from outString.
Parameters: outString (String) – the string to write to the file Returns: True/False if writing passes/fails + errors Return type: bool
-
peekFile
(numLines)¶ Reads numLines from file and returns.
Parameters: numLines (int) – number of lines to read in from file Returns: - bool – True/ False if read successful
- [lines] – array of strings read in or [“Failed”]
-
readFullFile
()¶ Reads the entire file into memory as a list of strings.
Returns: - bool – True/False if read passes/fails + errors
- [lines] – array of strings read in or [“Failed”]
-
testFileIO
(modeString)¶ Tests if file can be opened and closed.
Parameters: modeString (String) – mode with which to open file (“r,w,r+,a”) Returns: True/False if test passes/fails + errors Return type: bool
-
polychemprint3.utility.loggerSpec module¶
Specifies interface for all classes to read/write themselves to string.
-
class
polychemprint3.utility.loggerSpec.
loggerSpec
(**kwargs)¶ Bases:
abc.ABC
Abstract Base Class for objects that can generate log strings.
-
loadLogSelf
(yamlString)¶ loads yaml log back into dict.
Parameters: yamlString (String) – yaml string to be loaded back in
-
writeLogSelf
()¶ Generates yaml string containing dict to be written to log file.
Returns: log in yaml string format Return type: String
-
polychemprint3.utility.serialDeviceSpec module¶
Interface for all Serial Device objects (extruders/lasers/axes/etc).
-
class
polychemprint3.utility.serialDeviceSpec.
serialDeviceSpec
(devAddress, baudRate, commsTimeOut, **kwargs)¶ Bases:
abc.ABC
Abstract Base Class for all objects using serial device.
-
checkIfSerialConnectParamsSet
()¶ Goes through connection parameters and sees if all are set.
Returns: True if all parameters are set, false if any unset Return type: bool
-
handShakeSerial
()¶ Perform communications handshake with serial device.
Returns: - [1, “Handshake Successful”] – success occured
- [0, ‘Handshake Failed, Rcvd + message received’] – failure occured
- [-1, “Error (Handshake with Tool Failed + error text”]) – Error received
-
readTime
()¶ Reads in from serial device until timeout.
Returns: All text read in, empty string if nothing Return type: String
-
startSerial
()¶ Creates pySerial device.
Returns: - [1, “Terminated successfully”] – started succesfully
- [-1, “Error (error text”]) – could not start
-
stopSerial
()¶ Terminates communication.
Returns: - [1, “Terminated successfully”] – started succesfully
- [-1, “Error (Serial Device could not be stopped + error text”]) – could not start
-