Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Call Command

    PYTHON Development
    0
    4
    1.1k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

      On 11/08/2018 at 18:22, xxxxxxxx wrote:

      Hi

      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)

      Thanks 🙂

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        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
        
        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          On 13/08/2018 at 07:48, xxxxxxxx wrote:

          Hi Andreas

          Thanks a lot that worked 🙂

          Is there anyway of getting it to work on the user data of a Null object?

          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

            On 23/08/2018 at 08:11, xxxxxxxx wrote:

            Hi,

            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.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post