Create a command that can be assigned a shortcut?

Hi, I’m new here. I’m trying to figure out how to create a command with pyrevit that can be assigned a shortcut (so to make it show up in the “ks” keyboard shortcut dialog). I thought that it will be as simple as creating:


and restarting revit, but that doesn’t seem to work - no command shows up in revit.

Or is it something that you need to setup in the script itself?

I think nobutton can only be accessed using pyrevit search in UI. Can you see all the other buttons but not your nobutton?

If you make it a regular pushbutton then you can assign a shortcut to the button.

Otherwise IExternalCommand in a dll if you absolutely don’t want a button

@jpitts thanks, but it’s not showing up in the pyRevit Search netiher. Should it use the name given in the folder or do you need to specify it in the script itself? Or do you need to add a yaml or json file to it?

I thought that it may be caused due to the folder being on a network location accessed via vpn, but restarting revit didn’t help. contains only “print(“test”)” right now by the way - does it need something else to be loaded?

So after 3 hours of testing it became clear that pyRevit won’t work unless you create this pointless extensions/tab/panel/button hierarchy.

Sorry, but that is a really stupid idea. Look up how easy it is to add python scripts in Rhino.

I agree with you that the folder hierarchy is not so user firendly, and I started a discussion between the project contributors to review that.

But you’re the first one to call it a “really stupid” idea, and I think that Ehsan, the creator of pyRevit, doesn’t deserve insults for coming up with an idea that everybody else use and profit for free, thanks to the tremendous job he did.

pyRevit scope is to quickly create the UI (tabs, panels, buttons and so on) without having to learn about the .NET boilerplate code to achieve the same result.
As I told you in the GhitHub issues (I suppose it’s you behind those enigmatic usernames :sweat_smile: ) this is not the tool you are looking for. Once again, check out RevitPythonShell for running scripts directly without worrying about UI layouts.


pyRevit is the only tool so far that let’s you assign shortcuts to scripts - from what I’ve seen you can’t do that in RevitPythonShell although there is something called “deploy RPS addin” which I’m reviewing now (docs say that it’s a “compiled” python script, which doesn’t really help neither - back to C# it is then).