3
$\begingroup$

Is it possible to have Smooth Shading on by default for every object created? I can't seem to find a way to do this in the User Preferences. Turning on Smooth Shading is an action I need to perform 95% of the time, it would be nice if I could skip it. Apologies if this is more a "feature request" but I think I may have just missed the option in Preferences.

$\endgroup$

2 Answers 2

1
$\begingroup$

It is kind of possible to write an add-on for this with Python. There does not seem to be a nice way to trigger an operator(what smooth shading is in Blender apparently) every time an object is created, but it is possible to check the count of objects in the file every time scene is updated. Scene gets updated all the time so that is a whole lot of unnecessary checks, but it seems there is no nice or elegant way to do this. I am not entirely sure I can honestly recommend using it but this hack seems to work and it's the only way to do it I can think of. It shades anything new to the scene smooth. Pasting and duplicating will trigger it as well. You can save it to a .py file and install it as an add-on if you really need this functionality. You may also want to do something about ugly shading with sharp edges so you may want to uncomment the line enabling auto smooth.

bl_info = {
    "name": "Smooth shade new objects",
    "author": "-",
    "version": (1, 0),
    "blender": (2, 79, 0),
    "location": "Works every time new objects are added",
    "description": "Shades everything added to the scene smooth",
    "warning": "",
    "wiki_url": "",
    "category": "Mesh",
    }

import bpy
from bpy.app.handlers import persistent

bpy.last_count = 0

@persistent
def smooth_handler(dummy):

    if len(bpy.data.objects) < bpy.last_count:
        bpy.last_count = len(bpy.data.objects)
    elif len(bpy.data.objects) > bpy.last_count:
        bpy.last_count = len(bpy.data.objects)
        if bpy.context.object != None:
            #bpy.context.object.data.use_auto_smooth = True 
            bpy.ops.object.shade_smooth()



def register():
    bpy.app.handlers.scene_update_post.clear()
    bpy.app.handlers.scene_update_post.append(smooth_handler)

def unregister():
    bpy.app.handlers.scene_update_post.clear()

if __name__ == "__main__":
    register()
$\endgroup$
2
  • $\begingroup$ Thanks, very interesting! I guess if you combine this with "autosmooth" enabled with 30° angle, the ugly edges would be eliminated in most cases. That would be a good add-on for a hard-surface workflow. $\endgroup$
    – Jan
    Jan 12, 2019 at 9:14
  • $\begingroup$ Be wary of using context from within a handler. The argument of a handler is the scene it is handling. Only for onload handlers this is denoted as "dummy" because of restricted context. Given the scene is passed, scene.objects.active is active object, and scene.objects is all objects linked to scene. The operator can be avoided using similar Clearing all handlers may wipe out other addon handlers eg animation nodes. Also why look at the files objects collection, surely its meshes or at scene objects of type MESH. $\endgroup$
    – batFINGER
    Jan 17, 2019 at 6:22
0
$\begingroup$

Hi there I need little bit help on the above script it’s checking that is there any object in the scene if it’s there then make it smooth shading or if we adding anything to the scene then do smoothing to it .

Can we make it like that when we add something to the scene default cube or cylinder only this work on them . Not the objects that already presented in the scene .

I’m working on low-poly modelling so this script helps so much to me .

Thanks .

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .