Solved 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)

Here's code

  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?

Hi,

you probably have to check the dirty count of the BaseObjects attached to the FieldLayers that support such control object. The dirty method of the FieldList probably 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 FieldList and print out the layers and their attached objects (if there are any).

Cheers,
zipit

MAXON SDK Specialist
developers.maxon.net

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.

Best R.

@r_gigante Thanks man.

Can you please highlight proper way to check dirty of the layers?

right?

Hi,

you probably have to check the dirty count of the BaseObjects attached to the FieldLayers that support such control object. The dirty method of the FieldList probably 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 FieldList and print out the layers and their attached objects (if there are any).

Cheers,
zipit

MAXON SDK Specialist
developers.maxon.net

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 []