IsDirty() with arbitrary flags

On 14/01/2018 at 18:05, xxxxxxxx wrote:

I have a modifier plugin that contains a drop-down menu and other settings.
I want to check if this drop-down menu is changed/IsDirty() but DIRTYFLAGS_DATA only outputs True when any of the parameters are changed. 
Is it possible to output Bool value if only this drop-down menu is changed?

On 15/01/2018 at 03:01, xxxxxxxx wrote:


in general the dirty flags are only made to provide information about a change, it's not made to detect a specific change.

Just to make sure, as it's not completely clear from your post, you are looking for a parameter change in your own custom ObjectData modifier, right? To recap, IsDirty() may only be used in an ObjectData plugin to check its own dirtiness.

In order to detect (or react to) the change of a single parameter of your ObjectData, you have a bunch of options.
You can override SetDParameter() and react to setting of a specific parameter directly.
Or you can react to one of the various description related messages, like MSG_DESCRIPTION_POSTSETPARAMETER or MSG_DESCRIPTION_VALIDATE. This really depends on your needs. Please note, while there's no DescriptionPostSetValue in Python, the information is in the data dictionary, the key is 'descid'.

While only in C++ docs, maybe the NodeData manual can also provide some more context on this topic: NodeData::Message() Manual and NodeData::SetDParameter() Manual.

On 15/01/2018 at 05:27, xxxxxxxx wrote:

Sorry. Seems like I did not explain it clearly.

I have an object a Radio Buttons and a Slider.
I need to catch a moment when a value of this Radio Buttons is changed and if this is True, I need to decrease the value of this slider down to 0.

I guess [NodeData.Message()]( is what I need but I can't find an appropriate Parameters Type.

    def Message(self, node, type, data) :
        if type == c4d.????????????????:
            if data["id"][0].id == VALUES: node[c4d.SLIDER] = 0
        return True

On 15/01/2018 at 05:30, xxxxxxxx wrote:

I'm getting this error:
Traceback (most recent call last) :
  File "'test plugin.pyp'", line 26, in Message
KeyError: 'id'

  1. import c4d
  2. from c4d import plugins
  3. import os
  5. TESTPLUGIN_ID = 1040447
  6. VALUES = 1000
  7. V1 = 1001
  8. V2 = 1002
  9. V3 = 1003
  10. V4 = 1004
  11. V5 = 1005
  13. SLIDER = 1006
  15. class Testplugin(c4d.plugins.ObjectData) :
  17.     def Init(self, node) :
  19.         self.InitAttr(node, int, VALUES)
  20.         node[VALUES] = 1001
  22.         return True
  24.     def Message(self, node, type, data) :
  25.         if type == c4d.MSG_DESCRIPTION_POSTSETPARAMETER:
  26.             if data["id"][0].id == VALUES: node[c4d.SLIDER] = 0
  27.             else: node[c4d.SLIDER] = 0
  29.         return True
  31. if __name__ == "__main__":
  32.     bmp = c4d.bitmaps.BaseBitmap()
  33.     dir, file = os.path.split(__file__)
  34.     fn = os.path.join(dir, "res", "icon.tif")
  35.     bmp.InitWith(fn)
  36.     result = plugins.RegisterObjectPlugin(
  37.         id = TESTPLUGIN_ID, 
  38.         str = "Test Plugin", 
  39.         g = Testplugin, 
  40.         description = 
  41.         "Otestplugin", 
  42.         info = c4d.OBJECT_GENERATOR, 
  43.         icon = bmp)

On 16/01/2018 at 02:58, xxxxxxxx wrote:


the content passed via the data parameter of the Message() function depends on the type of message. In C++ data is pointing to a message specific structure, which in Python gets converted into a dictionary. Thus the content of the dictionary is equally message specific. For MSG_DESCRIPTION_POSTSETPARAMETER the key to access the DescID is "descid" as mentioned in my previous post.

On 16/01/2018 at 04:09, xxxxxxxx wrote:

It worked, Thanks!

On 21/01/2018 at 15:48, xxxxxxxx wrote:

    def Message(self, node, type, data) :
        if type == c4d.MSG_DESCRIPTION_CHECKUPDATE:
            if data["descid"][0].id == MY_TEST_VALUE: print 'Update'

It works in R19 but not in older versions. Is it available only for R19?

On 22/01/2018 at 02:57, xxxxxxxx wrote:


yes, support for MSG_DESCRIPTION_CHECKUPDATE got added with R19.
Here's where you can find such info: Python What is New