On 11/08/2018 at 18:22, xxxxxxxx wrote:
I am trying to do the same thing with a button. But instead of creating a hair object I need it to run "render all materials" from the function menu. Is that possible?
render all materials call command is - c4d.CallCommand(1225)
On 13/08/2018 at 05:22, xxxxxxxx wrote:
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'].id if id2 == c4d.ID_USERDATA: userDataId = data['id'].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
On 13/08/2018 at 07:48, xxxxxxxx wrote:
Thanks a lot that worked :)
Is there anyway of getting it to work on the user data of a Null object?
On 23/08/2018 at 08:11, xxxxxxxx wrote:
I'm terribly sorry, I somehow lost your follow up question.
It's not directly possible (MSG_DESCRIPTION_COMMAND is not forwarded from objects to tags), but there's a workaround described in the Listening for Checkbox Clicks in User Data thread.