https://github.com/christophschranz/octoprint-preprintservice
This service supports your 3D printing workflow by providing auto-rotation and slicing functionality.
https://github.com/christophschranz/octoprint-preprintservice
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
○codemeta.json file
-
○.zenodo.json file
-
✓DOI references
Found 2 DOI reference(s) in README -
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (11.8%) to scientific vocabulary
Repository
This service supports your 3D printing workflow by providing auto-rotation and slicing functionality.
Basic Info
- Host: GitHub
- Owner: ChristophSchranz
- License: agpl-3.0
- Language: Python
- Default Branch: master
- Homepage: https://plugins.octoprint.org/plugins/preprintservice/
- Size: 1.3 MB
Statistics
- Stars: 12
- Watchers: 3
- Forks: 6
- Open Issues: 1
- Releases: 0
Metadata Files
README.md
OctoPrint-PrePrintService
OctoPrint-PrePrintService is a powerful solution designed to enhance your 3D printing workflow by automating the orientation and slicing of your 3D models. This service leverages two cutting-edge tools:
For users of the Cura slicer, a similar toolchain can be set up using the OctoPrint Connection and Auto-Orientation plugins.
Workflow in OctoPrint
The workflow can be deployed on a single machine or across two separate nodes as demonstrated below:

The workflow consists of the following steps:
- Upload a model on OctoPrint and click on the
Slicebutton in thefile bar. - The model is auto-oriented for optimal 3D printing by Tweaker-3 software.
- The oriented model is then sliced by Slic3r.
- The final machine code is sent back to the OctoPrint server.
- You can start your print
Each step can be customized by adjusting the settings as described in the documentation.
Demo-Video
Requirements
- A node connected to your 3D printer, referred to as the printer node, such as a Raspberry Pi.
- One server node for pre-processing with at least a 2 GHz CPU frequency. If the printer node is powerful enough, it can handle both tasks.
- Optional: Install Docker version 1.10.0+ and Docker Compose version 1.6.0+ on the server node.
Setup
1. Set up the PrePrintSerivce in Docker
For high availability, it is recommended to deploy the PrePrint-Service in Docker.
Make sure to select the appropriate CPU architecture of the server node in the argument SLIC3R_VERSION for the installation of Slic3r in docker-compose.yml, see here.
To run the application locally, use:
git clone https://github.com/christophschranz/OctoPrint-PrePrintService --recurse-submodules
cd OctoPrint-PrePrintService
docker-compose up --build -d
docker-compose logs -f
The service is available at localhost:2304/tweak (on the server node), where a simple UI and API documentation are provided for testing the PrePrint Service. Use docker-compose down to stop the service.

2. Install the PrePrintService Plugin
Install the PrePrintService Plugin using the Plugin Manager (under Get More with the name PrePrintService Plugin
or manually using the URL on the Printer-Controller
Configure the plugin in the OctoPrint settings, ensuring that the URL for the PrePrint service (docker) is set correctly.
Make also sure to use the correct URL of the Octoprint server and copy and paste the Octoprint API-key that can be found under settings, API.
Save and return to the OctoPrint home UI, click the Slice button on uploaded STL models, and generate printable machine code using this Preprocessing-Plugin. If the small slicing button of the STL files loaded (right of the trash symbol) is deactivated, Octoprint can't reach the PrePrintService.

3. (optional) Install Plugins to visualize models
Plugins to visualize STL models and GCode improve the workflow. Therefore install the GCode Viewer() and Slicer(https://github.com/kennethjiang/OctoPrint-Slicer).
As soon as installed and reloaded, the new Slicer-Tab can be used to load STL-files via the model's slice-button and
sent to the PrePrintService with a Slicing Profile and Output Filename.

Testing
To test the entire setup, follow these steps:
Check if the docker service runs appropriately without errors:
docker-compose logs -fVisit localhost:2304/tweak, select an STL model file and perform an extended Tweak (auto-rotation) without slicing. The output should be an auto-rotated (binary) STL model. If not, check the Docker service logs using
docker-compose logs -fin the directory wheredocker-compose.ymlis located.Repeat the process with slicing enabled. The resulting file should be a G-code file of the model. If not, check the Docker service logs using
docker-compose logs -fin the same folder.Visit the OctoPrint server, click the
Slice-Button for the uploaded STL model in the file bar, and generate printable machine code using this PrePrint-Service Plugin. After a few seconds, a.gcofile should be uploaded. If this doesn't work, start the OctoPrint server using the commandoctoprint serveand monitor the logs withtail -f .octoprint/logs/octoprint.log. The following two lines are expected:2019-04-07 22:28:44,301 - octoprint.plugins.preprintservice - INFO - Connection to PrePrintService on http://192.168.48.81:2304/tweak is ready, status code 200
If the the PrePrint Server can't be reached, you will see this:
2019-04-07 22:27:34,746 - octoprint.plugins.preprintservice - WARNING - Connection to PrePrint Server on http://192.168.48.81:2304/tweak couldn't be established
Make also sure that your selected profile file is correct. An invalid profile would look result in:
2020-02-05 21:20:28,777 - octoprint.plugins.preprintservice - ERROR - Got http error code 500 on request http://192.168.48.48:2304/tweak
2020-02-05 21:20:28,778 - octoprint.plugins.preprintservice - INFO - Couldn't post to http://192.168.48.48:2304/tweak
If you encounter any issues setting up this plugin or have suggestions for improving these instructions, please let us know!
PrePrint-Service API
You can use the API to preprocess your models for 3D printing. The documentation is available when the server is running at http://localhost:2304/api/. To interact with the API in Python, follow the example below:
```python import requests
url = "http://localhost:2304/tweak" modelpath = 'preprintservicesrc/uploads/model.stl' profilepath = 'preprintservicesrc/profiles/profile015mmbrim.profile' outputpath = 'gcodename.gcode'
Auto-rotate file without slicing
r = requests.post(url, files={'model': open(modelpath, 'rb')}, data={"tweakactions": "tweak"})
Only slice the model to a gcode
r = requests.post(url, files={'model': open(modelpath, 'rb'), 'profile': open(profilepath, 'rb')}, data={"machinecodename": outputpath, "tweak_actions": "slice"})
Auto-rotate and slice the model file
r = requests.post(url, files={'model': open(modelpath, 'rb'), 'profile': open(profilepath, 'rb')}, data={"machinecodename": outputpath, "tweakactions": "tweak slice"}) print(r.statuscode) return_object = r.text ```
The resulting object, either a tweaked STL file or a G-code file, is accessible via r.text, which may be several MB in size.
Information on interacting with OctoPrint's API is available here. You can test the file upload API using the following example:
```python import json import requests
OctoPrint's URL using the default port 5000 and the API including the API-key
url = "http://192.168.48.43:5000/api/files/local?apikey=A943AB47727A461XXXXXXXXXXXX" modelpath = 'preprintservicesrc/uploads/model.stl'
Upload a file using OctoPrint's API
r = requests.post(url=url, files={'file': open(modelpath, 'rb')}) print(r.statuscode) print(json.dumps(r.json(), indent=2)) ```
Common issues
docker-composereturns an error about unsupported CPU, e.g.:ERROR: for pre-print-service Cannot create container for service pre-print-service: NanoCPUs can not be set, as your kernel does not support CPU CFS scheduler or the cgroup is not mounted ERROR: Encountered errors while bringing up the project.The reason could be that the container trys to install Slic3r for the wrong CPU architecture. Select an appropriateSLIC3R_VERSIONin theargsfield indocker-compose.yml, i.e.,x64for most servers andarmv7lfor a Raspberry Pi.
Note of the developer
I hope this PrePrintService improves your 3D printing workflow!
When using in academic works please cite:
Schranz, C. (2016). Tweaker - Auto Rotation Module for FDM 3D Printing. https://doi.org/10.13140/RG.2.2.27593.36966
Owner
- Name: Christoph
- Login: ChristophSchranz
- Kind: user
- Location: Salzburg
- Company: Salzburg Research
- Repositories: 25
- Profile: https://github.com/ChristophSchranz
GitHub Events
Total
- Create event: 1
Last Year
- Create event: 1
Dependencies
- Flask ==2.1.3
- numpy ==1.22.0
- requests ==2.26.0
- Flask ==2.1.3
- OctoPrint >=1.8.0
- numpy *
- requests ==2.26.0
- setuptools *
- urllib3 *
- 127.0.0.1 5001/pre-print-service
- python 3.8 build
)