15
$\begingroup$

I know that I can click on the smooth / flat shading buttons in the Tool Shelf panel when I am in object mode.

What I would like to know, is where can I find out if an object has smooth or flat shading on it without having to go and click the buttons to see the difference?

smooth flat shading animation

$\endgroup$
24
$\begingroup$

The smooth/flat shading option is only applied per face and not per object. So there isn't a way of viewing the shading status of an object.

When you click 'Smooth' or 'Flat' shading while in object mode you are simply telling blender to smooth each individual face. You could go into edit mode and set smooth or flat shading on a selection of faces instead of the whole object, meaning: the object would have both smooth and flat shading.

You could create a python script which loops through the faces of an object and sees whether the majority are smooth or flat shaded by accessing the use_smooth property of a polygon (face) and seeing whether it is True or False.

You can access the use_smooth property via Mesh.polygons on a given object:

# test the first polygon of a certain mesh
>>> bpy.data.objects['ObjectName'].data.polygons[0].use_smooth
>>> True

# set the shading of all polygons to flat 
for poly in bpy.context.object.data.polygons:
    poly.use_smooth = False
$\endgroup$
1
$\begingroup$

two way to set object smooth/flat shading

use menu:

[tab] key to enter edit mode, then mesh/faces [ctrl+F] to apply shade-smooth.

use panel:

[tab] key to enter edit mode, then in tool-shelf, shading/uvs, faces, choose smooth. the two way do the same thing, use vertex normal instead of face normal.

enter image description here

enter image description here

$\endgroup$
0
$\begingroup$

For the simpler case of applying smooth or flat shading across a whole mesh in Object Mode (as per Neil's question) right-clicking the smooth & flat buttons in the toolbox provides for easy creation of 2 distinct shortcuts. Since these are not toggles, there is little prospect of confusion if the shortcuts are properly memorized... Smooth shading applied to an already smooth-shaded mesh will create no change so the shortcuts function as absolute identifiers.

$\endgroup$
0
$\begingroup$

I had a need to identify which of 200 odd meshes in my scene had smooth shading and what value autosmooth(if used)

Running the following produced a list of all the details of all the meshes.

import bpy, math 

def is_smooth(polys): 
    smoothed=False 
    for poly in polys: 
        if not smoothed: 
            smoothed = poly.use_smooth 
    return smoothed 

for mesh in bpy.data.objects.data.meshes: 
    print(mesh.name, is_smooth(mesh.polygons), mesh.use_auto_smooth) 
    print("{:8.4f}".format(math.degrees(mesh.auto_smooth_angle)) ) 
$\endgroup$

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.