I am trying to subdivide the following mesh which is split in 3 objects and each object is structured from quads:
I tried both the following two functions:
def subdivide_objects(): obs = [o for o in bpy.data.objects if o.type == 'MESH' and (o.name == "Wall" or o.name == "Ceiling" or o.name == "Floor")] for obj in obs: me = obj.data # New bmesh bm = bmesh.new() # load the mesh bm.from_mesh(me) bmesh.ops.subdivide_edges(bm, edges=bm.edges, cuts=12, use_grid_fill=True) # Write back to the mesh bm.to_mesh(me) me.update() def post_process_objects(): bpy.ops.object.select_all(action='DESELECT') # Deselect all objects for o in ("Wall", "Ceiling", "Floor"): obj = bpy.context.scene.objects.get(o) bpy.context.view_layer.objects.active = obj if obj: obj.select_set(True) # Get into edit mode bpy.ops.object.mode_set(mode="EDIT") # Subdivide faces bpy.ops.mesh.subdivide(number_cuts=12) # Return back to object mode bpy.ops.object.mode_set(mode="OBJECT") bpy.ops.object.select_all(action='DESELECT') # Deselect all objects
but for some reason both are not giving the desired result, but as you can see a faulty one:
Any idea what I am missing here (attached the .blend file)?
After applying @Lucca's solution, for some reason I am still facing the same problem on some specific parts of the plane as you can see in the following images:
It doesn't seem that I have duplicate vertices or something now thus ny idea why still the subdivide operator does not work properly.
Example for @batFINGER 's solution: