On 13/08/2018 at 05:22, xxxxxxxx wrote:
Hello Novacon,
yes, that is possible. See mfersaoui's code sample four posts above, it does exactly what you want.
For this to work, the code belongs into a Python tag and the button needs to be placed on the tag, NOT the host object.
Not sure, where you got the command ID from, maybe just a typo, the ID of "Render All Materials" is 12253.
Here's mfersaoui's code with a few more comments for better understanding:
import c4d
# Additional message() function to react to button presses
def message(id, data) :
if id == c4d.MSG_DESCRIPTION_COMMAND:
id2 = data['id'][0].id
if id2 == c4d.ID_USERDATA:
userDataId = data['id'][1].id
if userDataId == 1: # here you need to change the ID to the one of your button
# here you can do almost anything in reaction to the button press
#print "My User Data Tag Button"
c4d.CallCommand(12253) # Render All Materials
# main() function of the Python tag can still be used as normal.
# For simplicity of this example it's left empty.
def main() :
pass