Skip to content

Commit d5d5a81

Browse files
authored
Merge pull request #24 from ynput/bugfix/user_data_ignore_unsupported_values
Ignore user data with values that can't be converted to Python
2 parents 52f39a7 + 906b4ab commit d5d5a81

File tree

1 file changed

+16
-2
lines changed
  • client/ayon_cinema4d/api

1 file changed

+16
-2
lines changed

client/ayon_cinema4d/api/lib.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,15 @@ def obj_user_data_to_dict(obj) -> dict:
256256

257257
for description_id, base_container in obj.GetUserDataContainer():
258258
key = base_container[c4d.DESC_NAME]
259-
value = obj[description_id]
259+
260+
try:
261+
value = obj[description_id]
262+
except AttributeError:
263+
# Fix #23: Silently ignore values that are not wrapped to Python
264+
# because we know user data we are interested in isn't any of
265+
# those anyway. Avoids object unknown in Python error.
266+
continue
267+
260268
user_data[key] = value
261269

262270
return user_data
@@ -290,7 +298,13 @@ def read(node) -> dict:
290298
def get_object_user_data_by_name(obj, user_data_name):
291299
for description_id, base_container in obj.GetUserDataContainer():
292300
if base_container[c4d.DESC_NAME] == user_data_name:
293-
return obj[description_id]
301+
try:
302+
return obj[description_id]
303+
except AttributeError:
304+
# Fix #23: Silently ignore values that are not wrapped to
305+
# Python because we know user data we are interested in isn't
306+
# any of those anyway. Avoids object unknown in Python error.
307+
continue
294308

295309

296310
def get_siblings(obj, include_self=True):

0 commit comments

Comments
 (0)