Skip to content

Commit f8dfe4f

Browse files
committed
adding specific error message when adding a new armature to a hidden collection
1 parent 3197d75 commit f8dfe4f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

car_rig.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,7 +1292,13 @@ def execute(self, context):
12921292

12931293
rig = bpy_extras.object_utils.object_data_add(context, amt, name='Car Rig')
12941294

1295-
bpy.ops.object.mode_set(mode='EDIT')
1295+
# TODO: cannot edit new object added to a hidden collection
1296+
# Could be a better fix (steal code from other addons).
1297+
try:
1298+
bpy.ops.object.mode_set(mode='EDIT')
1299+
except TypeError:
1300+
self.report({'ERROR'}, "Cannot edit the new armature! Please make sure the active collection is visible and editable")
1301+
return {'CANCELLED'}
12961302

12971303
self._create_bone(rig, 'Body', delta_pos=self.body_pos_delta)
12981304

@@ -1314,7 +1320,7 @@ def execute(self, context):
13141320

13151321
bpy.ops.object.mode_set(mode='OBJECT')
13161322

1317-
return{'FINISHED'}
1323+
return {'FINISHED'}
13181324

13191325
def _create_bone(self, rig, name, delta_pos):
13201326
b = rig.data.edit_bones.new('DEF-' + name)

0 commit comments

Comments
 (0)