1111 get_point_dist_to_line_sq ,
1212 get_range_pct ,
1313)
14- from ..helpers import get_collection , TempModifier
14+ from ..helpers import try_call , get_context , get_collection , TempModifier
1515
1616# make_collision TODO:
1717# - Non-axis aligned boxes
@@ -34,19 +34,33 @@ def find_free_col_name(prefix, name):
3434 break
3535 return col_name
3636
37+ def clear_customdata (obj , sculpt_mask_data = True , skin_data = True , custom_split_normals = True ,
38+ edge_bevel_weight = True , vertex_bevel_weight = True , edge_crease = True , vertex_crease = True ):
39+ ctx = get_context (obj )
40+ if sculpt_mask_data :
41+ try_call (bpy .ops .mesh .customdata_mask_clear , ctx )
42+ if skin_data :
43+ try_call (bpy .ops .mesh .customdata_skin_clear , ctx )
44+ if custom_split_normals :
45+ try_call (bpy .ops .mesh .customdata_custom_splitnormals_clear , ctx )
46+ if edge_bevel_weight :
47+ try_call (bpy .ops .mesh .customdata_bevel_weight_edge_clear , ctx )
48+ if vertex_bevel_weight :
49+ try_call (bpy .ops .mesh .customdata_bevel_weight_vertex_clear , ctx )
50+ if edge_crease :
51+ try_call (bpy .ops .mesh .customdata_crease_edge_clear , ctx )
52+ if vertex_crease :
53+ try_call (bpy .ops .mesh .customdata_crease_vertex_clear , ctx )
54+
3755def remove_extra_data (obj ):
3856 assert obj .type == 'MESH'
3957
4058 obj .vertex_groups .clear ()
4159 obj .shape_key_clear ()
60+ clear_customdata (obj )
4261
4362 mesh = obj .data
44- mesh .use_customdata_vertex_bevel = False
45- mesh .use_customdata_edge_bevel = False
46- mesh .use_customdata_edge_crease = False
47-
48- # mesh.materials.clear() seems to crash
49- while mesh .materials :
63+ while mesh .materials : # mesh.materials.clear() seems to crash
5064 mesh .materials .pop ()
5165 while mesh .uv_layers .active :
5266 mesh .uv_layers .remove (mesh .uv_layers .active )
0 commit comments