Hello, is there a faster/better way of doing this script? It looks at edges and decides if it should run a bevel or extrude based on it being an “open” or non-manifold edge. It does a lot selecting and deselected to do a comparison which I’m thinking isn’t the best especially as the poly count gets higher.
import bpy
import bmesh
def main(context):
if context.space_data.type == 'VIEW_3D':
if context.mode == 'EDIT_MESH':
current_mesh_mode = context.tool_settings.mesh_select_mode[:]
# if Face mode on
if current_mesh_mode[2]:
bpy.ops.wm.tool_set_by_id(name='builtin.extrude_region', cycle= True)
# Edge selected
if current_mesh_mode[1]:
obj = bpy.context.active_object
bm = bmesh.from_edit_mesh(obj.data)
#Get Selected Edges
selected_edges = [e for e in bm.edges if e.select]
bpy.ops.mesh.select_all(action='DESELECT')
bpy.ops.mesh.select_non_manifold()
#Get Selected Edges Non Manifold
selectedB_edges = [e for e in bm.edges if e.select]
#Select and Deselect to compare
bpy.ops.mesh.select_all(action='DESELECT')
for e in selected_edges:
e.select = True
for e in selectedB_edges:
e.select = False
# Get New Edge selection from comparison
selectedC_edges = [e for e in bm.edges if e.select]
#Count Edges
c1 = len (selectedC_edges)
print (c1)
#Decide what to do if 0 edges selected
bpy.ops.mesh.select_all(action='DESELECT')
if c1 == 0:
print('v0')
for e in selected_edges:
e.select = True
bpy.ops.wm.tool_set_by_id(name='builtin.extrude_region', cycle= True)
else:
for e in selected_edges:
e.select = True
bpy.ops.wm.tool_set_by_id(name='builtin.bevel')