45
votes
Accepted
How to call a confirmation dialog box?
When calling an operator via bpy.ops.* without any execution context the execute() method of the respective operator runs by ...
16
votes
Accepted
Add menu entry to generic right-click menu?
As of this commit, thanks to @p2or and @brecht, the bpy.ops.ui.copy_data_path_button() operator now allows to copy the full data-path of the active property under the mouse cursor to the clipboard ...
16
votes
Accepted
How do I get the correct context for Python operators?
After looking through the api documentation, it does not appear that there is a direct way to know which contexts an operator will work in.
Therefore, one way to determine this is to call an operator'...
13
votes
A comprehensive list of operator overrides
Operator
Required context members
Q&A's
ed.lib_id_generate_preview()
id - Object ...
Community wiki
12
votes
Accepted
Create keyboard shortcut for an operator using python?
Minimal add-on example using keymap_items.new() to register a new hotkey CtrlW in 3d View:
...
11
votes
Accepted
Force a Blender operator to always start with default values
Add 'SKIP_SAVE' to the blender property option set.
When defining properties for the operator, any with 'SKIP_SAVE' in their ...
11
votes
How to create toggle button use python in blender
Create a bool property for Window Manager (it can be for anything, but WM will store our modal operator handler so why not put this in the same place):
...
11
votes
Accepted
What does "wm" stand for?
Window manager.
As the name suggests
Window manager data-block defining open windows and other user
interface data
The one instance of the window manager
...
8
votes
Accepted
How can I add items in the node editor context menu in 2.8?
The Shader Editor context menu is called NODE_MT_context_menu (found by inspecting Preferences> Keymap> Node Editor and looking for Right Mouse) and we can '...
7
votes
How can I update a popup while shown?
While your Operator.check(...) method returns True the popup will redraw.
Simple return True method used in ...
7
votes
Accepted
How can I pass arguments to an Operator inside a Macro Operator?
Macro.define("TRANSFORM_OT_translate") returns a OperatorMacro which has a properties ...
7
votes
Accepted
How to pass a bpy.data.objects / bpy.data.materials / etc to an operator from the layout?
Add context members for your op to use.
Would assume you tried
object: PointerProperty(type=bpy.types.Object)
only to get the error message saying you can't ...
7
votes
A comprehensive list of operator overrides
I'm still working on my script that helps me to detect what elements a context override requires, but I guess I might as well share it now and update it later...
Making context copy
First, prepare a ...
7
votes
Automatically run a script when an object is transformed or a condition is met
Driver
It should update if one of the variables changes:
Rotate N objects identically, but with unique variations
Consider using the driver interface even if you do something more elaborate, just in ...
6
votes
Python: Operator Undo Method
Blender's undo system works by saving the blend file to memory, and loading it to perform the undo. If your operator doesn't fully undo, you're probably calling other operators from within its code. ...
6
votes
Accepted
How to assign PointerProperty in Operator through UI?
Aafter continuing researching, apparently operators can only take basic properties (e.g. string, bool, int, float, collections of the property types just mentioned), and PointerProperties only work if ...
6
votes
Accepted
How can I display a FloatVector without it being editable by the user?
You can disable the row (makes it read-only) and set emboss to False for example:
...
6
votes
Accepted
How to control spacing/alignment of Label + Horizontal Enum Property?
Just set layout.use_property_split property in your draw method to True:
...
6
votes
Accepted
Align & Scale Light (Portal) to Face
A Python script to do that.
The tricky part (I think) is to make it work whatever the face is: orientation, number of vertices, concavities... I guess that in this kind of cases, we want the light to ...
5
votes
Why avoid bpy.ops?
Apart from what's been said already, operators also create undo steps. This means that every time you execute an operator, the entire blend file is saved in memory. This is one of the reasons calling ...
5
votes
Making Property sliders act similar to Operators
You can use the 'update' function value that can be assigned to the property's definition:
Update function is triggered each time the slider's value is changing.
...
5
votes
Accepted
How to avoid operator `collection_instance_add`?
Just do all necessary steps
Create a new Empty object
Set instance_collection to the collection you want
Set instance_type to <...
5
votes
Accepted
How to change description in an operator depending on the option assigned in the UI?
Operator description method
Combining answers from Changing tooltip for menu entries which use the same operator
Since 2.81 An operator now has a ...
5
votes
Accepted
Operator Search: 'Free Data' not available in Blender 2.9 anymore?
The default behavior of the Operator Search dialog in 2.9x is to only list the operators that can be found in menus. In order to search for all registered operators, you currently have to enable the ...
5
votes
Change the "OK" button name in dialog-boxes?
Unfortunately this isn't something you have any control over. The window_manager.invoke_props_dialog function is defined in C here, and ultimately uses the ...
5
votes
Accepted
How can I add a panel to the properties area of the file browser?
You would have to add a draw() method along with a pass statement to the operator in order to skip drawing and declare a ...
5
votes
Accepted
How do you access the TEXT_EDITOR header so you can add an operator?
Result:
You can see the operator button added to the header
Answer:
You were on the right path. The link you shared shows how to add extra items in headers. You don't need to create new header class ...
4
votes
Accepted
Using a hint/information-bar like the trasformations are using
You do this by using Area.header_text_set()
Here is an example using the Modal Operator template:
...
4
votes
Know when edit-mode is entered by script? (python)
In 2.8, you can use message bus to do that:
The principle is to obtain the path using a path name through the object.
Then declare a subscription to message bus.
...
4
votes
Python performance with Blender operators
Is there something particular to know to improve these performance or a way to use the bpy.ops methods with better performances?
The top answer is correct, calling an operator updates the current ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
operator × 517python × 433
scripting × 210
add-on × 74
interface × 66
properties × 52
panel × 43
shortcut × 14
error × 13
mesh × 10
3d-view × 10
transforms × 10
objects × 9
customization × 8
grease-pencil × 8
rendering × 7
modifiers × 7
bmesh × 7
modeling × 6
animation × 6
import × 6
command-line × 6
export × 5
video-sequence-editor × 4
mouse × 4