I’m new to Blender and slowly setting up my keybinds. I was looking for a way to mark sharp edges and clear them in a single bind instead of two, like a toggle. I found a thread with a script for a creasing toggle but I don’t know how to transform it to sharp edges as I’m not familiar enough with Blender’s python API. If someone could lend a hand that would be much appreciated
import bpy
import bmesh
class SimpleOperator(bpy.types.Operator):
"""Tooltip"""
bl_idname = "object.simple_operator"
bl_label = "Simple Object Operator"
@classmethod
def poll(cls, context):
return context.active_object is not None
def execute(self, context):
ob = context.object
me = ob.data
bm = bmesh.from_edit_mesh(me)
cl = bm.edges.layers.crease.verify()
for edge in bm.edges:
if edge.select and (edge[cl] == 0.0 or edge.smooth):
sharp = False
break
else:
sharp = True
for edge in bm.edges:
if edge.select:
edge[cl] = 0.0 if sharp else 1.0
edge.smooth = sharp
bmesh.update_edit_mesh(me, False, False)
return {'FINISHED'}
def register():
bpy.utils.register_class(SimpleOperator)
def unregister():
bpy.utils.unregister_class(SimpleOperator)
if __name__ == "__main__":
register()
# test call
bpy.ops.object.simple_operator()