I would like to 3D print this image, which I computed in numpy as an array.

My hope is to put this into Blender and export as an STL file to give to my friend at MakerBot.

This is a 2D image but my plan is to thicken the image slightly to have a 3rd dimension.

How do I draw this array in Blender ?


Here are some solutions:


1) export your drawing in Python (numpy) as SVG file (say using MatPlotLib)
2) import SVG file into Blender
3) apply bevel to that

2: In the following however we did it in a different way.

1) We traced your image in Inkscape
2) and exported as SVG file.
3) In blender we just made it mesh and applied extrude.

enter image description here


You could construct geometry based on this data, probably the most straightforward method would be to create a 2D curve with Python.

# These coords are just an example and can be any length.
# They can be from a numpy array or loaded from a file.
coords = [
    (0.1, 0.21),
    (0.4, 0.24),
    (0.6, 0.4),
    (0.7, 0.1),
    (-0.2, -0.3),

import bpy

cu = bpy.data.curves.new(name="MyCurve", type='CURVE')

# setup curve
cu.fill_mode = 'NONE'
cu.extrude = 0.02
cu.bevel_depth = 0.02

# link to scene
ob = bpy.data.objects.new(name="MyObject", object_data=cu)
scene = bpy.context.scene

# fill curve with data
spline = cu.splines.new(type='POLY')
# -1 because we already have a point
spline.points.add(len(coords) - 1)
for i, point in enumerate(spline.points):
    point.co[0:2] = coords[i]

This can be added to the end if you want to convert to a mesh for printing.

# ----------------------------------------
# Optional: Convert to a mesh and cap ends

scene.objects.active = ob
ob.select = True

bpy.ops.object.mode_set(mode='EDIT', toggle=False)
bpy.ops.mesh.fill_holes(sides=0)  # cap ends
bpy.ops.object.mode_set(mode='OBJECT', toggle=False)

Make it white lines on black background. Add a displace modifier to a relative high poly plane mesh and use the image as a height map. Apply the modifier. Cut of the bottom with booleans.

To refine it you can use the Decimate and/or Remesh modifier. Then you should be able to 3D-print it.

Don't be afraid to use a really dense mesh. Slicing a dense mesh might take a little bit longer but that is the only drawback.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.