# Python dans la fabrication numérique et l'impression 3D
### Meetup Python Nantes février 2018
#### Arthur Lutz
<img src="http://www.bullhornleadership.com/wp-content/uploads/2017/08/meetup_logo.png" height="50" style="border=0" border="0"/>
<img src="http://www.vizteams.com/wp-content/themes/geoviz/js/timthumb.php?src=http://www.vizteams.com/wp-content/uploads/2013/08/python-logo-master.png&h=280&w=600" height="50"/>
---
![](http://www.pingbase.net/wp-content/uploads/2013/03/LogoPiNG_siteweb2-1.png")
<img src="http://www.pingbase.net/wp-content/uploads/2017/12/AP_pingbase.gif" style="border:0px">
---
## Disclaimer
*~~don't do this at home~~*
*I do this at home*
*not my day job*
---
## Programme
* introduction (vectoriel, commande numérique, etc.)
* conception avec python (inkscape, blender, freecad)
* l'impression 3D (cura, octoprint, printrun)
* la découpe laser (Laserengraver_smoothie)
* *prototypage* electronique (micropython, wipy)
---
# Introduction
<!-- .slide: data-background="https://s3.amazonaws.com/hakim-static/reveal-js/reveal-parallax-1.jpg" -->
---
## Scalable Vector Graphics (SVG)
* dessin vectoriel
![](https://i.imgur.com/F7niQBy.png)
*source [wikipedia](https://fr.wikipedia.org/wiki/Svg)*
---
## Gcode
* http://reprap.org/wiki/Gcode
* https://en.wikipedia.org/wiki/G-code
```gcode
G90 ; use absolute positioning for the XYZ axes
G1 X10 F3600 ; move to the X=10mm position on the bed
G1 X20 F3600 ; move to X=20mm
```
---
## Impression 3D
* dépots par couches de matière
* https://fr.wikipedia.org/wiki/Impression_3D
---
## Extrusion 3D
* retrait par couches de matière
* découpe d'un matériaux
* (par exemple les "foam cutters")
---
## PCBs
![](https://upload.wikimedia.org/wikipedia/commons/thumb/6/67/PCB_design_and_realisation_smt_and_through_hole.png/1024px-PCB_design_and_realisation_smt_and_through_hole.png)
*source: [wikipedia](https://en.wikipedia.org/wiki/PCB)*
---
# Conception
<!-- .slide: data-background="https://farm6.staticflickr.com/5348/8753422259_ffa89f3db0_o_d.jpg" -->
---
# inkscape: de l'image au SVG
*(pas en python)*
```
Ouvrir l'image > Path > Tracebitmat
```
* sans inkscape (en python): https://github.com/flupke/pypotrace
---
# du SVG à la découpe laser
http://fablabo.net/wiki/Raster2Gcode
![](http://fablabo.net/mediawiki/images/thumb/3/3f/Fablabologo.jpg/340px-Fablabologo.jpg)
---
## inkscape & python
* extensions en python (et aussi en perl, ruby, shell)
---
# inkscape: du SVG à la 3D
Paths to OpenSCAD
![](https://cloud.githubusercontent.com/assets/3838734/3856761/e55ecdf2-1efb-11e4-97f8-7c3195fc361d.png)
---
# inkscape : extensions
http://wiki.inkscape.org/wiki/index.php/Extension_repository
* ImprovedGears
* InkscapeLasertcutBox
* Gcode tools (inclus dans inkscape)
---
# blender & python
https://docs.blender.org/api/current/
![](https://i.imgur.com/qmw6F7B.png)
---
# freecad & python
* https://freecadweb.org/wiki/Python_scripting_tutorial
* https://www.freecadweb.org/wiki/Scripting_examples
* http://fablabo.net/wiki/D%C3%A9Scripthon
```
View > Panels > Python console
```
---
## Freecad exemple
```python
import Part
doc = FreeCAD.newDocument()
myshape = Part.makeSphere(10)
shapeobj = doc.addObject("Part::Feature",
"MyShape")
shapeobj.Shape = myshape
doc.recompute()
```
---
## Freecad copie d'écran
![](https://i.imgur.com/cAASZJO.png)
---
# openscad & python
https://github.com/SolidCode/SolidPython
![](https://i.imgur.com/c6m1LqA.png)
---
## Autres
* CAD en python http://www.pythonocc.org/
* Broderie en python https://github.com/Embroidermodder/Embroidermodder
* Doodle3D https://www.doodle3d.com/
---
# python & impression 3D
<!-- .slide: data-background="https://farm3.staticflickr.com/2924/13532914554_35825dea7e_k_d.jpg" -->
---
## Printrun
http://www.pronterface.com/
![](http://www.pronterface.com/images/pronterface-pronsole-printcore.jpg)
---
## Cura
https://ultimaker.com/en/products/ultimaker-cura-software
![](https://d3v5bfco3dani2.cloudfront.net/img/products/thumbs/Cura-Software.jpg)
---
## Cura - sous le capot
- [Uranium](https://github.com/Ultimaker/Uranium) (python3, qt5, numpy, etc)
- [CuraEngine](https://github.com/Ultimaker/CuraEngine) (C++)
- [PySerial](https://github.com/pyserial/pyserial) Only required for USB printing support.
- [python-zeroconf](https://github.com/jstasiak/python-zeroconf) Only required to detect mDNS-enabled printers
---
## Octoprint
![](https://i.imgur.com/weHvTqC.png)
---
### Plugins Python pour Octoprint
* https://plugins.octoprint.org/
* [plugins getting started](http://docs.octoprint.org/en/master/plugins/gettingstarted.html)
* [plugins cookiecutter](https://github.com/OctoPrint/cookiecutter-octoprint-plugin)
```python
import octoprint.plugin
# ...
__plugin_name__ = "My Plugin"
def __plugin_load__():
# whatever you need to do to load your plugin,
# if anything at all
pass
```
---
# (prototypage) éléctronique
<!-- .slide: data-background="https://farm8.staticflickr.com/7370/9087517979_4158422fd4_k_d.jpg" -->
---
## kicad
http://kicad-pcb.org/
![](http://kicad-pcb.org/img/frontpage/kicad_pcbnew.png)
* [scripting dans kicad](https://kicad.mmccoo.com/)
---
## fritzing
http://fritzing.org/
![](http://fritzing.org/static/img/banner-02.png)
fritzing-parts (scripts python) : https://github.com/fritzing/fritzing-parts
---
## fritzing to 3D print
https://github.com/fritzing/fzz2scad
![](https://i.imgur.com/eJFxGNj.png)
---
## micropython
https://micropython.org/
![](https://store.micropython.org/media/products/PYBv1_1.jpg)
---
## micropython - conférences
* [[pyconfr 2015] diapos introduction micropython - Arthur Lutz](http://slides.logilab.fr/2015/pyconfr2015_micropython/#/pyconfr-2015)
* [[pyconfr 2015] video introduction micropython - Arthur Lutz ](http://videos-2015.pycon.fr/116_-_Arthur_Lutz_-_Marre_de_faire_du_C++_sur_une_Arduino_Faites_du_Python_avec_MicroPython_sur_une_PyBoard.html)
* [[pyconfr 2017] Comment débuter avec MicroPython - Hugo Herter (video)](http://pyvideo.org/pycon-fr-2017/comment-debuter-avec-micropython.html "Permalink to Comment débuter avec MicroPython")
---
## wipy
micropython sur ESP avec du wifi
https://pycom.io/
![](https://media.rs-online.com/t_large/F1259531-01.jpg)
---
## micro:bit
http://microbit.org/
![](http://microbit.org/images/microbit-hardware.png)
---
## micro:bit & python
![](http://microbit.org/images/python-editor.png)
https://python-editor-1-0-0.microbit.org/help.html
---
## raspberry pi & python
GPIO !
<img src="https://i.imgur.com/2Vcgh4o.jpg" heigth=100/>
* https://www.raspberrypi.org/documentation/usage/gpio/
* [gpiozero](https://gpiozero.readthedocs.io/)
* [physical computing projects](https://projects.raspberrypi.org/en/projects/physical-computing)
* [python quick reaction game](https://projects.raspberrypi.org/en/projects/python-quick-reaction-game)
---
```python
from gpiozero import LED
from time import sleep
led = LED(17)
while True:
led.on()
sleep(1)
led.off()
sleep(1)
```
---
## Bonus : Mission Pinball Framework
* http://missionpinball.org/
* `pip install mpf`
---
# Fin
## à vous!
### questions / suggestions
Contacts :
* mastodon : [@arthurlutzim@mamot.fr](https://mamot.fr/@arthurlutzim)
* twitter : [@arthurlutzim](https://twitter.com/arthurlutzim)
* https://arthur.lutz.im/
* arthur@lutz.im
{"metaMigratedAt":"2023-06-14T15:42:14.783Z","metaMigratedFrom":"Content","title":"Python dans la fabrication numérique et l'impression 3D","breaks":true,"contributors":"[]"}