fix: view_settings error

fix: empty collection error
This commit is contained in:
Swann
2020-04-06 10:38:31 +02:00
parent 427b36ddaf
commit 3394299e8b
2 changed files with 14 additions and 4 deletions

View File

@ -82,7 +82,7 @@ class BlScene(BlDatablock):
#TODO: change this ugly fix
target.view_settings.curve_mapping.white_level = data['view_settings']['curve_mapping']['white_level']
target.view_settings.curve_mapping.black_level = data['view_settings']['curve_mapping']['black_level']
target.view_settings.curve_mapping.update()
target.view_settings.curve_mapping.update()
def _dump_implementation(self, data, pointer=None):
assert(pointer)

View File

@ -47,6 +47,10 @@ def np_load_collection(dikt: dict, collection: bpy.types.CollectionProperty, att
:arg attributes: list of attributes name
:type attributes: list
"""
if not dikt or len(collection) == 0:
logger.warning(f'Skipping collection')
return
if attributes is None:
attributes = dikt.keys()
@ -111,11 +115,15 @@ def np_dump_collection_primitive(collection: bpy.types.CollectionProperty, attri
:type attribute: str
:return: numpy byte buffer
"""
if len(collection) == 0:
logger.warning(f'Skipping empty {attribute} attribute')
return {}
attr_infos = collection[0].bl_rna.properties.get(attribute)
assert(attr_infos.type in ['FLOAT', 'INT', 'BOOLEAN'])
size = sum(attr_infos.array_dimensions) if attr_infos.is_array else 1
dumped_sequence = np.zeros(
@ -182,10 +190,12 @@ def np_load_collection_primitives(collection: bpy.types.CollectionProperty, attr
:arg attribute: target attribute
:type attribute: str
:arg sequence: data buffer
:type sequence: str
:return: numpy byte buffer
:type sequence: strr
"""
if len(collection) == 0:
logger.warning(f"Skipping loadin {attribute}")
return
attr_infos = collection[0].bl_rna.properties.get(attribute)
assert(attr_infos.type in ['FLOAT', 'INT', 'BOOLEAN'])