New Object Display Pie (Shift+W) #26
@ -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,
|
||||
]
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user