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
    • Register
    • Register
    • Login

    2024.4 update makes CheckDirty error for ObjectData plugin Fieldlist

    Cinema 4D SDK
    python macos 2024
    3
    5
    962
    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.
    • mikeudinM
      mikeudin
      last edited by mikeudin

      Hello there!
      After updating to Cinema 4D 2024.4 my plugin causes this Exception:

      ReferenceError: the object 'c4d.modules.mograph.FieldLayer' is not alive
      The above exception was the direct cause of the following exception:
      SystemError: <function VTexterData.CheckDirty at 0x4b3546450> returned a result with an exception set
      

      It happens after adding some fieldlayer to the Field List. What is problem it can be?
      Here is my CheckDirty func:

      def get_field_layers(op):
          
          """ 
          Returns all field layers that are referenced in a field list.
          Source: https://plugincafe.maxon.net/topic/11809/iterating-trough-field-list/2?_=1678357010902
      
          """
          
          def flatten_tree(node):
              
              """ Listifies a GeListNode tree. """
              
              r = []
              while node:
      
                  r.append(node)
      
                  for child in node.GetChildren():
                      
                      r += flatten_tree(child)
                  
                  mask = node.GetMaskHead()
      
                  if mask:
                      for child in mask.GetChildren():
                          r += flatten_tree(child)
      
                  node = node.GetNext()
              
              return r
          
          # 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 []
          
          # traverse the graph
          return flatten_tree(first)
             
      def CheckDirty(self, op, doc):
          
          fdirty = 0
          desc = op.GetDescription(c4d.DESCFLAGS_DESC_NONE)
          bc = desc.GetParameterI(c4d.VFTAG_TEXT_ANIMATOR_TRANSFORM, None)
          if not bc:
              return
      
          fenabled = [t[c4d.VFTAG_TEXT_ANIMATOR_ENABLE] for t in op.GetTags() if t.CheckType(c4d.Tvfanimatortag)]
          
          get_tvalue = lambda i: fenabled[i] if i < len(fenabled) else False #get correct value in case if tags count != axes count
      
          tfields = [op[c4d.VFTAG_TEXT_ANIMATOR_FIELDS + i] for i in range(len(bc[c4d.DESC_CYCLE])) if get_tvalue(i)]
          
      
          if not tfields:
              return 
      
          for f in tfields:
              if not f or not f.HasContent(): continue
              
              fdirty += f.GetDirty(doc)
              for l in get_field_layers(f):
                  
                  if not l.IsAlive(): continue
                  
                  if l.GetTypeName() in ('Time','Decay','Delay') and l.GetStrength() > 0.0:
                      fdirty += doc.GetTime().GetFrame(doc.GetFps())
                      continue
                  
                  fdirty += l.GetDirty(c4d.DIRTYFLAGS_ALL)
                  lobject = l.GetLinkedObject(doc)
                  if lobject:
                      fdirty += lobject.GetDirty(c4d.DIRTYFLAGS_MATRIX | c4d.DIRTYFLAGS_DATA | c4d.DIRTYFLAGS_DESCRIPTION)
      
          fdirty += op.GetDirty(c4d.DIRTYFLAGS_MATRIX)
      
          if fdirty != self.lastFieldsDirty:
              
              self.lastFieldsDirty = fdirty
      
              op.SetDirty(c4d.DIRTYFLAGS_DATA)
      

      Checkout my python tutorials, plugins, scripts, xpresso presets and more
      https://mikeudin.net

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

        Hey @mikeudin,

        Thank you for reaching out to us and I am sorry for the inconvenience this has caused you. This error very likely means that there is a bug in our code as a node reference should not loose connection in this context. It would have been better if you have included line numbers in your stack trace, as without them I have to guess, but it seems very likely that the return r of flatten_tree is the culprit with returning a dangling reference to a FieldLayer, a 'not alive' node.

        While the code you have posted is sufficient for understanding the problem, we will need your full plugin code to debug the problem and possibly provide a temporary workaround before a fix arrives.

        • Please send us your full plugin to sdk_support(at)maxon(dot(net).
        • Please also provide an example scene which triggers the problem.
        • Please also include a crash/bug report in the exact form lined out here.
        • Finally, please make sure to provide us the unencrypted form of your plugin, or to give us explicit permission to decrypt it (we obviously prefer the former). We will have to look at your code and debug the actual plugin.

        Cheers,
        Ferdinand

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 0
        • mikeudinM
          mikeudin
          last edited by

          @ferdinand

          It would have been better if you have included line numbers in your stack trace, as without them I have to guess...
          

          Error messages going not in traceback format 🤔
          Here is a sample plugin with same issue.
          odatafieldsexample.zip
          CheckDirty.2024.4.bug.png

          Checkout my python tutorials, plugins, scripts, xpresso presets and more
          https://mikeudin.net

          ferdinandF i_mazlovI 2 Replies Last reply Reply Quote 0
          • ferdinandF
            ferdinand @mikeudin
            last edited by ferdinand

            Hey @mikeudin,

            ah okay my bad, I thought you had a more expressive stack trace and just truncated it. We will have a look and keep you posted. Although I am fairly sure that this is a bug, we will wait with promoting/moving this topic to bugs until we have confirmed that it is a bug.

            Cheers,
            Ferdinand

            edit: I just looked into your zip. At least I do neither see there a scene file nor a bug report. Please provide these. When not, and we cannot reproduce an issue on first attempt without any instructions, we will simply declare it as "not reproducible". Even when you consider things obvious or trivial, you must provide reproduction steps and a scene.

            MAXON SDK Specialist
            developers.maxon.net

            1 Reply Last reply Reply Quote 0
            • i_mazlovI
              i_mazlov @mikeudin
              last edited by

              Hi @mikeudin ,

              To me it sounds pretty much like this issue here: issue with inserting fieldlayers in r2024, particularly after I couldn't reproduce this issue with the internally available next version of cinema.

              Cheers,
              Ilia

              MAXON SDK Specialist
              developers.maxon.net

              1 Reply Last reply Reply Quote 0
              • First post
                Last post