Commit graph

357 commits

Author SHA1 Message Date
Oktay Comu
7818ee73b2 Fix #147614: Update docs with faster copy of pixels in GPU Module example
This PR updates the [Copy Off-screen Rendering result back to RAM
example in the Python GPU Module docs. As recommended by @Lia-32 in
#147614, copying the buffer using the list slicing notation is much
faster than the list comprehension currently used in the example.

Pull Request: https://projects.blender.org/blender/blender/pulls/163354
2026-09-16 07:43:35 +02:00
Olayinka Vaughan
ff0f71d96e PyDoc: Document the undo argument when calling operators
Ref !160359
2026-07-19 12:20:55 +00:00
Pablo Vazquez
0e5263ff5b UI: Replace use of Info, Warning, and Error icons
Instead of reusing `ERROR` for both warnings and errors, and the Info
Editor icon for "info" label comments, use the new icons from !161002.

* Use `STATUS_WARNING` when the code refers to simple warnings, the
  feature might still work.
* Use `STATUS_ERROR` when the code refers to incompatibility, broken
  functionality, general errors.
* Use `STATUS_INFO` for every info label. Keep `INFO` for the editor.
* Sometimes `WARNING_LARGE` was used, that should only be used for
  dialogs. Use the regular warning instead, it looks almost the same.
* When extra contrast is needed, the filled version is used.

Mostly no big visual changes, other than warnings that were meant as
actual errors using the proper icon now.

See !161038 for details and screenshots.

Pull Request: https://projects.blender.org/blender/blender/pulls/161038
2026-07-05 14:27:56 +02:00
Andrej730
4ee8ff847b PyDoc: Fix Window.screenshot inconsistent header
Similar to https://projects.blender.org/blender/blender/pulls/148813 - `bpy.types.Window.screenshot` is using large header inside attribute description

![image.png](/attachments/5c277fa9-b31e-4484-94b2-6674cab47082)

As a fix using `**xxx**`, similar to how it's done in https://docs.blender.org/api/current/bpy.utils.html#bpy.utils.register_cli_command or https://docs.blender.org/api/current/bpy.types.Context.html#bpy.types.Context.temp_override

Pull Request: https://projects.blender.org/blender/blender/pulls/159506
2026-06-05 01:35:41 +02:00
Campbell Barton
aeb8a44803 PyAPI: update the ImBuf API to only support one buffer-type at a time
Each `ImBuf` now behaves as if it can only have one pixel buffer.

- `imbuf.new()` takes a new keyword-only `buffer_type` argument
  (FLOAT, BYTE).
- `ImBuf.buffer_type` - new read only attribute.
- `ImBuf.convert_buffer_type(bufrer_type)` - function for
  converting between types.
- `ImBuf.with_buffer()` no longer takes a type argument.
- In the unlikely even both buffers are missing,
  `ValueError("ImBuf has no pixel data")` is raised.

Removed: (recently added, not regressions)

- `ImBuf.ensure_buffer`
- `ImBuf.has_buffer`
- `ImBuf.clear_buffer`

Ref !158532
2026-05-14 12:54:58 +10:00
Campbell Barton
05b30f7c35 PyAPI: add bpy.types.Window.screenshot() method
Capture the contents of a window as a read-only `memoryview` of RGBA
bytes shaped `(height, width, 4)`, matching numpy's image convention.

Advantages over the operator for the Python API:

- It's not possible to set the image format from Python.
- It wasn't possible to capture pixel data without writing it to disk.

The documentation example shows how a screenshot can be captured
and written to an image file using imbuf.

Ref !158030
2026-05-01 17:06:43 +10:00
Campbell Barton
08516bebb1 PyAPI: correct function name in argument parsing
Also correct axis in `blf` example.

Ref !154424
2026-02-16 07:14:42 +11:00
Campbell Barton
87f425ff37 Cleanup: remove unused imports, argument shadowing, long lines in RST
Also resolve various pylint warnings.
2026-02-13 19:42:07 +11:00
Campbell Barton
998fe01e28 PyDoc: use type-hint syntax, add missing docs & some corrections
sphinx_doc_gen.py:
- Add _PRIVATE_ATTR_INCLUDE so underscore-prefixed types can be
  selectively included in API docs (needed to reference return values).
- Add :return:/:rtype: for operators.
- Fix context type entries (AnnotationLayer, FluidModifier, Curves).

bpy.props:
- Add :return:/:rtype: for property declaration functions.

gpu:
- Expose MatrixStackContext and OffScreenStackContext as documented
  gpu.types so :rtype: references resolve.

bmesh.ops:
- Use Sequence[float] for vector input params.
- Add default_value for single-element BMO_OP_SLOT_ELEMENT_BUF slots.

bpy.types:
- Convert `tuple of X` to `tuple[X, ...]` and `list of X` to `list[X]`.
- Add :return:/:rtype: to Context.path_resolve and Operator.as_keywords.
- Fix Menu example link reference.

bpy_extras:
- Convert Python type annotations to :param:/:type:/:rtype:,
  add missing doc-strings.

bpy.app.handlers:
- Add :type: with callable signatures.
- Fix depsgraph_update handler description
  (the second argument is optional).
- Fix missing argument descriptions for render and undo/redo handlers.

bpy.context
- Use type hints for for property listing.

mathutils.kdtree:
- Fix doc-string syntax.
- Clarify that the size is an upper limit.

Various minor corrections to other modules.
2026-02-12 20:41:34 +11:00
Campbell Barton
0640836baa PyDoc: number all examples to avoid conflicts when type checking
Examples were supported with/without number suffix,
this caused problems using mypy for type checking because it attempted
to resolve imports such as `mathutils` to the example file.

Having only some examples numbered already complicated documentation
for conventions with examples - simplify extraction and number all.
2026-02-12 00:51:02 +00:00
Campbell Barton
084333edb0 PyDoc: make examples self contained, resolve type warnings
Some examples were missing missing imports,
resolve some mypy warnings.
2026-02-12 00:25:15 +00:00
Campbell Barton
73940408bb PyDoc: replace deprecated TRI_FAN with TRI_STRIP in GPU examples
These examples wouldn't work on macOS.
2026-02-11 23:31:41 +00:00
Campbell Barton
b0fd6cec14 PyDoc: various corrections to doc-strings and examples
- Correct typos/grammar.
- Correct examples.
- Fixes for RST syntax examples.
- Add missing arguments.
2026-02-10 01:49:44 +00:00
Campbell Barton
03975acb55 Doc: add Python API example for KeyMaps add-on registration
Add an example with some notes on keymap usage, targeted at add-on
developers.

- Avoid pitfalls, add-on developers sometimes incorrectly modify user
  keymaps directly, which persists after the add-on is disabled and
  interferes with user preferences.
- Documents subtle/non-obvious requirements.
- Mention edge case regarding modal operator key-maps.

Ref !153111
2026-01-22 07:23:50 +00:00
Nick Alberelli
e1008386eb PyAPI: support for context logging to suppress missing member access
Add hide_missing keyword argument to temp_override.logging_set().
This reduces noise from members that aren't available in the current
context while still showing members that exist but are empty.

- Add CTX_LogFlag enum with Access and HideMissing flags to control
  context member logging behavior during temporary overrides.

- Store & restore original logging with a temporary context so each
  context override properly stores & restores the logging options.

Ref !148760
2026-01-13 19:17:09 +11:00
Nick Alberelli
d11b9878c4 Docs: Add Action Slot example code to PyAPI docs
Add some example code for working with Action slots.

Reference: https://projects.blender.org/blender/blender-manual/issues/105297
Pull Request: https://projects.blender.org/blender/blender/pulls/151510
2026-01-09 16:32:49 +01:00
Nick Alberelli
6577606415 Fix #151742: Docs: Fix Typo in bpy.types.USDHook code
Changes to example code introduced with db88381e75 contains a typo,
using `data block` instead of the standard `data-block`.

This changes ensures consistency with the spelling of `data-block` with
other API example files.

Pull Request: https://projects.blender.org/blender/blender/pulls/151850
2025-12-18 18:36:25 +01:00
John Kiril Swenson
6f9556c561 Cleanup: UI: Standardize ellipsis for menu operators
This patch standardizes ellipses on labels that require further input
from the user before running the operator as per our
HIG.

- PR does not include buttons (e.g. "Purge" in Outliner) and only
  modifies menu items.
- PR does not include operators that wait for input from the user during
  modal operation (e.g. `view3d.select_box`, `paint.sample_color`).
- Some usage of ellipses were removed since they were only present to
  indicate the start of the sentence (to be finished by submenu items).
  E.g. "Make Local...", "Sort Elements...", "Move..." do not require extra
  input from the user.

Pull Request: https://projects.blender.org/blender/blender/pulls/150950
2025-12-04 23:04:28 +01:00
Bipin Yadav
6784fc424e Fix #150602: invalid string formatting in menu example
Ref !150802
2025-11-30 08:40:23 +00:00
nutti
2d07d2a72a Fix: invalid PyDoc format on bpy.types.Context
Currently PyDoc format on bpy.types.Context is not correct.
This PR fixes this.

Pull Request: https://projects.blender.org/blender/blender/pulls/148813
2025-11-01 06:20:36 +01:00
Nick Alberelli
61da6403be USD: Add new get_prim_map API for the on_export hook
Similar to: 0df5d8220b

For consistency sake, we should have the `get_prim_map` function working
on the export side of USD hooks as well as the import side.

Pull Request: https://projects.blender.org/blender/blender/pulls/147242
2025-10-19 22:36:07 +02:00
Jeroen Bakker
e2dc63c5de Fix #147618: PyGPU incorrect colors when drawing images
644fb2b679 fixed a long standing issue
that offscreen example showed the wrong colors. However the fix assumes
that input texture color space is always sRGB.

This adds a shader variation that draws textures that are stored in scene referred
linear color space (like all of our Image data-block).

Co-authored-by: Clément Foucault <foucault.clem@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/147788
2025-10-16 19:12:16 +02:00
Nick Alberelli
0d9ea9d11c PyAPI: add Context.temp_override documentation & examples
Add a new section to the `Context` page that includes an explanation
on how to invoke "on demand" logging for context member access.

Design task: #144746
Logging added in: !144810

Ref !146862
2025-10-08 16:08:09 +11:00
Julian Eisel
eef971e377 UI/BPY: Remove grid layout for UI lists
The grid layout for UI lists wasn't used in practice from all we can
tell. It was badly maintained for a long time (bugs went unnoticed). I
think it was added for an earlier version of the asset UI design.

This was planned for removal in 5.0, see blender/blender#110461.

Usages in bundled scripts were already removed in efa8d942b8.

Pull Request: https://projects.blender.org/blender/blender/pulls/146656
2025-09-29 13:07:31 +02:00
Nick Alberelli
db88381e75 Docs: Include get_prim_map() in bpy.types.USDHook example code
Provide an example of using the `get_prim_map()` in the existing USD
Hook sample.

Related: blender/blender@0df5d8220b

Pull Request: https://projects.blender.org/blender/blender/pulls/146866
2025-09-27 01:58:44 +02:00
Habib Gahbiche
1b4daf9d2e Nodes: remove "Use Nodes" in Shader Editor for Object Materials
"Use Nodes" was removed in the compositor to simplify the compositing
workflow. This introduced a slight inconsistency with the Shader Node
Editor.

This PR removes "Use Nodes" for object materials.

For Line Style, no changes are planned (not sure how to preserve
compatibility yet).
This simplifies the state of objects; either they have a material or
they don't.

Backward compatibility:
- If Use Nodes is turned Off, new nodes are added to the node tree to
simulate the same material:
- DNA: Only `use_nodes` is marked deprecated
- Python API:
  - `material.use_nodes` is marked deprecated and will be removed in
6.0. Reading it always returns `True` and setting it has no effect.
  - `material.diffuse_color`, `material.specular` etc.. Are not used by
EEVEE anymore but are kept because they are used by Workbench.

Forward compatibility:
Always enable 'Use Nodes' when writing blend files.

Known Issues:
Some UI tests are failing on macOS

Pull Request: https://projects.blender.org/blender/blender/pulls/141278
2025-09-14 17:53:54 +02:00
Jacques Lucke
c3f49cd24e Shader Nodes: add Python API for inlined shader nodes
This makes the shader node inlining from #141936 available to external renderers
which use the Python API. Existing external renderer add-ons need to be updated
to get the inlined node tree from a material like below instead of using the
original node tree of the material directly.

The main contribution are these three methods: `Material.inline_shader_nodes()`,
`Light.inline_shader_nodes()` and `World.inline_shader_nodes()`.

In theory, there could be an inlining API for node trees more generally, but
some aspects of the inlining are specific to shader nodes currently. For example
the detection of output nodes and implicit input handling. Furthermore, having
the method on e.g. `Material` instead of on the node tree might be more future
proof for the case when we want to store input properties of the material on the
`Material` which are then passed into the shader node tree.

Example from API docs:
```python
import bpy

# The materials should be retrieved from the evaluated object to make sure that
# e.g. edits of Geometry Nodes are applied.
depsgraph = bpy.context.view_layer.depsgraph
ob = bpy.context.active_object
ob_eval = depsgraph.id_eval_get(ob)
material_eval = ob_eval.material_slots[0].material

# Compute the inlined shader nodes.
# Important: Do not loose the reference to this object while accessing the inlined
#   node tree. Otherwise there will be a crash due to a dangling pointer.
inline_shader_nodes = material_eval.inline_shader_nodes()

# Get the actual inlined `bpy.types.NodeTree`.
tree = inline_shader_nodes.node_tree

for node in tree.nodes:
    print(node.name)
```

Pull Request: https://projects.blender.org/blender/blender/pulls/145811
2025-09-11 06:08:30 +02:00
luz paz
656c3f65ad Cleanup: fix typos in doc subdirectory
Fix several documentation related typos.
Found via `codespell -S "*.desktop,*.diff,./intern,./extern,./locale,./AUTHORS,./source/blender/blenlib/tests/BLI_string_utf8_test.cc,./doc/license/bf-members.txt" -L accessort,abd,aci,alo,ans,ba,bording,childrens,clen,constructin,datas,dependees,domin,eary,ege,eiter,elemt,eles,endianess,enew,espace,finded,fiter,fpt,groupd,hist,implementating,indext,ine,infront,inout,inouts,inpt,ist,lene,listenter,lod,maks,masia,mata,mis,mke,nam,nd,ned,opose,ot,outlow,parm,parms,passt,pinter,pixelx,poin,pres,ptd,re-usable,re-use,re-used,re-uses,re-using,ridiculus,schem,soler,strack,suh,te,tesselate,tham,ue,vai,varius,wew`

Pull Request: https://projects.blender.org/blender/blender/pulls/145824
2025-09-06 08:03:16 +02:00
Bastien Montagne
ede8e3af91 Docs: Update bpy.props docs/examples for getters and setters.
Mostly addresses recent changes in the area (adding 'transform'
accessors), but also tweak/fix some minor issues with existing doc.

Pull Request: https://projects.blender.org/blender/blender/pulls/145582
2025-09-03 17:25:55 +02:00
Campbell Barton
e964f078b5 PyDoc: correct use of back ticks for literal text 2025-08-22 15:10:29 +10:00
Campbell Barton
990f0863e8 PyDoc: include buffer access in examples, cleanup
Note that buffer access is possible, also minor mathutils test cleanup.
2025-08-16 17:39:35 +10:00
clankill3r
ac962c02f6 Fix: PyDocs: typo fix in example
by -> be

Pull Request: https://projects.blender.org/blender/blender/pulls/144448
2025-08-12 17:20:04 +02:00
Aaron Carlisle
9188ce10e7 Cleanup: Format 2025-08-09 19:01:39 -04:00
Aaron Carlisle
86cd240c57 PyDocs: Add Macro example
- Adds a doc string for the Macro class
- Adds a basic example

Fixes #blender-manual/issues/51387
2025-08-09 18:43:14 -04:00
Campbell Barton
53cae68ee8 Cleanup: hyphenate the term data-blocks in strings/doc-strings 2025-08-08 08:47:13 +10:00
Campbell Barton
6d899a6726 Cleanup: naming & reduce declaration scope in the PyAPI for lib loading
Use terms source/destination instead of from/to.
2025-08-02 02:10:59 +00:00
Andrej730
6e70b755ce Fix: PyAPI Docs: Document more msgbus limitations
Added the following notes to documentation:
- `msgbus` interaction with undo system that particularly makes
 it not completely reliable, since users they easily skip it's effect.
- Details on when and how often message bus updates are triggered.

Pull Request: https://projects.blender.org/blender/blender/pulls/138557
2025-06-06 10:58:23 +02:00
Jesse Yurkovich
0fa8c0f62a Docs: Grammar and wording cleanups for FileHandler examples
Cleanup grammar and simplify the wording used in the FileHandler
Python API examples.

Pull Request: https://projects.blender.org/blender/blender/pulls/139366
2025-06-02 19:21:38 +02:00
Jacques Lucke
a010c1c8b8 Python Docs: remove example for using timers with separate threads
This appears to be unreliable.

Resolves #139602.
2025-05-30 09:15:40 +02:00
Jeroen Bakker
a06c7fddbb Fix #139565: Update GPU polyline examples
Update GPU line examples to use polyline shaders.

Pull Request: https://projects.blender.org/blender/blender/pulls/139587
2025-05-30 09:10:51 +02:00
Jeroen Bakker
c56a855b9f Fix #139565: PyGPU: Add builtin point shaders
This PR adds builtin shaders for drawing points. Using `FLAT_COLOR`,
`SMOOTH_COLOR`, `UNIFORM_COLOR` can lead to undesired behavior
on Metal and Vulkan backends. To ensure future compatibility this PR
adds `POINT_FLAT_COLOR` and `POINT_UNIFORM_COLOR`.

The point size can be set using `gpu.state.point_size_set`.

Pull Request: https://projects.blender.org/blender/blender/pulls/139583
2025-05-29 14:36:32 +02:00
Campbell Barton
72f24fcbab Cleanup: resolve pylint warnings 2025-05-23 14:03:20 +10:00
Clément Foucault
f55e97a83a Documentation: Python: Add notice about MSL compatibility
See #139185
2025-05-22 11:47:06 +02:00
Andrej730
670fc012e5 Fix: PyDocs: bpy.ops document behavior on error reports
When submitting #135854 I've assumed that `RuntimeError` is
connected particularly to `{'CANCELLED'}` return status. Turned
out error is raised regardless of what return status is and it's
only based on the presence of error reports during operator
execution. Submitting a clarification for this.

Pull Request: https://projects.blender.org/blender/blender/pulls/138558
2025-05-08 06:58:34 +02:00
Campbell Barton
fd6ac498b0 Cleanup: spelling in comments, strings (make check_spelling_*)
Also replace some triple-quoted non-doc-string strings with commented
blocks in examples.
2025-05-06 00:18:39 +00:00
Jesse Yurkovich
0a3e4b0fd4 Fix #138365: Define and use 'use_filter_orderby_invert' for UIList example
The property in question was undefined since the first commit[1]

[1] b7e2cd5948

Pull Request: https://projects.blender.org/blender/blender/pulls/138373
2025-05-05 19:40:59 +02:00
Campbell Barton
4f04f6f8af Docs: add warning regarding operators that use the file selector 2025-04-25 16:24:24 +10:00
Andrej730
e09d59f9de Fix duplicated dirpath in fileselect_add docs (0314f9318c)
Ref: !137985
2025-04-25 16:04:18 +10:00
Campbell Barton
575600d540 Docs: correct use of FILE_PATH for directories
Also correct own error in recent doc-update regarding the expected
return value for fileselect_add.
2025-04-25 10:27:30 +10:00
Andrej730
e9c0029316 Docs: add the WindowManager.fileselect_add check_existing property
Ref: !137416
2025-04-25 10:20:08 +10:00