2
$\begingroup$

What do the modal operators do? They are found below the 'Border Select.' Why are there so many of them? enter image description here If I assigned a HotKey to 'Border Select' as shown in the screenshot, what values should I put in modal operators, to 'Border Select' work as Deselect geometry through Alt + Left mouse?

So I need need to left-click + drag mouse Select geometry (or part geometry) and Left-click + drag mouse + holding Alt Deselect geometry (or part geometry).

$\endgroup$

2 Answers 2

8
$\begingroup$

A modal operator is just an operator that does things a little differently. While there are tons of ways to setup a modal operator, it doesn't have quite the same clearly defined lifetime like regular operators. For example, if you wanted to move an object with a regular operator, the implementation would do something like this the following and would execute in a fraction of a second.

  1. Get how far you want to move it
  2. Move it
  3. Quit, and return what happened (success, cancelled, etc.)

On the other hand, a modal operator that does the same thing has a completely different functionality. It may take a very long time before the user has confirmed the motion and stopped the execution, but Blender shouldn't become unresponsive if it is written correctly.

  1. Start the modal operator
  2. Interact with the user in real-time to update the position
  3. Stop (generally when the user ends the process) at some point and return the results

However, not all modal operators take over all user interaction like you may think. For example, you can have a modal operator that is always running and displays a clock in the 3D viewport. You could have an operator that shows the bounding box and wireframe for selected objects.

Here is an example of a modal operator that does both of the above.

enter image description here

So the real answer to What do the modal operators do? is simply an operator that runs in the background.

The Blender Python docs put it this way:

This operator defines a Operator.modal function which running, handling events until it returns {'FINISHED'} or {'CANCELLED'}.

Grab, Rotate, Scale and Fly-Mode are examples of modal operators. They are especially useful for interactive tools, your operator can have its own state where keys toggle options as the operator runs.

Here is a useful post by one of the Blender developers about all of the "operator methods" including modal:

https://blender.stackexchange.com/a/19431/28015

$\endgroup$
2
  • $\begingroup$ Where did you get that operator from? I'd like to take a look at its source code. $\endgroup$
    – kitfox
    Commented Dec 14, 2020 at 21:27
  • 1
    $\begingroup$ @kitfox That was several years ago, but I probably just combined some of the example scripts that Blender 2.7x included in the text editor if I had to guess. $\endgroup$
    – Jake Dube
    Commented Dec 15, 2020 at 19:41
0
$\begingroup$

Not a coder myself so my understanding may be a bit clouded here. So I'm not really sure but I think border select is technically called a Modal operator

As the name implies it enters a special Mode, that means in that while in mode things work differently, and for that special state there is a whole new list of operations and corresponding keymap entries.

All those are concerned with either beginning to draw a selection border rectangle, cancelling border select command, adding objects to the current selection or removing objects from the current selection.

To deselect it's a two-keymap set up.

You have to have a global 3D view hotkey to trigger the Border Select Command first. Say you want to have Alt+Tweak Left Mouse to deselect, then you have to assign a new Alt+Tweak Left Mouse hot key to Border Select operator with the option Extend so that the current selection is maintained.

Then in the modal you probably need to assign Alt+Left Mouse,Release event to DeSelect so that when you release the button highlighted objects will be removed from the current selection

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .