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

    CallCommand with modifier key

    General Talk
    3
    4
    748
    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.
    • J
      JohnSmith
      last edited by

      Hello! I created an interactive toolbar where content (plugins and scripts) appear depending on the conditions set in the plugin settings.
      StaX.th.jpg
      The problem is that many of my scripts have multiple trigger modes with modifier keys, and I call them using the c4d.CallCommand(id) command.
      I can find out which key is pressed like this:

      bc = c4d.BaseContainer()
      c4d.gui.GetInputState(c4d.BFM_INPUT_KEYBOARD, c4d.BFM_INPUT_CHANNEL, bc)
      key = bc[c4d.BFM_INPUT_QUALIFIER]
      

      How to run a c4d.CallCommand(id) given the key pressed?

      I use c4d.CallCommand(id) because I first create a list of dictionaries, each of which describes a button and its logic. Here is the dictionary example:

      section = 'button1'
      Btype = 'button'
      number = 1     # for sorting buttons
      pID = 600000028
      types = [5100, 5101]
      logic_modes = [11, 5, 6, 13]
      selection = 'True'
      
      {'name': section, 'type': Btype, 'number': number, 'plugin_id': pID, 'obj_types': types, 'logic_modes': modes, 'selection': selection}
      

      I write data to an ini file using configparser. After reading the data from the file, I register each button under the plugin id and check if it was clicked:

      def Command(self, paramid, msg):
          for button in self.button_data:
              if button['type'] == 'button' and paramid == button['plugin_id']:
                  c4d.CallCommand(button['plugin_id'])
          return True
      

      I hope this description will help you better understand my problem. Thanks!

      1 Reply Last reply Reply Quote 0
      • kbarK
        kbar
        last edited by kbar

        This may be an alternative to your current approach (or possibly exactly the same?): You could make your own UserArea and draw the icons manually yourself. Then you can handle any number of modifier keys and call your commands using the SubID to indicate to the script what it should do (CommandData.ExecuteSubID).

        https://www.gamelogicdesign.com
        https://www.plugins4d.com

        1 Reply Last reply Reply Quote 0
        • ferdinandF
          ferdinand
          last edited by ferdinand

          Hi @JohnSmith,

          thank you for reaching out to us and thanks @kbar for jumping in. What is not quite clear to us about your problem, is the nature of your plugins and scripts.

          It would be nice if you could clarify the scope of them. Are they all provided by yourself / have you authority on their code or are you seeking a general solution?

          1. When you have full authority on the code of the CommandData plugins, then you can register sub ids and implement CommandData.ExecuteSubID as @kbar already pointed out and so expose the different modes a command can execute to the outside world, i.e. make it accessible via c4d.CallCommand.
          2. For all other cases, be it you having no code authority, or be it other forms of plugins, this won't work. Because Cinema does not enforce the way how modifier keys are implemented (in case of CommandData) or the whole process is opaque (for scripts or ToolData for example). Your best solution here is to use an external keyboard interface library (you can find multiple of them on PyPI). Please note that this a workaround that is not officially supported and you might run into severe problems, especially regarding supporting all platforms.

          If we misunderstood your problem, please feel free to clarify any misunderstandings.

          Cheers
          Ferdinand

          MAXON SDK Specialist
          developers.maxon.net

          1 Reply Last reply Reply Quote 0
          • J
            JohnSmith
            last edited by

            For some reason that I do not understand, the modifier keys did not work before, now they work. Implementation of the plugin via UserArea instead of GeDialog will be more convenient, thank you for your answers, I will study this part of the SDK further.
            alt text

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