Any way to trigger an operator immidiately on active tool bar press?

Is there any way to trigger an operator immediately after a button on the toolbar is clicked? There doesn’t seem to be a way to do it directly from the active tool definition or from the gizmo/gizmo group (unless there is some other user interaction like a button press).

Nope, that runs counter to what blender considers a “tool”. you’re wanting a tool to behave like an operator- in which case it belongs in the N panel, not the T panel. There’s a clear UX that they’re trying to achieve with the left and right panels, think of the left panel as a tool box. you need a hammer, you open it up, you take it out- then you use it however many times you need to and put it away.

Now, having said all that, blender’s python api is very robust and there are ways to do what you want if you’re willing to get your hands dirty. for example (this is a very hacky example, but it does work)- you could write a modal operator that just sits in pass_through monitoring the active tool on every depsgraph_post update, and when the active tool changes to the thing you want- fire the operator. Since this method uses another operator there’s at least one user input required to get it started, unless you want to go deeper down the rabbit hole and learn about how you can trick blender into firing an operator on startup. Do all of this at your own risk, obviously- the API gives you plenty of rope to hang yourself with.

1 Like

That’s the only way I was able to get it to work. It’s very hacky for sure.