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

    detect a material has changed

    Scheduled Pinned Locked Moved PYTHON Development
    5 Posts 0 Posters 528 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 25/08/2014 at 12:51, xxxxxxxx wrote:

      Hi there,

      how can I detect that the user has changed a property of a shader which is used in a material? For example in the color channel.

      Thanks in advance
      Martin

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

        On 25/08/2014 at 15:23, xxxxxxxx wrote:

        Hi Monkeytack,

        I don't think there's a built-in method for detecting that specific change. In similar situations (detecting changes in Layer Selection, etc) - I've cached a copy of the object I'm monitoring and then checked it against the live copy every time there's a c4d.EVMSG_CHANGE message.

        -Donovan

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

          On 28/08/2014 at 04:27, xxxxxxxx wrote:

          thanks for the reply!

          do you have an example script?
           I was not able to implement your description?

          I have a tag plugin and I want to notify changes of the material which is, as the tag plugin, assigned to an object.
          How can I notify an EventMessage in my tag plugin and do the cache?

          Martin

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

            On 28/08/2014 at 13:07, xxxxxxxx wrote:

            Hello,

            a tag's Execute[URL-REMOVED] function is called pretty much every time something happens in the scene. So you could check there if the material's dirty state[URL-REMOVED] changed:

              
            class ExamplePythonTag(plugins.TagData) :  
               
              materialDirtyStatus = 0  
                
              def Init(self, node) :  
                  # init your plugin here  
                  return True  
                    
                
              def Execute(self, tag, doc, op, bt, priority, flags) :  
                    
                  # search for texture tag  
                  textureTag = op.GetTag(c4d.Ttexture)  
                  if textureTag != None:  
                    
                      # get material  
                      material = textureTag.GetMaterial()  
                      if material != None:  
                            
                          # get dirty state  
                          dirty = material.GetDirty(c4d.DIRTY_DATA)  
                            
                          # compare  
                          if dirty != self.materialDirtyStatus:  
                              print("material changed...")  
                              self.materialDirtyStatus = dirty  
                
                    
                  return c4d.EXECUTIONRESULT_OK  
            

            best wishes,
            Sebastian


            [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 02/09/2014 at 02:47, xxxxxxxx wrote:

              Hello Sebastian,

              thank you for the reply!
              It works !

              best wishes
              Martin

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