6
$\begingroup$

Is it possible to turn on Auto Normals by default when creating new objects in Blender? Now you need to apply it manually for each new object in the scene when switching to Smooth Shading and it's not very convenient. Maybe there are some ways to do this by default?

$\endgroup$
8
$\begingroup$

Subscribe to msgbus

enter image description here

Very similarly to answer to Origins to the down of the object by default can check when a new object becomes active when it is the result of being freshly added by an add primitive operator.

Run this code, and any newly added primitive will have auto smooth on with 18 degrees.

enter image description here

as shown in origins to default, can change up all sorts of things.

import bpy
from math import radians

handle = object()

# make some default value
auto_smooth_default = (True, radians(18))

# Triggers when an object is made active
subscribe_to = bpy.types.LayerObjects, "active" # 

def notify_test(context):
    if (context.object.type == 'MESH'
            and getattr(context.active_operator, "bl_idname", "").startswith("MESH_OT_primitive_")
            and context.mode == 'OBJECT'):
        print("Setting auto smooth")
        me = context.object.data
        me.use_auto_smooth, me.auto_smooth_angle = auto_smooth_default
        # set all faces smooth
        me.polygons.foreach_set(
                "use_smooth", 
                [me.use_auto_smooth] * len(me.polygons),
                )
bpy.msgbus.subscribe_rna(
    key=subscribe_to,
    owner=handle,
    args=(bpy.context,),
    notify=notify_test,
)

bpy.msgbus.publish_rna(key=subscribe_to)
$\endgroup$
1
  • 1
    $\begingroup$ @JachymMichal It's a bit "hacky" and relies on operator having the idname prefix. Would take some effort to make sure any operator that adds a mesh is picked up. $\endgroup$
    – batFINGER
    Mar 10 '21 at 9:39

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.