I have a Python script that takes a mesh (created from an SVG path) and drills holes in it from coordinates in a file.

The whole project is auto-generating models of PCBs I design - but I am only concerned with the generation of the actual PCB at the moment.

My script all works perfectly - it's just that it's horribly, horribly, slow. The slow part is when it's performing boolean operations to cut cylinders out of the mesh.

This is the routine I am using to cut one hole out from the mesh:

def drill(target, x, y, size):
    print("Drilling " + str(x) + "," + str(y) + " @ " + str(size) + "mm")
    bpy.ops.mesh.primitive_cylinder_add(vertices=64, radius=size/2, depth=10, location=(x, y, 0))
    newbit = bpy.context.object
    target.select = True
    bpy.context.scene.objects.active = target
    mod = target.modifiers.new("Drill", type='BOOLEAN')
    mod.operation = 'DIFFERENCE'
    mod.object = newbit
    target.data = target.to_mesh(bpy.context.scene, True, 'PREVIEW')
    #bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)

Yes, I iterate the file getting the data and drill one hole at a time. Originally I was creating multiple "drill bits" then .join()ing them into a single compound object and using that for the boolean operation. This was considerably faster, however often the boolean operation would mess up and the resultant mesh would be a complete mess with faces covering random holes (Blender 2.79b), and the only way I found to cure that was to drill each hole separately.

But the actual drilling operation takes a long time. If you uncomment the last line you can see each hole being cut in turn and see how long it's taking, and it's ages.

So I'm looking for other ideas. Other approaches that I could take to create the mesh - from people that know a darn sight more about Blender than I do.

The constraints:

  • There is an SVG file which is used to create the "outline" of a solid mesh that is extruded to give it depth and all faces closed to make it solid.
  • There is a list of coordinates and diameters
  • The results must not cause incorrect faces to be created

So... ideas?

  • $\begingroup$ 1 Don't convert curves to mesh (it is destructive). 2 Don't use Booleans (produces errors, bad topology, it is slow and fails often); 3 Instead keep the original curve and add bezier circles centered at the correct positions, then join them to the main SVG curve $\endgroup$ Commented Jan 28, 2019 at 0:07
  • $\begingroup$ Interesting. So stick as a path / curve and add the holes to it, and then extrude it to a mesh? $\endgroup$
    – Majenko
    Commented Jan 28, 2019 at 0:08
  • $\begingroup$ Curves can be extruded/beveled natively, no need to convert to mesh unless strictly necessary. Try to keep your workflow as non destructive as possible. $\endgroup$ Commented Jan 28, 2019 at 0:11
  • $\begingroup$ How would this work with the faces having holes in them? How does it know the circles are holes? $\endgroup$
    – Majenko
    Commented Jan 28, 2019 at 0:18
  • $\begingroup$ All circles would then have to joined back into the main curve, they can't remain as separate objects $\endgroup$ Commented Jan 28, 2019 at 0:22

1 Answer 1


Booleans are slow, heavy, error prone and produce bad topology, they also only work on meshes, requiring conversion of curves to mesh which is a destructive process.

I would suggest instead a different approach. Keep you SVG import as a live bezier curve object, use its builtin extrusion and beveling capabilities to generate geometry.

Then use the coordinates file to create bezier curve circle objects with the desired radius at the correct positions. Join these created circles back into the original SVG object. Set it as 2D curve.

If everything has been correctly designed as coherent closed splines, Blender should be able to correctly close them and represent the circles as holes.

  • $\begingroup$ It kind of works. For a simple curve with only a few holes it's fine. For a more complex one with hundreds / thousands of holes it gets confused. $\endgroup$
    – Majenko
    Commented Jan 28, 2019 at 10:33
  • $\begingroup$ Actually you can ignore that. Having two holes in the same location confuses Blender. I have fixed it by filtering my holes so it's impossible to have two at the same place. $\endgroup$
    – Majenko
    Commented Jan 28, 2019 at 11:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .