# How to draw a circle hole by bmesh on the plane?

How to draw a circle hole or a square hole by bmesh on the plane object? I tried with below but failed it only draws circle rather than a hole.

bm=bmesh.new()
ret=bmesh.ops.create_circle(
bm,
cap_ends=False,
segments=8)
#print('circleret:',ret)
bmesh.ops.translate(
bm,
verts=ret['verts'],
vec=(5.0, 24.0, 0.0))
mycircleface = bm.faces.new(ret['verts'])
me1 = bpy.data.meshes.new("Circle")
bm.to_mesh(me1)


Round or square hole in round or square mesh.

Would be many ways to skin this cat.

• Add a plane remove its one face. Size square_size
• Subdivide the plane equally using cuts
• Add a circle with 4 * (cuts + 1) segments, radius circle_radius
• Bridge the loops from square to circle

Test script.

import bpy
import bmesh

cuts = 3
square_size = 1

context = bpy.context
collection = context.collection
me = bpy.data.meshes.new("Hole")
bm = bmesh.new()

bmesh.ops.create_grid(
bm,
x_segments=2,
y_segments=2,
size=square_size,
)

bm.faces.remove(bm.faces[:].pop())
bmesh.ops.subdivide_edges(
bm,
edges=bm.edges,
cuts=cuts,
)

bmesh.ops.create_circle(
bm,
segments=4 * (cuts + 1),
)

bmesh.ops.bridge_loops(
bm,
edges=bm.edges,
)

bm.to_mesh(me)
ob = bpy.data.objects.new("Hole", me)


This makes one of each as mesh and hole. Circle in circle (Square in square) can be done as above, simply making one twice.

Could wire this up similarly to