Page MenuHome

File Metadata

Author
Robert Forsman (mutantbob)
Created
May 21 2014, 5:09 PM
import bpy
import bmesh
def copy_stuff(src, dst, bm):
dst.material_index = src.material_index
#for l in bm.faces.layers.tex.values():
# dst[l] = src[l]
class RotateFaceVertexOrderOp(bpy.types.Operator):
"""Rotate Face Vertex Order"""
bl_idname="object.rotate_face_vertex_order_operator"
bl_label = "Rotate Face Vertex Order Operator"
def execute(self, context):
mesh = context.active_object.data
bm = bmesh.from_edit_mesh(mesh)
for face in bm.faces:
if (face.select):
vs = face.verts[:]
vs2 = vs[1:]+vs[:1]
#face.verts =vs2
tex_copy = [ [l, face[l].image] for l in bm.faces.layers.tex.values() ]
tex_copy2 = [ [l, face[l]] for l in bm.faces.layers.tex.values() ]
mi = face.material_index
print (tex_copy[0][1])
print ("copied")
bm.faces.remove(face)
f2=bm.faces.new(vs2)
if False:
f2.copy_from(face)
else:
f2.material_index = mi
for tc in tex_copy:
f2[tc[0]].image = tc[1]
print (tc[1])
#for tc in tex_copy2:
# f2[tc[0]] = tc[1]
print ("face done")
f2.select = True
bmesh.update_edit_mesh(mesh)
return {'FINISHED'}
# VIEW3D_MT_edit_mesh_faces
def add_object_button(self, context):
self.layout.operator(RotateFaceVertexOrderOp.bl_idname,
text=RotateFaceVertexOrderOp.__doc__,
icon='PLUGIN')
def register():
bpy.utils.register_class(RotateFaceVertexOrderOp)
bpy.types.VIEW3D_MT_edit_mesh_faces.append(add_object_button)
if __name__ == "__main__":
register()

Event Timeline