4
$\begingroup$

I'm trying to speed up an addon that had to toggle into Edit Mode for sometimes thousands of object by staying at the object level using bmesh instead of object.editmode_toggle().

Is there any operation to clear sharp edges without having to enter Edit Mode for each object?

$\endgroup$
2
$\begingroup$

You can set use_edge_sharp flag per edge on MeshData.edges in Object Mode:

import bpy

obj = bpy.context.object

# Clear sharp state for all edges
for edge in obj.data.edges:
    edge.use_edge_sharp = False

If there is no way around Bmesh for whatever reason, you can set the smooth state of all edges to True in Edit Mode:

import bpy
import bmesh

obj = bpy.context.object
me = obj.data
bm = bmesh.from_edit_mesh(me)

# Clear sharp state for all edges 
for edge in bm.edges:
    edge.smooth = True

# Update the mesh
bmesh.update_edit_mesh(me, False, False)

Related: Is there a way to select edges marked as sharp via python?

$\endgroup$
  • 2
    $\begingroup$ While this is not the requested bmesh solution, this should be faster due to not requiring the bmesh conversion. If your workflow has bmesh conversion anyway, you can use this before or after the bmesh part, not during. $\endgroup$ – kheetor May 2 '18 at 8:40
  • $\begingroup$ Yeah, absolutely right, should be indeed way faster without the conversion... Thanks @kheetor $\endgroup$ – brockmann May 2 '18 at 9:10
  • $\begingroup$ Thanks. I'm going to experiment with different methods and see which combination of approaches works the fastest. The main method that I could only get with bmesh or toggling into edit mode was limited dissolve. I think there are other ways to do this as well, since I think it is mostly removing/merging colinear edges and coplanar faces. $\endgroup$ – dpdp May 2 '18 at 13:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.