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

    Change Icon Color parameter

    Cinema 4D SDK
    2024 python
    3
    6
    712
    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.
    • chuanzhenC
      chuanzhen
      last edited by chuanzhen

      hi,
      I use script to create bone and insert it to document, set it Icon Color=Display Color,Why does the Icon Color parameter of the object turn to Custom when I click on it.

      import c4d
      
      doc: c4d.documents.BaseDocument  # The currently active document.
      op: c4d.BaseObject | None  # The primary selected object in `doc`. Can be `None`.
      
      def main() -> None:
          for i in range(2):
              obj = c4d.BaseObject(c4d.Ojoint)
              obj[c4d.ID_BASELIST_ICON_COLORIZE_MODE] = 2
              obj[c4d.ID_BASEOBJECT_USECOLOR] = 2
              obj[c4d.ID_BASEOBJECT_COLOR] = c4d.Vector()
      
              obj.SetName(str(i))
              doc.InsertObject(obj)
          c4d.EventAdd()
      
      
      if __name__ == '__main__':
          main()
      

      Thanks for any help!

      相信我,可以的!

      1 Reply Last reply Reply Quote 0
      • JH23J
        JH23
        last edited by

        Hello chuanzhen,
        I tried this, you're right, it's strange, but curiously if a value is assigned to the color it manages to be created with the defined color without the need for interaction, this is a possible solution, even so I would like to know what could be happening.
        Cinema_4D_72OIMo0GEM.mp4
        Cheers,
        James H.

        chuanzhenC 1 Reply Last reply Reply Quote 0
        • chuanzhenC
          chuanzhen @JH23
          last edited by

          @JH23 Thanks for your help,this is indeed a solution.
          For existing objects in Object Manager, using this code is effective, but creating a new object and setting it up yields a different result, which is confusing.

          @chuanzhen said in Change Icon Color parameter:

          import c4d
          
          doc: c4d.documents.BaseDocument  # The currently active document.
          op: c4d.BaseObject | None  # The primary selected object in `doc`. Can be `None`.
          
          def main() -> None:
              for i in range(2):
                  obj = c4d.BaseObject(c4d.Ojoint)
                  obj[c4d.ID_BASELIST_ICON_COLORIZE_MODE] = 2
                  obj[c4d.ID_BASEOBJECT_USECOLOR] = 2
                  obj[c4d.ID_BASEOBJECT_COLOR] = c4d.Vector()
          
                  obj.SetName(str(i))
                  doc.InsertObject(obj)
              c4d.EventAdd()
          
          
          if __name__ == '__main__':
              main()
          

          相信我,可以的!

          JH23J 1 Reply Last reply Reply Quote 1
          • JH23J
            JH23 @chuanzhen
            last edited by

            Hi @chuanzhen,
            I wanted to say that it is confusing that it fails to create an automatic color when defining the use of icons with custom colors, I suspect a reason why this happens but I am not at all sure, I am still happy that this solution works for you, even so I would like to know if this is something planned or some kind of bug.
            Cheers,
            James H.

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

              Hi @chuanzhen,

              The "Display Color" value of the "Icon Color" attribute is a dynamic value (comparing to "None" and "Custom" being static values), this was explained in the related thread: Python Documentation - Icon Color. This is the reason why it requires special handling, namely (as Manuel explained in the related thread: Simple Organisational Structure Generation Script), one needs to send a c4d.MSG_GETCUSTOMICON_SETTINGS message to the object to properly set this attribute. Please check the example code snippet that shows its usage.

              Cheers,
              Ilia

              Example code, showing the usage of the c4d.MSG_GETCUSTOMICON_SETTINGS message:

              import c4d
              
              doc: c4d.documents.BaseDocument  # The currently active document.
              op: c4d.BaseObject | None  # The primary selected object in `doc`. Can be `None`.
              
              def main() -> None:
                  obj = c4d.BaseObject(c4d.Ojoint)
                  
                  # Configure object display color attribute
                  obj[c4d.ID_BASEOBJECT_USECOLOR] = c4d.ID_BASEOBJECT_USECOLOR_ALWAYS
                  obj[c4d.ID_BASEOBJECT_COLOR] = c4d.Vector(1, 0, 1)
              
                  # Configure object icon color attribute
                  settings = c4d.CustomIconSettings()
                  settings._colorMode = 2
                  obj.Message(c4d.MSG_GETCUSTOMICON_SETTINGS, {'setting': settings})
                  obj[c4d.ID_BASELIST_ICON_COLORIZE_MODE] = c4d.ID_BASELIST_ICON_COLORIZE_MODE_CUSTOM + 1
              
                  obj.SetName("Magenta Joint")
                  doc.InsertObject(obj)
              
              
              if __name__ == '__main__':
                  main()
                  c4d.EventAdd()
              

              MAXON SDK Specialist
              developers.maxon.net

              chuanzhenC 1 Reply Last reply Reply Quote 1
              • chuanzhenC
                chuanzhen @i_mazlov
                last edited by

                @i_mazlov Thanks for your help, it works well.

                相信我,可以的!

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