Shortcut for CommandData is not working

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

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.

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.

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.

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!