I'm trying to write a blender script which duplicate and flip faces if X material is found. Right now the script only can duplicate the faces but I need to flip their normals. (Only duplicated faces not the original faces)
The code I have so far:
for ob in bpy.context.scene.objects:
if ob.type == 'MESH':
tbh_slots = [id for id, mat in enumerate(ob.data.materials) if mat == mat_tbh]
faces_mat_tbh = []
bm = bmesh.new()
bm.from_mesh(ob.data)
for face in bm.faces:
if face.material_index in tbh_slots:
faces_mat_tbh.append(face)
bmesh.ops.duplicate(bm, geom=faces_mat_tbh)
bmesh.ops.reverse_faces(bm, faces=faces_mat_tbh, flip_multires=False) #Trying to flip normals, but it does it to every face that applies to the condition, for obvious reasons.
bm.to_mesh(ob.data)
bm.free()
else:
ob.select_set(state=True)
duplicate
operation create a new listfaces_added = [f for f in bm.faces if f.material_index in tbh_slots and f not in faces_mat_tbh]
then when performing thereverse_faces
operation reference the new list. should get you what you need. $\endgroup$