detect a material has changed



  • 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



  • 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



  • 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



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

    Hello,

    a tag's Execute function is called pretty much every time something happens in the scene. So you could check there if the material's dirty state 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



  • On 02/09/2014 at 02:47, xxxxxxxx wrote:

    Hello Sebastian,

    thank you for the reply!
    It works !

    best wishes
    Martin


Log in to reply