I've been playing with duplifaces and it turns out the orientation of the copied geometry depends on the order of the vertices in the face (https://developer.blender.org/T30547). Since I'm unhappy with the orientation of some of my duplicated geometry, clearly I need to "rotate" the vertex order of some of the faces.

I've come up with this little python snippet, but it has one drawback I can think of.

# rotate selected face

import bpy
import bmesh

mesh = bpy.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 # fails because verts is read-only
        f2 = bm.faces.new(vs2)
        f2.select = True

# trigger UI update    

The drawback is that it destroys the old face and creates a new one. I suspect that there will be some cases where information on the old face will be lost.

Just for some flavor, here's an illustration of a situation where you might want manual control over the orientation: enter image description here

  • 1
    $\begingroup$ JA12 put together a short video that illustrates some workflow techniques to control this if you are building new geometry: $\endgroup$
    – Mutant Bob
    May 17 '14 at 19:38
  • $\begingroup$ There is a tool to help re-order mesh elements, which can be accessed in the GUI with Space > Sort Mesh elements (you must be in edit mode), or in python with bpy.ops.mesh.sort_elements(). Unfortunately it didn't seem to affect duplifaces, at least it didn't when I tried it.. $\endgroup$
    – gandalf3
    May 19 '14 at 19:20
  • $\begingroup$ Even if Sort Mesh Elements were to affect the vertex order on a face, there's only a 1/4 chance that the order of the vertices is the order you want. I think it would require a new operator, but I'm disinclined to start work on a new patch until my other patch gets accepted, or even rejected. $\endgroup$
    – Mutant Bob
    May 20 '14 at 14:34
  • $\begingroup$ Do you actually want to rotate the faces, or do you want to flip the normals (so the orientation the polygon is facing)? There are bmesh.utils.face_flip(), bmesh.ops.rotate_edges() and bmesh.utils.edge_rotate(), which might do what you want. $\endgroup$
    – CodeManX
    Aug 18 '14 at 17:48

The UI isn't updating because the script does not call


(I got this from how to use BMesh to add verts, faces, and edges to existing geometry )


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.