New Object Display Pie (Shift+W) #26

Merged
Demeter Dzadik merged 4 commits from object_display_pie into main 2024-09-08 13:07:19 +02:00
Showing only changes of commit e4ffe98c4a - Show all commits

View File

@ -2,7 +2,8 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later
from bpy.types import Menu
import bpy
from bpy.types import Menu, Operator
from .hotkeys import register_hotkey
@ -70,10 +71,38 @@ class OBJECT_MT_set_object_shading(Menu):
if context.active_object.type == 'MESH':
layout.operator('object.shade_auto_smooth', icon='MODIFIER')
layout.separator()
layout.operator('OBJECT_OT_reset_normals', icon='LOOP_BACK')
class OBJECT_OT_reset_normals(Operator):
"""Reset mesh normals by clearing custom split normals if any, recalculating mesh normals, and setting all faces to smooth shading"""
bl_idname = "object.reset_normals"
bl_label = "Reset Normals"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
for obj in context.selected_objects:
if obj.type != 'MESH':
continue
with context.temp_override(active_object=obj, object=obj):
bpy.ops.mesh.customdata_custom_splitnormals_clear()
obj.data.shade_smooth()
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.reveal()
bpy.ops.mesh.select_all(action='SELECT')
bpy.ops.mesh.normals_make_consistent()
bpy.ops.object.mode_set(mode='OBJECT')
return {'FINISHED'}
registry = [
PIE_MT_object_display,
OBJECT_MT_set_object_shading,
OBJECT_OT_reset_normals,
]