fix non existing bone

blender3.6
ChristopheSeux 2022-04-09 20:12:40 +02:00
parent 2d16d82c99
commit 89941a9d30
1 changed files with 7 additions and 2 deletions

View File

@ -372,12 +372,16 @@ class Picker:
) )
elif s['type'] == 'BONE': elif s['type'] == 'BONE':
bone = rig.pose.bones.get(s['bone'])
if not bone:
print(f'Bone {s["bone"]} not exist')
continue
shape = BoneShape( shape = BoneShape(
self, self,
points=s['points'], points=s['points'],
polygons=s['polygons'], polygons=s['polygons'],
edges=s['edges'], edges=s['edges'],
bone=rig.pose.bones.get(s['bone']), bone=bone,
color=s['color'] color=s['color']
) )
@ -527,7 +531,8 @@ def draw_callback_view():
return return
if ob not in PICKERS: if ob not in PICKERS:
picker_path = Path(bpy.path.abspath(ob.data.rig_picker.source)) picker_path = Path(bpy.path.abspath(ob.data.rig_picker.source, library=ob.data.library))
print('Load picker from', picker_path.resolve())
picker_datas = json.loads(picker_path.read_text()) picker_datas = json.loads(picker_path.read_text())
#shapes = [s.to_dict() for s in ob.data.rig_picker['shapes']] #shapes = [s.to_dict() for s in ob.data.rig_picker['shapes']]
PICKERS[ob] = Picker(ob, shapes=picker_datas) PICKERS[ob] = Picker(ob, shapes=picker_datas)