Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Update generator plugin with FieldList sub-objects being updated

    Cinema 4D SDK
    python
    3
    5
    523
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • bacaB
      baca
      last edited by

      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?

      1 Reply Last reply Reply Quote 0
      • r_giganteR
        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.

        Best R.

        bacaB 1 Reply Last reply Reply Quote 0
        • bacaB
          baca @r_gigante
          last edited by

          @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

          right?

          1 Reply Last reply Reply Quote 0
          • ferdinandF
            ferdinand
            last edited by

            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

            bacaB 1 Reply Last reply Reply Quote 0
            • bacaB
              baca @ferdinand
              last edited by

              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 []
              
              1 Reply Last reply Reply Quote 0
              • First post
                Last post