Tag Archives: Blender

selection in Blender

I’d wanted to select a certain mesh object and then edit it, but was getting weird errors, like:

RuntimeError: Operator bpy.ops.mesh.select_all.poll() failed, context is incorrect


RuntimeError: Operator bpy.ops.object.mode_set(mode='EDIT').poll() failed, context is incorrect

I couldn’t find my actual initial code, so here’s me trying to replicate it. All I’m doing is selecting the first cube.

my_object = bpy.context.scene.objects['Cube'] = True

>>> RuntimeError: Operator bpy.ops.mesh.select_all.poll() failed, context is incorrect

Turns out I needed to set the object as the active object and deselect any other object. If the originally selected object was in EDIT mode, I needed to toggle to OBJECT mode before toggling back EDIT mode. Otherwise, bpy.ops.object.mode_set(mode='EDIT') will appear finished but actually fail.

other_object = bpy.context.scene.objects['Cube.002'] = False

my_object = bpy.context.scene.objects['Cube'] = True = my_object




Hope this helps!

*My example snippet can replicate the select_all error, if the original object was in EDIT mode, but I can’t seem to reproduce the edit_mode error. However, I haven’t had any problems after deselecting all other objects and toggling to OBJECT mode before any further operations.

Blender 2.72

[Updates on the project here]

3D Print Your Own Glassesglasses shot

I wrote a little script to 3D print your own glasses. You don’t need much modeling skills. Just load up the script in Blender and load up your SVG (scalable vector graphics, like JPG except vector format). It’s going to do the 2D to 3D conversion for you (complete with nose pads) in just a few clicks!

You can play around with all sorts of designs!


*The algorithm has been updated based on actual glasses specs. I’ll write about that later. Below is the original algorithm.

Seth Taylor glasses

I started with the black SVG you see above (made by Seth Taylor).


Since I don’t have any specs, I estimated (based off of my own glasses) that the bridge is about 16% of the entire length of the frame and protrudes out a little bit.

The nosepad area I estimated to be 16% around the bridge, and the midpoint between the bottom of the bridge to the bottom of the frame would be where the bump of the nosepad was.

The entire frame also has a slight blend.


more glasses picsresults!

I think it came out pretty well!

I would probably lessen the bend in the bridge and increase the protrusion of the nosepads.


Download the script from my Github and download Blender. I’m using version 2.70 but any future version should work fine.

If you’re already familiar with Blender, then just load up the script, select your imported SVG, and run!

If you’re not, here are more detailed steps.

opening screen

When you open up Blender, hit Scripting to open up the scripting windows.

scripting windows

Press X on the cube to delete it.

delete cube

Press Open to open up the downloaded script.

open up the script

Load your glasses SVG.

load your SVG

Your SVG might be very small so you’ll have to zoom in a lot to see it (scroll up to zoom).

tiny SVG

With the SVG selected, hit Run.

run run run

Viola! Export your glasses as an STL to print.

print those frames!

Design Notes

The 3D glasses might not be the right size, so you might have to scale it. Also, this script might not work great for thick frames, or really weirdly shaped frames, since I assume symmetry and based the parameters around the thin frame above.

There’s some small tweaks I still gotta do.

Try it out! Let me know.

Software Notes

If you’re code savy, feel free to make pull requests. The project is free/open source under GPLv3+.

So, I’m probably waay late to the party, but I recently discovered MeshMixer.

It’s a neat little software that has tons of features. It’s not a full modeling suite like Blender, but instead focuses on a few 3D printing related tasks.

I tested Meshmixer out by loading up Rakdos (a high polygon mesh), and it loads super fast!

One features it has is the ability to digitally sculpt, much like ZBrush or Sculptris.


Another is mesh repair.


I tried repairing Rakdos, but the result didn’t fix the inverted vertices. I suspect it works fine for simpler meshes, since Rakdos is a known problematic mesh.

Meshmixer also supplies an array of neat analytics.


It can also generate supports.


Based on the settings, I suspect it uses an angle based approach to generate the supports (like, give a support if face is less than 25 degrees off of the X plane.

This may also have been MakerBot’s algorithm in the early days. However, there are more sophisticated support generation algorithms out there, so I’m not overly impressed (FormLabs does a physics simulation in their generation!)


However, I am impressed by its mesh mixing ability. You can very easily combine two meshes together and it joins very smoothly.

It also supposedly has way better boolean combines than Blender.

Overall, I like Meshmixer. It does some things ok, and other things really well. I really wish it was open source though… then again, if it was, it might’ve not been bought by Autodesk.