If you delete a field object in the object manager, GetCount() does not change. Worse if you repeat the whole thing, the value even increases.
The issue also apply to HasContent()
workaround / seems to work in my usecase
def CheckFieldHealth (self,doc,field):
if field == None: return False
""" Returns all field layers that are referenced in a field list.
""" Listifies a GeListNode tree.
res = 
for child in node.GetChildren():
res += flatten_tree(child)
node = node.GetNext()
# get the GeListHead for the FieldList
root = field.GetLayersRoot()
if root is None:
# Get the first node under the GeListHead
first = root.GetFirst()
if first is None:
# traverse the graph
error = 0
for f in get_field_layers(field):
if f.GetName() != None and f.GetLinkedObject(doc) == None and f[c4d.DESC_NAME]== None:
error += 1
if error == field.GetCount(): return False
Hi @pyr, I've just reached the development team about it.
So for them, this is not a bug since FieldList store only baseLink.
In Python, we don't have BaseLink, but if you are not aware of what it is, please read BaseLink Manual.
But since there is no BaseLink in Python, if a link points to a destructed object (like in your case, Python simply returns None)
So I guess your workaround is ok.