Skip to content

Commit 1cbf9ef

Browse files
committed
Fix a bug in graft, more helpful error messages
1 parent d4cd476 commit 1cbf9ef

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

mesh/graft.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,19 @@ class GRET_OT_graft(bpy.types.Operator):
6262

6363
@classmethod
6464
def poll(cls, context):
65-
return (len(context.selected_objects) > 1
66-
and context.active_object
67-
and context.active_object.type == 'MESH'
68-
and context.mode == 'OBJECT')
65+
return context.mode == 'OBJECT'
6966

7067
def _execute(self, context):
7168
orig_dst_obj = context.active_object
7269
objs = [o for o in context.selected_objects if o.type == 'MESH' and o != orig_dst_obj]
7370

71+
if not objs:
72+
self.report({'ERROR'}, f"Select one or more meshes then the target object to graft them to.")
73+
return {'CANCELLED'}
74+
if not orig_dst_obj or orig_dst_obj.type != 'MESH' or orig_dst_obj not in context.selected_objects:
75+
self.report({'ERROR'}, f"Active object is not a selected mesh.")
76+
return {'CANCELLED'}
77+
7478
# Get an evaluated version of the destination object
7579
# Can't use to_mesh because we will need to enter edit mode on it
7680
dg = context.evaluated_depsgraph_get()
@@ -241,7 +245,8 @@ def _execute(self, context):
241245
# Can't create a hide_viewport driver for reasons
242246
link_properties(obj, 'hide_render', orig_dst_obj, mod_dp + '.show_render', invert=True)
243247

244-
obj.vertex_groups.remove(boundary_vg)
248+
obj.vertex_groups.remove(boundary_vg)
249+
245250
bpy.data.objects.remove(dst_obj)
246251
bpy.data.meshes.remove(dst_mesh)
247252
return {'FINISHED'}

0 commit comments

Comments
 (0)