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?
1 Answers
Subscribe to msgbus
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.
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)
- 84,216
- 10
- 108
- 233
-
1@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. – batFINGER Mar 10 '21 at 09:39

