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.
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
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
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
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
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
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
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
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
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
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
"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
"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.
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
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
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
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
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
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
Suppress unused warnings using the "vulture" utility.
- Include public definitions in the modules `__all__`.
- Mark arguments & variables as unused with a "_" prefix.
`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
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