Scanning mesh for two sided faces

Hi all,

I’m updating my script (written for 2.49b) to be compliant with 2.5x. I’m stuck with “twoside” toggle detection.

Here is a part of the code I used in 2.49:

if f.mode & Blender.Mesh.FaceModes['TWOSIDE']: 
    (this means we detected face with "twoside" on 
    (something else) 

f is face off course. The script was testing each and every face of the mesh and was checking if it has TWOSIDE flag on.

Can you give me an example of how I should do it in 2.5x API?

OK, I’ve finally figured out it by myself. :cool:

This could be interesting for some of you, so below I present a demo code which scans all the faces in the current mesh:

import bpy

# Let's use the current cube
mesh =["Cube"]

# make sure we are in the object mode

for i, face in enumerate(mesh.faces):
    uf =[i]
    img = uf.image
    print ("image = " + str(
    two = uf.use_twoside
    print ("two_side = " +  str(two))

The key is to use[i] and go through all the faces by incrementing variable i. There’s also one very important part - the script needs to go into object mode to perform this operation. That’s why I included the line which switches to object mode.