Change Icon Color parameter
-
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!
-
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. -
@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()
-
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. -
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,
IliaExample 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()
-
@i_mazlov Thanks for your help, it works well.