Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python 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
    • Recent
    • Tags
    • Users
    • Login

    Object Use Color Property

    Scheduled Pinned Locked Moved PYTHON Development
    8 Posts 0 Posters 690 Views
    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.
    • H Offline
      Helper
      last edited by

      On 23/03/2013 at 10:16, xxxxxxxx wrote:

      I have script that changes the objects display color. First turning on the Use Color option with this code:

      obj = doc.GetActiveObject()
      bc = obj.GetData()
      bc.SetLong(c4d.ID_BASEOBJECT_USECOLOR, 2)
      obj.SetData(bc)
      

      It even prints the correct value when I print GetLong, but the object doesn't change?

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 23/03/2013 at 12:22, xxxxxxxx wrote:

        We're supposed to use the Get&Set Parameters method as much as possible. And only use BaseContainers as a very last resort.

        In Python. That means using a bracketed syntax like this:

        import c4d  
        def main() :  
          obj = doc.GetActiveObject()  
          obj[c4d.ID_BASEOBJECT_USECOLOR]=2     #Equivalent to SetParameter() in C++     
          c4d.EventAdd()  
          
        if __name__=='__main__':  
          main()
        

        -ScottA

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 23/03/2013 at 12:56, xxxxxxxx wrote:

          Thanks Scott! I was racking my brain over that simple problem. Still seems like the base container should have worked though.

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            On 24/03/2013 at 09:22, xxxxxxxx wrote:

            BaseContainers don't work for everything. For example, you can't get the attributes of a light that way - you have to use Get/SetParameter.

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              On 24/03/2013 at 11:21, xxxxxxxx wrote:

              Thanks spedler, I guess I'm not really sure why someone would use a BaseContainer then?

              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

                On 24/03/2013 at 11:39, xxxxxxxx wrote:

                Most parameters are accessible and modifiable via the BaseContainer, but not all. Using the container
                directly offers certain advantages in speed (especially when using the fixed-type setters and getters)
                and usage (eg. merging containers).

                -Niklas

                1 Reply Last reply Reply Quote 0
                • H Offline
                  Helper
                  last edited by

                  On 24/03/2013 at 14:13, xxxxxxxx wrote:

                  The things we grab using Get&Set Parameters are set up to work that way by Maxon.
                  So it's considered a convenience.
                  Plus it's also considered a safer way to work. Since you're using code they set up for us to use.

                  The containers are there in case you want to be a mad scientist. !Smile[URL-REMOVED]
                  They let us create something brand new on our own that Maxon hasn't set up for us already.

                  -ScottA


                  [URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.

                  1 Reply Last reply Reply Quote 0
                  • H Offline
                    Helper
                    last edited by

                    On 24/03/2013 at 16:54, xxxxxxxx wrote:

                    Thanks for clarifying this confusing topic guys! Ill stick to the get/set. It really is much easier to work with.

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