Automatically launch a tool just by selecting an object?

Hi guys!

It’s possible in Blender to automatically launch a tool just by selecting an object?

I mean: imagine select a CUBE, and then, automatically having the Modal Rotate enabled for it.

Or imagine select a CONE, and then, automatically having the Modal Move enabled for it.

Thanks!

Moved to Coding Python Support
I think you could use the msgbus to get a selection event but i’d wait for some more answer coming from experts.

2 Likes

I see you’re talking about creating something with Python, right?

I was referring to whether there was some interface element already created (or some addon) that would allow you to do this directly.

But any suggestion will be welcome! :slight_smile:

In Modo there is a utility that allows to assign simple commands to easily manipulate the rigs (attached screenshot). And I just wanted to know if in Blender we have something similar.

THANKS!

No there’s nothing like that right out of the box in blender. Its just as @BG_Division says, technically this could be done with an addon. Cant rule out that such an addon already exists, but havent stumbled across something like that.

2 Likes

I think that it will be possible with some line of python, yes. I do not have deep knowledge of external add-on, often I like to build myself simple tools/addon for what I need (but I’m an enthusiast, not a pro coder). Just now I’d like to go more in deep on this because I’ll need something like this for my addon under construction.
These link could be very useful for a start (but msgbus is not very well documented, unfortunately):

1 Like

Thanks for your help, guys!

No problem: I can live with that, not a drama, at all! :grinning:

Just select my objects/empties and then press “G” or “R” to Move or Rotate quickly, without having to think or worry too much, thanks to the channel locks and limits that I can easily define.

2 Likes

Anyway I’ll try to do something in the next few days, if it leads to something that doesn’t blow up the PC I’ll share something… :grimacing:

1 Like

Yeahh! Thank you soooo much! :grinning:

Remember that msgbus or app handler type internal subscription will always activate the transform tool when you select an object, even when you intend to do something else with the the object.

1 Like

Yes. It would be necessary for a hypothetical addon enabling this functionality to provide a checkbox to enable and disable it at will.

The good thing about this mechanism is that, when you already have a perfectly rigged model, you can select each part and not have to think if the movement assigned to that particular element is translation, rotation or scale. You just click and move the mouse.

1 Like

The application definitely has its practical uses, but the real challenge lies in implementing it in an intelligent manner. Going beyond just the basic features will require a much more complex approach. Since each object and object type would need to be handled uniquely, and users will have to set up these specific configurations for every scene they use. It needs a really good UX design to be useful.

1 Like

Here my test, a bit late but here we are.
My intent here was to trigger the ‘selection object’ event to automatically launch different tools (grab, scale and rotate) depending on which object is selected and without the need to use any G, S or R key.
I used msgbus and there is choice to enable and disable this functionality. When it is enabled, at the moment selecting the Cone it will launch the Rotation tool, the Sphere the Grab tool and the Cube the Scale tool (everything is hard coded but it will be simple to go further and improving UI to let the user make his own custom choices and preferences). When you disable the functionality everything will be as default.
This could be a base to improve, let me know if I understand your question in the right way.
Anyway I learned something new that it will be useful for my stuff.

1 Like

Exactly, yes, that’s it! It’s very good. I think you have the first stage of what could be an interesting add-on.

What is important is that the mechanism used “respects” the possible limits that we may have introduced in each object. Let me explain:

Imagine that we want the CUBE to only be able to ROTATE and that it can only do so on the X axis (because we have blocked the other two axes) and also, it can only rotate between -30º and 60º.

Well: once that cube is selected, without having to press anything (as seen in the video) it is important that the limitations are met: that it can only rotate on the X axis between -30º and 60º

In this way, when we have a relatively complex rig and we are in the animation phase, we can click on each object or empty that can be animated and not worry about whether that object should only move, rotate or scale (nor on which axis or how many degrees). We simply “click and move the mouse”.

I don’t know if I have managed to explain myself.

Of course, it is important that the command associated with each object (Move, Rotate or Scale) can be deactivated if at any time we want to go back and make some changes to the model or the setup…

Big thanks for your efforts! :grinning:

1 Like

Yes, it’s very clear.
I’ll continue trying to improve it because I like the ‘subject’ and it allow me to continue learn something new.
I’ll be back (as Terminator usually say :sunglasses:) with some update!

1 Like

YEAHH! Looking for to your news on this!

Some day I will try to put my hands in the scripting side of Blender dusting off my old and poor Python knowledge… But for the moment I have LOT of other things to learn here and there.

Big thanks again! :slight_smile:

Small update on the current state of the “AutoTool” experiment.
I hope this very short video can show something understandable, but it is not possible to upload a longer one (5 MB limit) and I do not have a YT account. “AutoTool” can be enabled and disabled at will (when opening Blender it will always be disabled automatically) and it only works if you are in OBJECT or POSE mode. A warning message will be displayed in the panel while “AutoTool” is enabled (I would also add a larger message in the 3D view).
There is a PREFERENCES panel that allows you to dynamically create lists of objects that will be affected by the tool itself for GRAB, SCALE or ROTATE. Obviously the same object cannot be present in multiple lists (there is a control that does not allow it).
Currently the logic behind the lists uses the object names: it checks the suffixes so if you add a Cube, a Cube.001 and a Cube.002 to the list the tool will only add 1 Cube to the list and handle all Cubes in the scene.
You can Show/Hide all panels inside PREFERENCES.
While “AutoTool” is running and an object in the lists is selected, the tool it was assigned to is automatically started.
All types of CONSTRAINTS assigned to the object are respected.

It make sense?

1 Like

Wow! Thanks for your work, BG!

I think that more or less, I understand it.

You move each object to the correspondent “List” (to Grab, Rotate or Scale), right?

But the limits for the translation, rotation and scale amounts are defined per-object, right?

And this is persistent between sessions? I mean: if you move a CONE to the list to be SCALED. Once you close and open Blender, this is stored? Or all those lists becomes empty?

I recorded a small video to show how this works in Modo. It’s much more limited than I remembered. In fact it only works with Locators (Empties) and not with regular geometry. In Modo there is not such thing like in Blender, where you click-and-move immediately. It only calls the corresponding gizmo.

YT VIDEO - HOW THIS WORKS IN MODO

What you are achieving is fantastic, even better than in Modo, since you can use over any object, right? (also empties?)

Exactly.

Yes, it was the first idea came in my mind. But this logic can be changed.

Yes.

This is a thing that could be implemented in minutes. I’d add the choice to have both options,

Yes, but I have to test it because didn’t try it.

1 Like

Yeah! I think that this could be a nice addon/helper to animate, since with it you can forget about what tool needs to be invoked (Grab, Rotate or Scale) every time you select an object. The system does this, automatically, for you.

Thanks for your efforts! :slight_smile:

Sorry for the delay, but the early stage of my quick attempt is now ready, so I can share the .py file with you.
Small premise: for this very first test I used Serpens addon to speed up and have fun building and testing different UIs. Serpens is really convenient for this and allows you to build the user interface in a moment and become familiar with the properties and structure of Blender. This however generates a lot of ‘superfluous’ and ‘redundant’ code (which is added to the my own superfluous and redundant code…) not to mention that I left many meaningless names and deleted many of the comments (I’m a shy guy).
In summary: the code is not optimized/clean, let’s forget about PEP8 conventions for this very first version. If a real developer saw it, he would surely lose all his hair immediately but the purpose here is just to try it to understand if it can be useful to you and then refine it. In the meantime, I had fun and learned several very useful things.

I have temporarily named it “GSR AutoTool” (GSR stands for Grab, Scale, Rotate). Once installed, you can find it inside the 3D View > ‘N’ panel > Tool tab.

You can install the add-on the old fashioned way:
Preferences > Add-ons > Install from disk, then select the .zip file.

Once enabled, you will see this:

The tool can be ENABLED and DISABLED as needed by pressing the toggle button.
When ENABLED, a “Running” alert message will appear in the 3D view, and the Settings cannot be edited.

The Settings button opens/closes the panel where you can make core choices.
The main idea is to have 3 lists containing objects that, when selected, will automatically trigger the Grab, Scale, or Rotate operators.

When you select an object in the Grab list, the Grab operator (or the related gizmo, depending on the settings you chose) is launched on that object.
The same applies for Scale and Rotate.

All settings are quite intuitive and self-explanatory (I’ve also added some tooltips), but I’d like to describe those points in more detail:

  1. Single Selection Restriction:
    Currently, I have chosen not to allow more than one object to be selected at a time. However, with my initial msgbus method, it was still possible to select multiple objects using drag selection.
    To address this, I added an option to restrict multi-selection using a depsgraph handler. If you disable this option, drag multi-selection will be possible, but if you select objects that are included in different lists, of course you might experience unexpected transformation behavior.

  2. Refresh Button:
    If you delete objects from the scene and those objects (or some of them) were present in one of the lists, this button will remove the orphaned items from the lists. Having orphaned items in a list does not cause any issues, but refreshing them doesn’t hurt either… especially in very heavy lists :grimacing:

    Find Button:
    This button checks if the currently selected object in the 3D view is already included in any of the lists.

  3. For each list, you also have the following controls:
    ‘Eye’ button: Show/hide the list panel.
    ‘+’ button: Add all selected objects in the 3D view to the list (no need to worry about duplicates; there is a check that prevents adding the same object twice or to multiple lists).
    ‘-’ button: Remove all selected objects in the 3D view from the list they are currently in (the system automatically finds which list they belong to, so there is only one button for this action).
    ‘Trash’ button: Clear the entire list with a single click.

Here the .py (sorry, I haven’t any account to sharing code on proper platforms at the moment):
gsr_autotool_0.1.0.zip (78.2 KB)

You can use it and do whatever you like with it, even if it contains some icons made by me just to have fun. Of course, at your risk! No warranty at all if your house explodes or you lose all your data :rofl:

2 Likes