Post #5108: Is this the behavior you were looking for?
📋 Metadata
- Author: Pluglug
- Date: 2024-04-22 06:26:09
- Type:
answer - Quality Score: 8/10
- Reply to: post_05107
🏷️ Tags
⚙️ Related PME Features
- Python Scripting
- Macro Editor
💬 Content
Is this the behavior you were looking for?
import bpy
import bmesh
def set_edge_sharpness():
obj = bpy.context.edit_object
if obj and obj.type == 'MESH':
me = obj.data
bm = bmesh.from_edit_mesh(me)
crease_layer = bm.edges.layers.float.get("crease_edge") or bm.edges.layers.float.new("crease_edge")
selected_edges = [e for e in bm.edges if e.select]
if selected_edges:
value = 1 if all(e[crease_layer] == 0 and e.smooth and not e.seam for e in selected_edges) else 0
for e in selected_edges:
e[crease_layer] = value
e.smooth = not value
e.seam = value
bmesh.update_edit_mesh(me)
set_edge_sharpness()
Test it in a text editor and call it with execute_script() if you like.
❤️ 2 likes