Commit graph

127 commits

Author SHA1 Message Date
Campbell Barton
3c09df88e4 PyDoc: add missing args, correct function directives
- Add missing doc-strings for function arguments & return.
- Remove unnecessary `bpy.type.` prefix.
- Correct function directives.

Ref !158251
2026-05-07 16:35:51 +10:00
Christoph Lendenfeld
253ae8112d Fix #157398: Add functions in anim_utils to python docs
Functions have to be added to the `__all__` tuple to show up
in the python docs.

This is now done for the new channelbag functions in
`anim_utils.py`.

Pull Request: https://projects.blender.org/blender/blender/pulls/157470
2026-04-16 16:24:01 +02:00
Campbell Barton
eacd94fc79 Cleanup: spelling (make check_spelling_*) 2026-03-14 16:14:56 +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
1d064dd124 PyDoc: use Literal[...] types for fixed string enum parameters
Replace `:type X: str` with `:type X: Literal[...]` for parameters
for more accurate typing information.
2026-02-10 09:51:28 +00:00
Campbell Barton
17f39b8893 PyDoc: type corrections for Python doc-strings
Also use uppercase 2D/3D.
2026-02-10 14:00:01 +11: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
81857ea926 PyDoc: add missing Python doc-strings
Various Python utility functions were missing doc-strings.
2026-02-10 01:04:51 +00:00
Campbell Barton
791505e2ed PyDoc: use :param: instead of :arg: in Sphinx docstrings
While "arg" isn't deprecated "param" is preferred and used in all
Sphinx's examples & tutorials.

Ref !154039
2026-02-07 14:30:16 +11:00
Campbell Barton
d7d8e7a1df Fix #152809: bpy_extras.io_utils.orientation_helper fails on Python 3.14
The workaround for #58772 created an empty `__annotations__` dict to
prevent modifying a parent class's annotations. In Python 3.14 (PEP 649),
this broke because it overwrote the lazily-evaluated annotations that
the new descriptor-based system would have created.

Skip the workaround for Python 3.14+ since lazy evaluation ensures
`cls.__annotations__` always returns a dict specific to that class.

Ref !153384
2026-01-26 10:00:56 +00:00
Tariq-Sulley
943be0a28d Fix #152992: Torus added in edit mode does not reuse existing materials on objects
Adding a torus to an object in edit mode does not reuse
the existing materials of the object but instead adds an
empty material slot for the torus. This is not consistent
behavior with adding other primitives. Resolve by copying
the active object's active material into the material slot of
the torus.

Pull Request: https://projects.blender.org/blender/blender/pulls/153099
2026-01-21 04:25:17 +01:00
dupoxy
e771b27e9c Fix #146062: Incorrect reference tot the default key-map
Ref !146063
2026-01-08 13:56:03 +11:00
Christoph Lendenfeld
97af0b5757 Fix #152216: copy global transforms python error
The `keyframe` function added in 4.5 used `keyingset.name`
which doesn't exist. The way to get the name of a keyingset
is `keyingset.bl_label`

Pull Request: https://projects.blender.org/blender/blender/pulls/152406
2026-01-05 11:20:00 +01:00
Demeter Dzadik
29d35774c1 Fix #150654: id_map_utils missing docs/autocomplete
This code was originally annotated with modern style, then those annotations got commented out due to what I believe are some current technical limitations, so this PR goes back to the old-style documentation syntax.

I nested `recursive_get_referenced_ids` inside of `get_all_referenced_ids` because it was always just a helper function, there's no use case for calling this function directly from anywhere else.

No functional changes, except hopefully now the docstrings will show up [in the docs](https://docs.blender.org/api/5.0/bpy_extras.id_map_utils.html), and look a bit prettier in the PyConsole autocomplete.

Pull Request: https://projects.blender.org/blender/blender/pulls/151203
2025-12-09 14:39:57 +01:00
shikhin
c2b2058428 Fix #149724: Baking animation removes constraints from linked file
The issue was that the code did not check if a constraint came from
a linked file.
Fix it by checking the `is_override` condition and only remove local constraints.

Pull Request: https://projects.blender.org/blender/blender/pulls/150309
2025-11-24 13:56:52 +01:00
Christoph Lendenfeld
53099529ed Merge branch 'blender-v5.0-release' 2025-11-03 12:46:27 +01:00
Christoph Lendenfeld
699e3344c3 Anim: operator to manually version animation of the Bone.hide property
This comes from a discussion on #147711
on how to best version animations for that property.

The issue with animations is that we cannot know where the
users wants to have the animation moved to.
In 4.5 the animation was on the armature but now needs
to be on an object. Because of that the FCurve
has to move to a different action or slot. There is no good
way to figure out which action + slot combination
the user wants to move the animation to, so we provide this tool.

The operator always works on selected armature objects.
For it to work, the armature and the object have to have an
animation + slot assigned. That way we
can know reliably where the data should move.

This does not solve the issue with the NLA. However I think it
will be very rare that bone visibility is
animated with the NLA since it doesn't affect the final render.

Pull Request: https://projects.blender.org/blender/blender/pulls/148111
2025-11-03 11:55:16 +01:00
Jacques Lucke
991fe3e84a Merge branch 'blender-v5.0-release' 2025-10-25 20:39:22 +02:00
Gabriel Lee
ae7d728409 Fix: Error when connecting Boolean sockets to Material Output in Material Nodes
Correct Boolean socket type in node_utils to fix TypeError when connecting to
Material Output.

Problem: Connecting a Boolean-type socket to Material Output from within a
NodeGroup using Ctrl+Shift+LeftClick caused a TypeError.

Cause: In node_utils.py, the socket type was incorrectly written as
'NodeSocketBoolean' instead of 'NodeSocketBool'.

Solution: Change the type to 'NodeSocketBool'. Boolean sockets now connect to
Material Output without error.

Testing: Verified the fix on Blender versions 4.2 through 5.0.1a. Only this
instance of 'NodeSocketBoolean' existed in the codebase; all other references
already used 'NodeSocketBool'.

Pull Request: https://projects.blender.org/blender/blender/pulls/147808
2025-10-25 20:38:04 +02:00
Campbell Barton
7a249222be Cleanup: tweak multi-line parenthesis for Python scripts
Reduce right shift, moving closing parenthesis onto own line
for clarity & reducing diff noise in some cases.

Ref !147857
2025-10-12 03:31:31 +00:00
Janne Nylander
88308e108e Fix #147739: Python animation baking script was checking bone selection from wrong type of bone
The script was checking if a bone was selected via Bone.select.
As of 5.0, this is not available. Instead, PoseBone.select should be used.

Pull Request: https://projects.blender.org/blender/blender/pulls/147743
2025-10-10 17:29:08 +02:00
Campbell Barton
cc1a3f19b4 Cleanup: resolve various pylint warnings from recent changes 2025-10-07 10:19:46 +11:00
Nika Kutsniashvili
b4a8e8c5f8 Anim: Move "Copy Global Transform" extension to internal scripts
Move the Copy Global Transform core add-on into Blender's code.

- The entire extension was one Python file. This PR basically splits
  it into two, one for operators (in `bl_operators`) and the other for
  UI panels. Those panels are registered in the 3D viewport's sidebar,
  which were registered in `space_view3d`, but I made the decision
  here to create a new file `space_view3d_sidebar`, because the main
  file is getting too large and difficult to navigate. This PR puts
  the global transform panel in this file. After this is merged, I
  will do refactors to move the rest of the sidebar panels here as
  well.

- `AutoKeying` class was moved into `bpy_extras/anim_utils.py` so that
  it's reusable and also accessible from API, since it's generally
  very useful. There were discussions about putting this somewhere,
  but for now, I chose against it because creating a new file would
  also mean PR would have to affect documentation generation, and
  would complicate things. If we want to, we can probably create a new
  module in the future.

- Little tweaks to labels and descriptions. Now that they exist
  outside of the add-on context, and exist without the user explicitly
  enabling them, they need to be more descriptive and tell users what
  they actually do. They also need to conform to Blender's GUI
  guidelines. Also tried organizing files a little by grouping
  objects.

- Add-on properties (which included word `addon` in the name) have
  been registered in C++, on `scene.tool_settings` with `anim_`
  prefix.

Pull Request: https://projects.blender.org/blender/blender/pulls/145414
2025-10-03 17:42:04 +02:00
Sybren A. Stüvel
7b18a2c324 Refactor: convert Rigify from legacy Action API to the current API
Minimal changes to make Rigify use the current Action API (introduced in
Blender 4.4) instead of the legacy API (removed in 5.0).

Most of the refactoring consists of:

- Find the right `Channelbag`
- Replace operations on `Action` with operations on that `Channelbag`.

I didn't manage to test all code, because some code paths are very hard
to follow, and others seem to only be available for legacy rigs.

This is part of #146586

Pull Request: https://projects.blender.org/blender/blender/pulls/147060
2025-10-02 14:42:43 +02:00
Sybren A. Stüvel
5c2069e284 Refactor: convert "Bake Action" operator to current Action API
Remove the use of `action.fcurves` in the Bake Action operator, replacing
it with the current API (introduced for slotted Actions in Blender 4.4).

No functional changes.

This is part of #146586

Pull Request: https://projects.blender.org/blender/blender/pulls/147060
2025-10-02 14:42:43 +02:00
Campbell Barton
df5366f596 Cleanup: spelling, duplicate terms 2025-10-01 23:22:42 +00:00
Sybren A. Stüvel
dbcb701eb2 Anim: make it easier to convert from legacy to current Action API
The changes:

1. Add `group_name` to the `channelbag.fcurves.new()` and
   `action.fcurve_ensure_for_datablock()` RNA functions.
2. Add `anim_utils.action_ensure_channelbag_for_slot(action, slot)`.
3. Add `channelbag.fcurves.ensure()` RNA function.

This makes it possible to replace this legacy code:

```py
fcurve = action.fcurves.new("location", index=2, action_group="Name")
```

with this code:

```py
channelbag = action_ensure_channelbag_for_slot(action, action_slot)
fcurve = channelbag.fcurves.new("location", index=2, group_name="Name")
```

or replace this legacy code:

```py
fcurve = action.fcurves.find("location", index=2, action_group="Name")
if not fcurve:
    fcurve = action.fcurves.new("location", index=2, action_group="Name")
```

with this code:

```py
channelbag = action_ensure_channelbag_for_slot(action, action_slot)
fcurve = channelbag.fcurves.ensure("location", index=2, group_name="Name")
```

Note that the parameter name is different (`action_group` became
`group_name`). This clarifies that this is the name of the group, and
not a reference to the group itself.

This is part of #146586

Pull Request: https://projects.blender.org/blender/blender/pulls/146977
2025-09-30 14:43:56 +02:00
Alaska
2f02866519 Fix #146322: Spelling mistake and missing return type for axis_conversion
Fix typo in PyApi doc of `axis_conversion` and add return type

Pull Request: https://projects.blender.org/blender/blender/pulls/146353
2025-09-22 15:48:11 +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
luz paz
072f956ce0 Cleanup: Fix typos in scripts subdirectory
Fix spellings from comment and string
Found via codespell

Pull Request: https://projects.blender.org/blender/blender/pulls/145834
2025-09-11 11:29:06 +02:00
Campbell Barton
53cae68ee8 Cleanup: hyphenate the term data-blocks in strings/doc-strings 2025-08-08 08:47:13 +10:00
Damien Picard
5998795aa6 UI: Replace contractions with long-form text
Avoid using contractions for can't, aren't, doesn't, and shouldn't.
Following the writing style guide in the Human Interface Guidelines.

Pull Request: https://projects.blender.org/blender/blender/pulls/143852
2025-08-05 11:16:22 +02:00
Campbell Barton
81e4558ab6 Cleanup: reduce right-shift in Python scripts 2025-07-22 11:59:43 +10:00
Campbell Barton
e5947bdf63 Cleanup: spelling (make check_spelling_*)
Also exclude some files that have too many false positives.
2025-07-20 14:59:19 +10:00
Damien Picard
3aa633304a I18n: Disambiguate "Strip" for exporter filepath mode
"Strip" generally is a sequencer or animation strip, but in this
context it is a string manipulation action for file names. It is
defined as part of the Path Mode defined in the FBX and OBJ exporters.
Those exporters are defined in Python and C++, respectively. This
commit changes both exporters to use the "File browser" translation
context.

In addition, the tooltip for "Relative" from the FBX exporter was
changed to match its OBJ counterpart, and the "Strip Path" mode was
also matched to the other version which reads better as an enum item.

Reported by Ye Gui in #43295.
2025-07-07 12:02:25 +02:00
Sybren A. Stüvel
9605cbde6f Fix #137041: Bugs with Slotted Actions and the Available Keying Set
Make the 'Available' keying set look at the F-Curves for the assigned
slot, instead of the backward-compatible API (which only sees the F-Curves
for the first slot).

Pull Request: https://projects.blender.org/blender/blender/pulls/137131
2025-04-08 11:10:46 +02:00
Christoph Lendenfeld
28d0bef706 Fix: Retain slot name when baking action
Previously when an action was baked, the slot name was not retained.
This causes problems when switching between actions because the slot
will not automatically be assigned.

This is now fixed by ensuring that the name of the last assigned slot
is used to create the new slot.

Pull Request: https://projects.blender.org/blender/blender/pulls/136814
2025-04-03 10:18:15 +02:00
Campbell Barton
e436b9638e Cleanup: replace references to "C" to C++ or the C-API
Also capitalize Blender, Python & API in docs & code-comments.
2025-03-26 17:23:33 +11:00
Sybren A. Stüvel
9c1845dbf2 Fix #135775: Bake to an empty Action using bake_action_objects throws error
Fix a few small mistakes in the action baking code:

- Assigning an action slot should only happen after the action itself has
  been assigned.
- `_ensure_channelbag_exists()` didn't actually ensure the channelbag
  always exists; now it also creates the layer & strip if necessary.

Pull Request: https://projects.blender.org/blender/blender/pulls/135853
2025-03-12 11:46:34 +01:00
Christoph Lendenfeld
a485bf6556 Fix #134034: Baking a custom property with a name existing in Blender failed
When baking custom properties that were named exactly the same
as a property already in Blender (in this case `scale`), it would fail.
The issue was introduced with eee32726c7 where the goal was
to not key addon defined properties.
The problem with that approach was that `obj.bpy_rna.properties`
not only contains addon defined properties but also all that are native to Blender.
So the rna path would be created to be identical as for e.g. transform properties.

The fix is to test the property for `is_runtime` which is true for addon
defined properties but false for blender internal properties

I tested with the test file of #121349 to confirm that doing so
doesn't bring that original bug back.

Pull Request: https://projects.blender.org/blender/blender/pulls/135297
2025-03-06 15:51:44 +01:00
Christoph Lendenfeld
566f51c24a Fix: selecting bones of pose assets not respecting multiple slots
The code for selecting bones from a pose was still using the legacy api,
thus it didn't work properly for selecting bones of all slots.

Pull Request: https://projects.blender.org/blender/blender/pulls/134912
2025-02-27 14:46:36 +01:00
Campbell Barton
6fcd84721c Cleanup: quiet some warnings from check_pep8 target 2025-02-04 14:51:17 +11:00
Sybren A. Stüvel
226486aa91 Refactor: Anim, rename and adjust ActionKeyframeStrip.channels()
Rename `ActionKeyframeStrip.channels()` to `.channelbag()`, and change
its first parameter from `slot_handle` to `slot`.

This is to be consistent with `ActionKeyframeStrip.channelbags`, which is
the array of channelbags in the keyframe strip. Having a function that's
singluar makes sense for finding a single element in the array.

The change from using the slot handle to using the slot is to be consistent
with `.channelbags.new(slot)`. Furthermore, the Python API should be using
slot handles as little as possible (they're basically meaningless numbers).
Using the slots directly is preferred. If that's not possible, it is
recommended to use the slot identifier (`slot.identifier`) instead, as that
can be used to look up the slot (`action.slots[slot_identifier]`).

This breaks the glTF add-on, which will be fixed in !133915.

Pull Request: https://projects.blender.org/blender/blender/pulls/133868
2025-02-03 20:19:00 +01:00
Jonas Holzman
0ee4ae89e4 UI: Capitalize default filenames from "untitled" to "Untitled"
Capitalize the default filename used for .blend files and other savable
and exportable file formats (like images, 3D formats, etc.) from
"untitled" to "Untitled".

Pull Request: https://projects.blender.org/blender/blender/pulls/132424
2025-01-13 20:06:27 +01:00
Campbell Barton
6ca1417103 Cleanup: suppress unused Python warnings
Suppress unused warnings using the "vulture" utility.

- Include public definitions in the modules `__all__`.
- Mark arguments & variables as unused with a "_" prefix.
2024-12-03 12:54:13 +11:00
Nathan Vegdahl
aa83738d44 Anim: change parameters of slots.new() RNA function
`Action.slots.new()` in the Python API previously took either an ID or nothing
as a parameter. In the former case it would create a slot with the appropriate
`id_root` and name for that ID. In the latter case it would create a default
slot with an unspecified `id_root` and default name.

This had several issues:

1. You couldn't create a slot with a specific `id_root` without already having
   an ID of that type. In theory this isn't a problem, but in practice in larger
   scripts/addons you don't necessarily have such an ID on hand at the call
   site.
2. You couldn't directly create a slot with a desired name without an existing
   ID with that name. This isn't so important, since you can always just set the
   name afterwards. But it's a bit annoying.
3. Most other `new()` APIs in Blender *require* you to specify the name of the
   item being created. So calling this with no parameters was violating that
   norm.
4. Ideally, we want to eliminate unspecified `id_root`s, since they cause other
   weirdness in the API such as slot identifiers changing upon slot assignment.

To resolve these issues, and just generally to make the API more
straightforward, this PR changes `slots.new()` to take two required parameters:
an ID type and a name. For example:

`slots.new(id_type='CAMERA', name="My Camera Data Slot")`.

This fully specifies everything needed for the slot identifier upon creation,
and doesn't require any outside data items to create a slot with the desired
type and name.

In the future if we decide we still want a `for_id`-style slot creation API, we
can reintroduce it as a separate function.

Ref: #130892
Pull Request: https://projects.blender.org/blender/blender/pulls/130970
2024-12-02 17:04:37 +01:00
Alaska
e84103d958 Fix #130822: Update built-in Python scripts to use new EEVEE material settings
In Blender 4.3 all the EEVEE Legacy compatibility Python API calls for
materials in were removed. All Python code that makes use of that API
need to be updated to make use of the new API.

This commit updates two built in Python scripts to use the new API
to avoid errors like the one reported in #130822

Candidate for 4.3.1 corrective release

Pull Request: https://projects.blender.org/blender/blender/pulls/130873
2024-11-25 10:51:45 +01:00
Campbell Barton
96ac7b7ff3 Merge branch 'blender-v4.3-release' 2024-11-06 10:51:53 +11:00
Campbell Barton
6fe8b5724a Merge branch 'blender-v4.3-release' 2024-11-06 10:51:01 +11:00