I want to create an object based on the active one with inset faces and modified vertex coordinates. Inset works as expected if I don't modify verts coordinates but if I do it gives me unexpected results. Do I need to somehow "recalculate" bmesh after I modify verts positions?
Here's the result I'm getting:
Here's a code I run on a Plane object. As an example I make every point of the object 1 unit higher. I tried to include different variants of .ensure_lookup_table()
without any luck.
import bpy
import bmesh
from mathutils import Vector
ob = bpy.context.object
bm = bmesh.new()
bm.from_mesh(ob.data)
for index, v in enumerate(bm.verts):
v.co = v.co + Vector((0,0,index))
# insetting bmesh
inset_faces = bmesh.ops.inset_region(bm, faces = bm.faces, thickness=0.5, use_boundary=True, use_even_offset=True)
# creating mesh
mesh = bpy.data.meshes.new("mesh")
obj = bpy.data.objects.new("new_obj", mesh)
bpy.context.scene.collection.objects.link(obj)
bm.to_mesh(obj.data)
obj.data.update()
bm.free()
What am I missing?