Top Banner
From Code to Coffee Table with Blender and Sly Matt Meshulam ChiPy 2015-03-12
47

From Code to Coffee Table with Blender and Sly

Jul 18, 2015

Download

Technology

mattmeshulam
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: From Code to Coffee Table with Blender and Sly

From Code to Coffee Table with Blender and Sly

Matt MeshulamChiPy 2015-03-12

Page 2: From Code to Coffee Table with Blender and Sly

About Me

By day - Developer Experience at

Member of Pumping Station: One

Side projects involving electronics, music, woodworking, Python, cooking, visual art

Page 3: From Code to Coffee Table with Blender and Sly

The Metropol Table

Page 4: From Code to Coffee Table with Blender and Sly
Page 5: From Code to Coffee Table with Blender and Sly
Page 7: From Code to Coffee Table with Blender and Sly
Page 8: From Code to Coffee Table with Blender and Sly

Conception

CNC enables novel construction methods that require unique, high precision parts.

Fabrication tools exist, but what about upstream design tools?

I want a new coffee table.

Page 9: From Code to Coffee Table with Blender and Sly

Fabrication Software

● Vectric VCarve - Convert vector images to G-code toolpaths

● ShopBot software - Calibrate axes and run G-code on the ShopBot

G-code (yuck!)

Page 10: From Code to Coffee Table with Blender and Sly

Metropol Parasol, Seville, Spain

Page 11: From Code to Coffee Table with Blender and Sly

Study 1: ShopBotsaurus RexPattern via http://www.instructables.com/id/Build-a-6-0-tall-Wooden-T-Rex-Model/

Page 12: From Code to Coffee Table with Blender and Sly

Study 2: Design composeable parts

Create a 3D model in Blender

Use 123D Make to convert model into fab-able parts

Page 13: From Code to Coffee Table with Blender and Sly

Blender model

Page 14: From Code to Coffee Table with Blender and Sly

123D Make

Page 15: From Code to Coffee Table with Blender and Sly
Page 16: From Code to Coffee Table with Blender and Sly

Autodesk 123D Make

:-)● Free● Designed for CNC

construction● Many cool built-in

features

:-(● Unstable● GUI only● Hard to extend

Page 17: From Code to Coffee Table with Blender and Sly

A better design tool?

● Artistic/exploratory workflow ● Precise and reproducible operations● Output in a useful format (2D vector

shapes)● Aware of physical 3D concepts (e.g.

intersection)

Page 18: From Code to Coffee Table with Blender and Sly

Existing programmatic CAD tools

OpenSCADFreeCADPythonOCCCadquery

Page 19: From Code to Coffee Table with Blender and Sly

Why Blender?

● Intended for artistic uses● Awesome Python API● Large user base● Open source

Page 20: From Code to Coffee Table with Blender and Sly

Why NOT Blender?

● It’s not CAD● Mesh-based● Poor support for physical construction

Page 21: From Code to Coffee Table with Blender and Sly

A Quick Tour of Blender

Page 22: From Code to Coffee Table with Blender and Sly

bpy - Main Blender Python module

Programmatic equivalent of the GUI

Highly imperative - Operations apply to the global selection context

Great for macros/automation, not for complex apps

Page 23: From Code to Coffee Table with Blender and Sly

A bpy operation - No arg for what you’re resizing!

Page 24: From Code to Coffee Table with Blender and Sly

bmesh - Low level mesh interface

Meshes are Python objects

A BMesh object contains:- Vertices- Edges (2 verts)- Faces (3+ verts)

Page 25: From Code to Coffee Table with Blender and Sly

bmesh (cont’d)

Users must ensure mesh consistency

Tightly coupled to C data structures - be careful directly modifying mesh data!

Page 27: From Code to Coffee Table with Blender and Sly

bmesh.ops - BMesh Operations

Most GUI (bpy) ops have underlying BMesh implementations

(Mostly) well documented

Page 28: From Code to Coffee Table with Blender and Sly

bmesh.ops - Example

Page 29: From Code to Coffee Table with Blender and Sly

Blender’s classes for 3D math: Matrix, Vector, etc.

Available as a standalone module

mathutils

Page 30: From Code to Coffee Table with Blender and Sly

Wait, what are we trying to do again?

Page 31: From Code to Coffee Table with Blender and Sly

Wait, what are we trying to do again?

Page 32: From Code to Coffee Table with Blender and Sly

Introducing Sly

A Python library for 3D construction from 2D parts

Uses Blender for I/O, but fairly decoupled

Only ~350 SLoC

Page 33: From Code to Coffee Table with Blender and Sly

Two core concepts

Slice - A 2D polygon (with thickness) positioned in 3D space.

Cut - Material to be removed from a slice so it can interlock with another slice

Page 34: From Code to Coffee Table with Blender and Sly

Let’s see it in action!

Page 35: From Code to Coffee Table with Blender and Sly

Manually sculpted mesh

Page 36: From Code to Coffee Table with Blender and Sly

Mirroring and smoothing - Blender mesh modifiers

Page 37: From Code to Coffee Table with Blender and Sly

Specify slice locations and orientations

Page 38: From Code to Coffee Table with Blender and Sly

Extract slices from selected mesh

Apply an operation to each one

Add slices to vector output and Blender scene

Page 39: From Code to Coffee Table with Blender and Sly

Script generates slices

Page 40: From Code to Coffee Table with Blender and Sly

Rendered slices include cutouts

Page 41: From Code to Coffee Table with Blender and Sly

Generated vectors, manually positioned

Page 42: From Code to Coffee Table with Blender and Sly
Page 43: From Code to Coffee Table with Blender and Sly

Sly implementationExtracting slices from a model:

Page 44: From Code to Coffee Table with Blender and Sly

Sly implementation (cont’d)

Shapely - http://toblerity.org/shapely/● Great polygon library● GIS-focused but general purpose● Support for geometric operations:

intersections, unions, etc.● Slices use Shaply polygons internally

Page 45: From Code to Coffee Table with Blender and Sly

Sly Roadmap

● Installer, tests, docs● Command line operation● Better Blender GUI integration● Smart slice placement● Output to G-code?● Different construction modes?

Page 46: From Code to Coffee Table with Blender and Sly

Want more?

In-depth sessions at PS:1 starting in April, email me to get notified: [email protected]

Contribute on GitHub: github.com/meshulam/sly

Page 47: From Code to Coffee Table with Blender and Sly

Thanks!

Twitter: @mattmeshulam

GitHub: meshulam