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

    Fieldlist HasContent() GetCount() bug workaround

    Cinema 4D SDK
    python r23
    3
    3
    551
    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

      Re: FieldList.GetCount Bug
      Hello!
      I have a same issue but @pyr's workaround not working for me. Because the issue of fieldlayers based on linked objects. But if FieldList have fieldlayers without linked objects like Solid this code

      def CheckFieldHealth (self,doc,field):
      
              if field == None: return False
      
              def get_field_layers(field):
                  """ Returns all field layers that are referenced in a field list.
      
                  https://developers.maxon.net/forum/topic/11809/iterating-trough-field-list/2
      
                  """
      
                  def flatten_tree(node):
                      """ Listifies a GeListNode tree.
                      """
                      res = []
                      while node:
                          res.append(node)
                          for child in node.GetChildren():
                              res += flatten_tree(child)
                          node = node.GetNext()
                      return res
      
                  # get the GeListHead for the FieldList
                  root = field.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)
      
              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
      
      
              return True
      

      will give same result as fieldlayer with destructed object. So how to figure out type of fieldlayer: FieldObject, Fieldlayer, Modifier Layer? Is this layer based on object or tag from OM or not? Thank you!

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

      1 Reply Last reply Reply Quote 0
      • ManuelM
        Manuel
        last edited by Manuel

        hi,

        unfortunately, there is nothing in the SDK that will help you in this regard. The only solution i see is to check the type of the layer and hardcode if that layer can have a link or not. Could be just an array containing the IDs of layers that do not have this link.

        Cheers,
        Manuel

        MAXON SDK Specialist

        MAXON Registered Developer

        1 Reply Last reply Reply Quote 0
        • M
          m_adam
          last edited by

          Hello @mikeudin,

          without further questions or postings, we will consider this topic as solved by Monday 05/06/2023 and flag it accordingly.

          Thank you for your understanding,
          Maxime.

          MAXON SDK Specialist

          Development Blog, MAXON Registered Developer

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