Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python 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

    Shortcut for CommandData is not working

    Scheduled Pinned Locked Moved PYTHON Development
    5 Posts 0 Posters 661 Views
    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 Offline
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 18/10/2012 at 09:09, xxxxxxxx wrote:

      Hi,

      I have a very simple Python CommandData plugin, which does nothing more than print "Hello" into the console when it is selected in the Plugins Menu.

      My problem is that I cannot assign a shortcut to this plugin. Well I actually can assign it, but pressing the shortcut will not execute the plugin. Does anyone know what I am doing wrong?

      I should add that if I click the Execute button in the Command Manager, next to where I setup the shortcuts, the plugin does get executed, but never if I actually press that shortcut.

      import c4d   
      import os   
      from c4d import documents, plugins, bitmaps   
        
      PLUGIN_ID = 1234588880   
        
      class MYPLUGIN(plugins.CommandData) :   
           pass   
              
           def Execute(self, doc) :   
                print 'Hello'   
                return True   
              
      if __name__ == "__main__":   
           okyn = plugins.RegisterCommandPlugin(id=PLUGIN_ID, str="MyPlugin", info=c4d.PLUGINFLAG_COMMAND_HOTKEY, icon=None, help="", dat=MYPLUGIN())   
           print "MyPlugin initialized ", okyn
      
      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 19/10/2012 at 03:38, xxxxxxxx wrote:

        Hi,

        Do you really want to develop an hotkey command or just assign a shortcut to a command? This isn't the same.
        Have you tried to register the command plugin with info=0 or info=c4d.PLUGINFLAG_COMMAND_STICKY?

        I asked the developers why Execute() isn't called when a command is registered with PLUGINFLAG_COMMAND_HOTKEY flag.

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

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 19/10/2012 at 03:54, xxxxxxxx wrote:

          Originally posted by xxxxxxxx

          Hi,
          Do you really want to develop an hotkey command or just assign a shortcut to a command? This isn't the same.
          Have you tried to register the command plugin with info=0 or info=c4d.PLUGINFLAG_COMMAND_STICKY?
          I asked the developers why Execute() isn't called when a command is registered with PLUGINFLAG_COMMAND_HOTKEY flag.

          Yeah, I think I did not quite understand the meaning of PLUGINFLAG_COMMAND_HOTKEY. My command should be primarilily be executed via a hotkey, which the user can assign manually in the Customize Commands window. I did also try with info=0.

          I also tested the 2 example plugins: the Cineversity and the memory plugin from the examples folder of the Python documentation. I have no problems assigning hotkeys to these: But my code I posted in the first post will never be executed when pressing the assigned hotkey.

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

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 19/10/2012 at 04:19, xxxxxxxx wrote:

            Originally posted by xxxxxxxx

            Yeah, I think I did not quite understand the meaning of PLUGINFLAG_COMMAND_HOTKEY. My command should be primarilily be executed via a hotkey, which the user can assign manually in the Customize Commands window. I did also try with info=0.

            A hotkey is like the way keys 4 (move), 5 (scale) or 6 (rotate) works.

            Originally posted by xxxxxxxx

            I also tested the 2 example plugins: the Cineversity and the memory plugin from the examples folder of the Python documentation. I have no problems assigning hotkeys to these: But my code I posted in the first post will never be executed when pressing the assigned hotkey.

            Yes, this is because it seems Execute() isn't called when a command is registered with PLUGINFLAG_COMMAND_HOTKEY flag and the hotkey assigned is pressed.
            Hotkeys assigned to your command plugin work if it's registered with info=0 or info=c4d.PLUGINFLAG_COMMAND_STICKY.

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

              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

              On 23/10/2012 at 04:01, xxxxxxxx wrote:

              OK, thank you for clearing this up!

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