Warning This repository is no longer maintained. The functionalities have been moved to Tweaker-3 for the REST API and to Octoprint-PrePrintService for a RESTful Tweaker and Slicer endpoint for the OctoPrint platform.
This service supports your 3D printing workflow by utilizing auto-rotation and slicing functionality.
The PrePrint Service is based on:
The full workflow can be deployed either on a single machine or on two separated nodes as described below:
The following steps will be done:
- Open the basic API of the PrePrint Service or a server GUI that uses it and submit a model file.
- The model will be auto-rotated for a proper 3D print by the Tweaker-3 software.
- The optimized model will be sliced using Slic3r.
- The final machine code will be sent back to the requester.
- The printing can be started.
Each step can be adjusted as described in the settings.
- A server node with at least 2GHz CPU frequency.
- Optional: Install Docker version 1.10.0+ and Docker Compose version 1.6.0+ on the more powerful node.
If you don't want to install docker right now, follow run:
cd preprintservice_src
pip install -r requirements.txt
git clone https://github.com/ChristophSchranz/Tweaker-3
python3 tweak-service.py
In order to make the service highly available, it is recommended to deploy the PrePrint Service in docker. If you are not familiar with docker yet, have a quick look at the links in the requirements-section.
Then run the application locally with:
https://github.com/ChristophSchranz/Pre-Print-Service
cd PrePrintService
docker-compose up --build -d
docker-compose logs -f
Optional: The docker-compose.yml
is also configured to run in a given
docker swarm, just
adapt the config in the file docker-compose.yml
to your setup and run:
docker-compose build
docker-compose push
docker stack deploy --compose-file docker-compose.yml preprintservice
The service is available on localhost:2304/tweak
(from the hosting node),
where a simple UI is provided for testing the PrePrint Service.
Use docker-compose down
to stop the service. (If you ever wish 😉 )
Configure the plugin in the settings and make sure the url for the PrePrint service is correct:
To test the setup, do the following steps:
-
Visit localhost:2304/tweak, select a stl model file and make an extended Tweak (auto-rotation)
without
slicing. The output should be an auto-rotated (binary) STL model. If not, check the logs of the docker-service usingdocker-compose logs -f
in the folder where thedocker-compose.yml
is located. -
Now, do the same
with
slicing, the resulting file should be a gcode file of the model. Else, check the logs of the docker-service usingdocker-compose logs -f
in the same folder.
If you have any troubles in setting this plugin up or tips to improve this instruction, please let me know!
You can use this API to preprocess your models for 3D printing.
import requests
url = "http://localhost:2304/tweak"
model_path = 'preprintservice_src/uploads/model.stl'
profile_path = 'preprintservice_src/profiles/profile_015mm_brim.profile'
output_path = 'gcode_name.gcode'
# Auto-rotate file without slicing
r = requests.post(url, files={'model': open(model_path, 'rb')},
data={"tweak_actions": "tweak"})
# Only slice the model to a gcode
r = requests.post(url, files={'model': open(model_path, 'rb'), 'profile': open(profile_path, 'rb')},
data={"machinecode_name": output_path, "tweak_actions": "slice"})
# Auto-rotate and slice the model file
r = requests.post(url, files={'model': open(model_path, 'rb'), 'profile': open(profile_path, 'rb')},
data={"machinecode_name": output_path, "tweak_actions": "tweak slice"})
print(r.json())
This service, as well as the auto-rotation module Tweaker-3 was developed in my spare time. If you like it, I am very thankful about a cup of coffee from you! :)
Happy Printing!