Tue, 19 Jan 2021 20:45:09 +0100
updated main files to new github master version
45 | 1 | # PRINTRUN 2.X |
2 | ||
3 | The master branch holds the development of Printrun 2.x. This new version of Printrun supports Python 3 and wxPython 4. All new features and developments should be merged to it. | |
4 | ||
15 | 5 | Printrun consists of printcore, pronsole and pronterface, and a small collection of helpful scripts. |
6 | ||
7 | * printcore.py is a library that makes writing reprap hosts easy | |
8 | * pronsole.py is an interactive command-line host software with tabcompletion goodness | |
9 | * pronterface.py is a graphical host software with the same functionality as pronsole | |
10 | ||
11 | # GETTING PRINTRUN | |
12 | ||
13 | This section suggests using precompiled binaries, this way you get everything bundled into one single package for an easy installation. | |
14 | ||
15 | If you want the newest, shiniest features, you can run Printrun from source using the instructions further down this README. | |
16 | ||
17 | ## Windows | |
18 | ||
19 | A precompiled version is available at http://koti.kapsi.fi/~kliment/printrun/ | |
20 | ||
21 | ## Mac OS X | |
22 | ||
23 | A precompiled version is available at http://koti.kapsi.fi/~kliment/printrun/ | |
24 | ||
45 | 25 | Note for OSX users: if OSX tells you the file is corrupted, you don't need to redownload it. Instead, you need to allow OSX to run unsigned apps. To do this, run |
26 | `sudo spctl --master-disable` | |
27 | ||
28 | ||
15 | 29 | ## Linux |
30 | ### Ubuntu/Debian | |
31 | ||
45 | 32 | There is currently no package for Printrun 2. It must be [run from source](https://github.com/kliment/Printrun/tree/master#running-from-source). |
15 | 33 | |
34 | ### Chrome OS | |
35 | ||
45 | 36 | You can use Printrun via crouton ( https://github.com/dnschneid/crouton ). Assuming you want Ubuntu Trusty, you used probably `sudo sh -e ~/Downloads/crouton -r trusty -t xfce` to install Ubuntu. Fetch and install printrun with the line given above for Ubuntu/Debian. |
15 | 37 | |
38 | By default you have no access to the serial port under Chrome OS crouton, so you cannot connect to your 3D printer. Add yourself to the serial group within the linux environment to fix this | |
39 | ||
40 | `sudo usermod -G serial -a <username>` | |
41 | ||
42 | where `<username>` should be your username. Log out and in to make this group change active and allow communication with your printer. | |
43 | ||
44 | ### Fedora | |
45 | ||
46 | You can install Printrun from official packages. Install the whole package using | |
47 | ||
45 | 48 | `sudo dnf install printrun` |
15 | 49 | |
50 | Or get only apps you need by | |
51 | ||
45 | 52 | `sudo dnf install pronsole` or `pronterface` or `plater` |
15 | 53 | |
45 | 54 | Adding `--enablerepo updates-testing` option to `dnf` might sometimes give you newer packages (but also not very tested). |
15 | 55 | |
56 | ||
57 | ### Archlinux | |
58 | ||
59 | Packages are available in AUR. Just run | |
60 | ||
61 | `yaourt printrun` | |
62 | ||
63 | and enjoy the `pronterface`, `pronsole`, ... commands directly. | |
64 | ||
65 | ## RUNNING FROM SOURCE | |
66 | ||
67 | Run Printrun for source if you want to test out the latest features. | |
68 | ||
69 | ### Dependencies | |
70 | ||
71 | To use pronterface, you need: | |
72 | ||
45 | 73 | * Python 3 (ideally 3.6), |
74 | * pyserial (or python3-serial on ubuntu/debian) | |
75 | * pyreadline (not needed on Linux) | |
76 | * wxPython 4 | |
15 | 77 | * pyglet |
45 | 78 | * appdirs |
15 | 79 | * numpy (for 3D view) |
80 | * pycairo (to use Projector feature) | |
81 | * cairosvg (to use Projector feature) | |
45 | 82 | * dbus (to inhibit sleep on some Linux systems) |
83 | ||
84 | ### Use Python virtual environment | |
85 | ||
86 | Easiest way to run Printrun from source is to create and use a Python [virtual environment](https://docs.python.org/3/tutorial/venv.html). | |
87 | The following section assumes Linux. Please see specific instructions for Windows and macOS X below. | |
88 | ||
89 | **Ubuntu/Debian note:** You might need to install `python3-venv` first. | |
90 | ||
91 | **Note:** wxPython4 doesn't have Linux wheels available from the Python Package Index yet. Find a proper wheel for your distro at [extras.wxpython.org](https://extras.wxpython.org/wxPython4/extras/linux/gtk3/) and substitute the link in the bellow example. You might skip the wheel installation, but that results in compiling wxPython4 from source, which can be time and resource consuming and might fail. | |
15 | 92 | |
93 | ||
45 | 94 | ```console |
95 | $ git clone https://github.com/kliment/Printrun.git # clone the repository | |
96 | $ cd Printrun # change to Printrun directory | |
97 | $ python3 -m venv venv # create an virtual environment | |
98 | $ . venv/bin/activate # activate the virtual environment (notice the space after the dot) | |
99 | (venv) $ python -m pip install https://extras.wxpython.org/wxPython4/extras/linux/gtk3/fedora-27/wxPython-4.0.1-cp36-cp36m-linux_x86_64.whl # replace the link with yours | |
100 | (venv) $ python -m pip install -r requirements.txt # intall the rest of dependencies | |
101 | (venv) $ python pronterface.py # run Pronterface | |
102 | ``` | |
15 | 103 | |
104 | ### Cython-based G-Code parser | |
105 | ||
106 | Printrun default G-Code parser is quite memory hungry, but we also provide a much lighter one which just needs an extra build-time dependency (Cython), plus compiling the extension with: | |
107 | ||
45 | 108 | ```console |
109 | (venv) $ python -m pip install Cython | |
110 | (venv) $ python setup.py build_ext --inplace | |
111 | ``` | |
15 | 112 | |
113 | The warning message | |
114 | ||
115 | WARNING:root:Memory-efficient GCoder implementation unavailable: No module named gcoder_line | |
116 | ||
117 | means that this optimized G-Code parser hasn't been compiled. To get rid of it and benefit from the better implementation, please install Cython and run the command above. | |
118 | ||
45 | 119 | ### Ubuntu/Debian |
120 | ||
121 | The above method is the recommended way to run Printrun 2 from source. However, if you can't find a suitable wxPython4 wheel, or if it fails for other reasons, it could be run without using a python virtual environment. For users of Debian 10 Buster or later and Ubuntu 18.04 Bionic Beaver or later. | |
122 | ||
123 | Install the dependencies: | |
124 | ||
125 | ``` | |
126 | sudo apt install python3-serial python3-numpy cython3 python3-libxml2 python3-gi python3-dbus python3-psutil python3-cairosvg libpython3-dev python3-appdirs python3-wxgtk4.0 | |
127 | ``` | |
128 | ||
129 | ``` | |
130 | sudo apt install python3-pip | |
131 | pip3 install --user pyglet | |
132 | ``` | |
133 | ||
134 | Install git, clone this repository: | |
135 | ``` | |
136 | sudo apt install git | |
137 | git clone https://github.com/kliment/Printrun.git | |
138 | cd Printrun | |
139 | ``` | |
140 | ||
15 | 141 | ### Windows |
142 | ||
45 | 143 | Download and install [Python 3.6](https://www.python.org/downloads/) and follow the **Python virtual environment** section above except use the following to create and activate the virtual environment and install dependencies: |
15 | 144 | |
45 | 145 | ```cmd |
146 | > py -3 -m venv venv | |
147 | > venv\Scripts\activate | |
148 | > python -m pip install -r requirements.txt | |
149 | ``` | |
15 | 150 | |
151 | ||
45 | 152 | ### macOS X |
15 | 153 | |
45 | 154 | Install Python 3, you can use Brew: |
15 | 155 | |
45 | 156 | ```console |
157 | $ brew install python3 | |
158 | ``` | |
15 | 159 | |
45 | 160 | And follow the above **Python virtual environment** section. You don't need to search for wxPython wheel, macOS wheels are available from the Python Package Index. |
15 | 161 | |
162 | ||
163 | # USING PRINTRUN | |
164 | ||
165 | ## USING PRONTERFACE | |
166 | ||
167 | When you're done setting up Printrun, you can start pronterface.py in the directory you unpacked it. | |
168 | Select the port name you are using from the first drop-down, select your baud rate, and hit connect. | |
169 | Load an STL (see the note on skeinforge below) or GCODE file, and you can upload it to SD or print it directly. | |
170 | The "monitor printer" function, when enabled, checks the printer state (temperatures, SD print progress) every 3 seconds. | |
171 | The command box recognizes all pronsole commands, but has no tabcompletion. | |
172 | ||
45 | 173 | If you want to load stl files, you need to install a slicing program such as Slic3r or Skeinforge and add its path to the settings. |
174 | ||
175 | #### Slic3r integration | |
15 | 176 | |
45 | 177 | To invoke Slic3r directly from Pronterface your slicing command (_Settings_ > _Options_ > _External Commands_ > _Slice Command_) should look something like `slic3r $s -o $o`. If Slic3r is properly installed "slic3r" will suffice, otherwise, replace it with the full path to Slic3r's executable. |
178 | ||
179 | If the Slic3r integration option (_Settings_ > _Options_ > _User interface_ > _Enable Slic3r integration_) is checked a new menu will appear after application restart which will allow you to choose among your previously saved Slic3r Print/Filament/Printer settings. | |
15 | 180 | |
181 | ## USING PRONSOLE | |
182 | ||
183 | To use pronsole, you need: | |
184 | ||
45 | 185 | * Python 3 (ideally 3.6), |
186 | * pyserial (or python3-serial on ubuntu/debian) and | |
15 | 187 | * pyreadline (not needed on Linux) |
188 | ||
189 | Start pronsole and you will be greeted with a command prompt. Type help to view the available commands. | |
190 | All commands have internal help, which you can access by typing "help commandname", for example "help connect" | |
191 | ||
192 | If you want to load stl files, you need to put a version of skeinforge (doesn't matter which one) in a folder called "skeinforge". | |
193 | The "skeinforge" folder must be in the same folder as pronsole.py | |
194 | ||
195 | ## USING PRINTCORE | |
196 | ||
45 | 197 | To use printcore you need Python 3 (ideally 3.6) and pyserial (or python3-serial on ubuntu/debian) |
15 | 198 | See pronsole for an example of a full-featured host, the bottom of printcore.py for a simple command-line |
199 | sender, or the following code example: | |
200 | ||
201 | ```python | |
202 | #to send a file of gcode to the printer | |
203 | from printrun.printcore import printcore | |
204 | from printrun import gcoder | |
205 | p=printcore('/dev/ttyUSB0',115200) # or p.printcore('COM3',115200) on Windows | |
206 | gcode=[i.strip() for i in open('filename.gcode')] # or pass in your own array of gcode lines instead of reading from a file | |
207 | gcode = gcoder.LightGCode(gcode) | |
208 | p.startprint(gcode) # this will start a print | |
209 | ||
210 | #If you need to interact with the printer: | |
211 | p.send_now("M105") # this will send M105 immediately, ahead of the rest of the print | |
212 | p.pause() # use these to pause/resume the current print | |
213 | p.resume() | |
214 | p.disconnect() # this is how you disconnect from the printer once you are done. This will also stop running prints. | |
215 | ``` | |
216 | ||
217 | ## PLATERS | |
218 | ||
219 | Printrun provides two platers: a STL plater (```plater.py```) and a G-Code plater (```gcodeplater.py```). | |
220 | ||
221 | ## 3D VIEWER CONTROLS | |
222 | ||
223 | When the 3D viewer is enabled, the controls are the following: | |
224 | - Mousewheel: zoom (Control reduces the zoom change steps) | |
225 | - Shift+mousewheel: explore layers (in print gcode view ; Control key makes layer change by increments of 10 instead of 1) or rotate object (in platers) | |
226 | - Left-click dragging: rotate view | |
227 | - Right-click dragging: pan view | |
228 | - Shift + left-click dragging: move object (in platers) | |
229 | - Page up/down keys: zoom (Control reduces the zoom change steps) | |
230 | - Up/down keys: explore layers | |
231 | - R key: reset view | |
232 | - F key: fit view to display entire print | |
233 | - C key: toggle "display current layer only" mode (in print gcode view) | |
234 | ||
235 | ## RPC SERVER | |
236 | ||
237 | ```pronterface``` and ```pronsole``` start a RPC server, which runs by default | |
238 | on localhost port 7978, which provides print progress information. | |
239 | Here is a sample Python script querying the print status: | |
240 | ||
241 | ```python | |
45 | 242 | import xmlrpc.client |
15 | 243 | |
45 | 244 | rpc = xmlrpc.client.ServerProxy('http://localhost:7978') |
245 | print(rpc.status()) | |
15 | 246 | ``` |
247 | ||
248 | ## CONFIGURATION | |
249 | ||
250 | ### Build dimensions | |
251 | ||
252 | Build dimensions can be specified using the build_dimensions option (which can | |
253 | be graphically edited in Pronterface settings). This option is formed of 9 parameters: | |
254 | 3 for the build volume dimensions, 3 for the build volume coordinate system | |
255 | offset minimum, 3 for the endstop positions. | |
256 | ||
257 | The default value is `200x200x100+0+0+0+0+0+0`, which corresponds to a | |
258 | 200x200mm (width x height) bed with 100mm travel in Z (there are the first | |
259 | three numbers) and no offset. The absolute coordinates system origin (0,0,0) is | |
260 | at the bottom left corner on the bed surface, and the top right corner on the | |
261 | bed surface is (200,200,0). | |
262 | ||
263 | A common practice is to have the origin of the coordinate system (0,0,0) at the | |
264 | center of the bed surface. This is achieved by using the next three parameters, | |
265 | for instance with `200x200x100-100-100+0+0+0+0`. | |
266 | In this case, the bottom left corner of the bed will be at (-100,-100,0) and | |
267 | the top right one at (100,100,0). | |
268 | ||
269 | These two sets of settings should be sufficient for most people. However, for | |
270 | some specific complicated setups and GCodes and some features, we might also | |
271 | need the endstops positions for perfect display. These positions (which are | |
272 | usually 0,0,0, so if you don't know you probably have a standard setup) are | |
273 | specified in absolute coordinates, so if you have your bed starting at | |
274 | (-100,-100,0) and your endstops are 10mm away from the bed left and right and | |
275 | the Z endstop 5mm above the bed, you'll want to set the endstops positions to | |
276 | (-110,-110,5) for this option. | |
277 | ||
278 | ## USING MACROS AND CUSTOM BUTTONS | |
279 | ||
280 | ### Macros in pronsole and pronterface | |
281 | ||
282 | To send simple G-code (or pronsole command) sequence is as simple as entering them one by one in macro definition. | |
283 | If you want to use parameters for your macros, substitute them with {0} {1} {2} ... etc. | |
284 | ||
285 | All macros are saved automatically immediately after being entered. | |
286 | ||
287 | Example 1, simple one-line alias: | |
288 | ||
289 | ```python | |
290 | PC> macro where M114 | |
291 | ``` | |
292 | ||
293 | Instead of having to remember the code to query position, you can query the position: | |
294 | ||
295 | ```python | |
296 | PC> where | |
297 | X:25.00Y:11.43Z:5.11E:0.00 | |
298 | ``` | |
299 | ||
300 | Example 2 - macros to switch between different slicer programs, using "set" command to change options: | |
301 | ||
302 | ```python | |
303 | PC> macro use_slicer | |
304 | Enter macro using indented lines, end with empty line | |
305 | ..> set sliceoptscommand Slic3r/slic3r.exe --load slic3r.ini | |
306 | ..> set slicecommand Slic3r/slic3r.exe $s --load slic3r.ini --output $o | |
307 | Macro 'use_slicer' defined | |
308 | PC> macro use_sfact | |
309 | ..> set sliceoptscommand python skeinforge/skeinforge_application/skeinforge.py | |
310 | ..> set slicecommand python skeinforge/skeinforge_application/skeinforge_utilities/skeinforge_craft.py $s | |
311 | Macro 'use_sfact' defined | |
312 | ``` | |
313 | ||
314 | Example 3, simple parametric macro: | |
315 | ||
316 | ```python | |
317 | PC> macro move_down_by | |
318 | Enter macro using indented lines, end with empty line | |
319 | ..> G91 | |
320 | ..> G1 Z-{0} | |
45 | 321 | ..> G90 |
15 | 322 | ..> |
323 | ``` | |
324 | ||
325 | Invoke the macro to move the printhead down by 5 millimeters: | |
326 | ||
327 | ```python | |
328 | PC> move_down_by 5 | |
329 | ``` | |
330 | ||
331 | For more powerful macro programming, it is possible to use python code escaping using ! symbol in front of macro commands. | |
332 | Note that this python code invocation also works in interactive prompt: | |
333 | ||
334 | ```python | |
45 | 335 | PC> !print("Hello, printer!") |
15 | 336 | Hello printer! |
337 | ||
338 | PC> macro debug_on !self.p.loud = 1 | |
339 | Macro 'debug_on' defined | |
340 | PC> debug_on | |
341 | PC> M114 | |
342 | SENT: M114 | |
343 | X:0.00Y:0.00Z:0.00E:0.00 Count X:0.00Y:0.00Z:0.00 | |
344 | RECV: X:0.00Y:0.00Z:0.00E:0.00 Count X:0.00Y:0.00Z:0.00 | |
345 | RECV: ok | |
346 | ``` | |
347 | ||
348 | You can use macro command itself to create simple self-modify or toggle functionality: | |
349 | ||
350 | Example: swapping two macros to implement toggle: | |
351 | ||
352 | ```python | |
353 | PC> macro toggle_debug_on | |
354 | Enter macro using indented lines, end with empty line | |
355 | ..> !self.p.loud = 1 | |
45 | 356 | ..> !print("Diagnostic information ON") |
15 | 357 | ..> macro toggle_debug toggle_debug_off |
358 | ..> | |
359 | Macro 'toggle_debug_on' defined | |
360 | PC> macro toggle_debug_off | |
361 | Enter macro using indented lines, end with empty line | |
362 | ..> !self.p.loud = 0 | |
45 | 363 | ..> !print("Diagnostic information OFF") |
15 | 364 | ..> macro toggle_debug toggle_debug_on |
365 | ..> | |
366 | Macro 'toggle_debug_off' defined | |
367 | PC> macro toggle_debug toggle_debug_on | |
368 | Macro 'toggle_debug' defined | |
369 | ``` | |
370 | ||
371 | Now, each time we invoke "toggle_debug" macro, it toggles debug information on and off: | |
372 | ||
373 | ```python | |
374 | PC> toggle_debug | |
375 | Diagnostic information ON | |
376 | ||
377 | PC> toggle_debug | |
378 | Diagnostic information OFF | |
379 | ``` | |
380 | ||
381 | When python code (using ! symbol) is used in macros, it is even possible to use blocks/conditionals/loops. | |
382 | It is okay to mix python code with pronsole commands, just keep the python indentation. | |
383 | For example, following macro toggles the diagnostic information similarily to the previous example: | |
384 | ||
385 | ```python | |
386 | !if self.p.loud: | |
387 | !self.p.loud = 0 | |
45 | 388 | !print("Diagnostic information OFF") |
15 | 389 | !else: |
390 | !self.p.loud = 1 | |
45 | 391 | !print("Diagnostic information ON") |
15 | 392 | ``` |
393 | ||
394 | Macro parameters are available in '!'-escaped python code as locally defined list variable: arg[0] arg[1] ... arg[N] | |
395 | ||
396 | All python code is executed in the context of the pronsole (or PronterWindow) object, | |
397 | so it is possible to use all internal variables and methods, which provide great deal of functionality. | |
398 | However the internal variables and methods are not very well documented and may be subject of change, as the program is developed. | |
399 | Therefore it is best to use pronsole commands, which easily contain majority of the functionality that might be needed. | |
400 | ||
401 | Some useful python-mode-only variables: | |
402 | ||
403 | ```python | |
404 | !self.settings - contains all settings, e.g. | |
405 | port (!self.settings.port), baudrate, xy_feedrate, e_feedrate, slicecommand, final_command, build_dimensions | |
406 | You can set them also via pronsole command "set", but you can query the values only via python code. | |
407 | !self.p - printcore object (see USING PRINTCORE section for using printcore object) | |
408 | !self.cur_button - if macro was invoked via custom button, the number of the custom button, e.g. for usage in "button" command | |
409 | !self.gwindow - wx graphical interface object for pronterface (highly risky to use because the GUI implementation details may change a lot between versions) | |
410 | ``` | |
411 | ||
412 | Some useful methods: | |
413 | ||
414 | ```python | |
415 | !self.onecmd - invokes raw command, e.g. | |
416 | !self.onecmd("move x 10") | |
417 | !self.onecmd("!print self.p.loud") | |
418 | !self.onecmd("button "+self.cur_button+" fanOFF /C cyan M107") | |
419 | !self.project - invoke Projector | |
420 | ``` | |
421 | ||
422 | ## USING HOST COMMANDS | |
423 | ||
424 | Pronsole and the console interface in Pronterface accept a number of commands | |
425 | which you can either use directly or inside your G-Code. To run a host command | |
426 | from inside a G-Code, simply prefix it with `;@`. | |
427 | ||
428 | List of available commands: | |
429 | ||
430 | - `pause`: pauses the print until the user resumes it | |
431 | - `run_script scriptname [arg1 ...]`: runs a custom script or program on the | |
432 | host computer. This can for instance be used to produce a sound to warn the | |
433 | user (e.g. `run_script beep -r 2` on machines were the `beep` util is | |
434 | available), or to send an email or text message at the end of a print. The $s | |
435 | token can be used in the arguments to get the current gcode file name | |
436 | - `run_gcode_script scripname [arg1 ...]`: same as `run_script`, except that | |
437 | all lines displayed by the script will be interpreted in turn (so that G-Code | |
438 | lines will be immediately sent to the printer) | |
439 | - `shell pythoncommand`: run a python command (can also be achieved by doing | |
440 | `!pythoncommand`) | |
441 | - `set option value`: sets the value of an option, e.g. `set mainviz 3D` | |
442 | - `connect` | |
443 | - `block_until_online`: wait for the printer to be online. For instance you can | |
444 | do `python pronsole.py -e "connect" -e "block_until_online" -e "upload | |
445 | object.gcode"` to start pronsole, connect for the printer, wait for it to be | |
446 | online to start uploading the `object.gcode` file. | |
447 | - `disconnect` | |
448 | - `load gcodefile` | |
449 | - `upload gcodefile target.g`: upload `gcodefile` to `target.g` on the SD card | |
450 | - `slice stlfile`: slice `stlfile` and load the produced G-Code | |
451 | - `print`: print the currently loaded file | |
452 | - `sdprint target.g`: start a SD print | |
453 | - `ls`: list files on SD card | |
454 | - `eta`: display remaining print time | |
455 | - `gettemp`: get current printer temperatures | |
456 | - `settemp`: set hotend target temperature | |
457 | - `bedtemp`: set bed target temperature | |
458 | - `monitor`: monitor printer progress during a print | |
459 | - `tool K`: switch to tool K | |
460 | - `move xK`: move along `x` axis (works with other axes too) | |
461 | - `extrude length [speed]` | |
462 | - `reverse length [speed]` | |
463 | - `home [axis]` | |
464 | - `off`: turns off fans, motors, extruder, heatbed, power supply | |
465 | - `exit` | |
466 | ||
467 | # LICENSE | |
468 | ||
469 | ``` | |
45 | 470 | Copyright (C) 2011-2020 Kliment Yanev, Guillaume Seguin |
471 | ||
15 | 472 | Printrun is free software: you can redistribute it and/or modify |
473 | it under the terms of the GNU General Public License as published by | |
474 | the Free Software Foundation, either version 3 of the License, or | |
475 | (at your option) any later version. | |
476 | ||
477 | Printrun is distributed in the hope that it will be useful, | |
478 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
479 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
480 | GNU General Public License for more details. | |
481 | ||
482 | You should have received a copy of the GNU General Public License | |
483 | along with Printrun. If not, see <http://www.gnu.org/licenses/>. | |
484 | ``` | |
485 | ||
486 | All scripts should contain this license note, if not, feel free to ask us. Please note that files where it is difficult to state this license note (such as images) are distributed under the same terms. | |
45 | 487 |