When I subdivide edges of selected faces using the GUI, it ends up looking like this:
On the other hand, using python, it looks like this, only generating vertices and not faces:
Here is the code - how can I get a similar result to the GUI, actually splitting faces up?
import bpy
import bl_operators
import bmesh
from math import ceil
obj = bpy.context.active_object
mat_zero = bpy.data.materials.new("mat_zero")
mat_zero.diffuse_color = (0, 0, 0, 1)
mat_one = bpy.data.materials.new("mat_one")
mat_one.diffuse_color = (1, 0, 0, 1)
obj.data.materials.append(mat_zero)
obj.data.materials.append(mat_one)
me = obj.data
bm = bmesh.new()
bm.from_mesh(me)
for edge in bm.edges:
linked = edge.link_faces
if(linked[0].smooth and linked[1].smooth):
edge.seam = False
print(len(bm.faces))
bpy.ops.object.mode_set(mode="EDIT")
for face in bm.faces:
if (face.smooth):
face.material_index = 1
area = face.calc_area()
face.select = True
for edge in face.edges:
edge.select = True
bmesh.ops.subdivide_edges(bm, edges=face.edges, cuts=1)
bm.normal_update()
me.update()
bpy.ops.object.mode_set(mode="OBJECT")
print(len(bm.faces))
bm.to_mesh(me)
print("done")