Update generator plugin with FieldList sub-objects being updated
Generator doesn't receive updates if objects attached to a FieldList are updated (moved in space, or resized, or whatever)
def GetDirty(self, op, doc): if op is None or doc is None: raise RuntimeError("Failed to retrieves op or doc.") self.DIRTY_SELF = op.GetDirty(c4d.DIRTYFLAGS_MATRIX | c4d.DIRTYFLAGS_DATA | c4d.DIRTYFLAGS_DESCRIPTION) if op[PLUGIN_FIELD] is not None: # PLUGIN_FIELD is as FIELDLIST defined in a res file self.DIRTY_FIELDS = op[PLUGIN_FIELD].GetDirty(doc) return self.DIRTY_SELF + self.DIRTY_FIELDS
op[PLUGIN_FIELD].GetDirty(doc) is only changed when properties changed inside of the FieldList (like opacity, blend-mode and so on).
But it updates if I'll disable and enable generator in Object Manager
Should I iterate through FieldList object and through child GroupField sub-objects to check if they are also dirty?
r_gigante last edited by
Hi @baca, thanks for reaching out us.
With regard to your question, as written in the documentation, FieldList::GetDirty() returns the dirty state of the GUI only. The dirty state of the object included in the list as well as of the object owning the list should be checked independently by checking each of them.
@r_gigante Thanks man.
Can you please highlight proper way to check dirty of the layers?
- get FieldList's root FieldList.GetLayersRoot()
- get root's direct children GeListNode.GetChildren()
- get each child dirtyness, and if child also has GeListNode.GetChildren() list, check their dirty recursively as well
zipit last edited by
you probably have to check the dirty count of the
BaseObjectsattached to the
FieldLayersthat support such control object. The dirty method of the
FieldListprobably only considers the layer nodes as relevant data for its evaluation. I made here a post on a similar topic, which shows you how to iterate through a
FieldListand print out the layers and their attached objects (if there are any).
Thamks @zipit, it works.
Just noticed it has to be adjusted with GetClone(), otherwise I'm getting "link is not alive" error
def get_field_layers(op): """ Returns all field layers that are referenced in a field list. """ def flatten_tree(node): """ Listifies a GeListNode tree. """ res =  while node: res.append(node.GetClone()) for child in node.GetChildren(): res += flatten_tree(child) node = node.GetNext() return res # get the GeListHead for the FieldList root = op.GetLayersRoot() if root is None: return  # Get the first node under the GeListHead first = root.GetFirst() if first is None: return