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

    Force InExclusionData update after remove object outside of In-/Exclusion User Data

    Cinema 4D SDK
    python r19
    2
    7
    1.7k
    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.
    • eZioPanE
      eZioPan
      last edited by y_puech

      Hi,
      I have a very simple scene:

      • A Null Object with an In-/Exclusion User Data
      • A Python Tag on the Null Object
      • some script in the Python Tag
      import c4d
      
      def main():
          obj = op.GetObject()
          objList = obj[c4d.ID_USERDATA,1] # point to the In-/Exclusion User Data
          print(objList.GetObjectCount())
      

      If I add scene objects into In-/Exclusion User Data, or remove object within In-/Exclusion User Data, Python Tag will print correct object count.

      But if I remove an object from the Object Manager which had been added into the In-/Exclusion User Data before, I can see object has been removed in In-/Exclusion User Data, but Python Tag report wrong object count (as if the object has not been removed).

      And only if I make some change within the In-/Exclusion User Data directly, that the Python Tag report correct count number again.

      I wonder if there is something I'm missing from the script for forcing InExclusionData update, or it's a bug in the "updating system"?

      Thanks!

      1 Reply Last reply Reply Quote 0
      • Y
        y_puech
        last edited by

        Hi,

        The InExcludeData object count does not always reflect the accurate number of valid objects depending on the scenarios.
        Additionally to calling GetObjectCount() the returned value from ObjectFromIndex() should be checked if it's not None.

        Former MAXON SDK Engineer

        1 Reply Last reply Reply Quote 3
        • eZioPanE
          eZioPan
          last edited by

          Hi, y_puech!

          Thank you for replying!
          I use

          i = 0
          while True:
              obj = InExData.ObjectFromIndex(doc,i)
              if obj == None:
                  break
          i += 1
          

          to get right result.

          1 Reply Last reply Reply Quote 0
          • Y
            y_puech
            last edited by m_adam

            Hi,

            Just a quick note on your code. A pythonic solution could be:

            count = inExData.GetObjectCount()
            for i in xrange(count):
                obj = inExData.ObjectFromIndex(doc, i)
                if obj is None:
                    continue
            

            Why are you breaking out from the loop with the first invalid object in the InExcludeData?

            Former MAXON SDK Engineer

            1 Reply Last reply Reply Quote 3
            • eZioPanE
              eZioPan
              last edited by eZioPan

              Oh! Sorry! I know what you mean in the previous post now. I'm doing the wrong way. Your solution is correct!

              By the way, I wonder if there is a situation where the actual object counts are greater than GetObjectCount() returned?

              Y 1 Reply Last reply Reply Quote 0
              • Y
                y_puech @eZioPan
                last edited by y_puech

                By the way, I wonder if there is a situation where the actual object counts are greater than GetObjectCount() returned?

                This should never happen.

                Thanks for marking the topic as solved. Note that you can mark a specific post as the correct answer or solution. See step 5 in Q&A New Functionality.

                Former MAXON SDK Engineer

                eZioPanE 1 Reply Last reply Reply Quote 2
                • eZioPanE
                  eZioPan @y_puech
                  last edited by eZioPan

                  Hi, @y_puech I may find a bug of the forum about "mark a post correct answer", discussion post here: Cannot mark post as answer
                  Once this bug solved, I will re-edit this topic and posts correctly.

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