Commit Graph

551 Commits

Author SHA1 Message Date
Campbell Barton
1216651ca9 PyAPI: make internal modules explicitly "private"
Rename modules in `./scripts/modules/` to use an underscore prefix to
make it clear they aren't intended to be part of public API's. This
also means there is no implication that these modules should be stable,
allowing us to change them based on Blender's internal usage.

The following modules have been marked as private:

- `animsys_refactor`
- `bl_console_utils`
- `bl_i18n_utils`
- `bl_previews_utils`
- `bl_rna_utils`
- `bl_text_utils`
- `bl_ui_utils`
- `bpy_restrict_state`
- `console_python`
- `console_shell`
- `graphviz_export`
- `keyingsets_utils`
- `rna_info`
- `rna_manual_reference`
- `rna_xml`

Note that we could further re-arrange these modules
(under `_bpy_internal` in some cases), this change is mainly to mark
them as private, further changes can be handed on a case-by-case basis.

Ref !147773
2025-10-13 09:35:09 +00:00
Christoph Lendenfeld
d68680ed61 Fix #147709: Use correct property for bone selection in Python
Replace all calls to `pose_bone.bone.select` with
`pose_bone.select` since that is where the property lives now

Pull Request: https://projects.blender.org/blender/blender/pulls/147725
2025-10-09 16:52:06 +02:00
Falk David
f9a76822a8 Fix #147437: VSE: Some python operators are broken
Since the introduction of the sequencer scene,
some of the sequencer python operators have
been using `context.scene` when they should be using
`context.workspace.sequencer_scene`.

This fixes `SequencerFadesAdd`, `SequencerFadesClear`,
`SequencerDeinterlaceSelectedMovies`,
`SequencerSplitMulticam`, and `SequencerCrossfadeSounds`.

Pull Request: https://projects.blender.org/blender/blender/pulls/147560
2025-10-09 15:46:05 +02:00
Damien Picard
c35de6f92d I18n: Translate labels using node UI function from node_add_menu.py
In 2a1a658492, layout functions for nodes were refactored and new
methods were introduced, but this change was not applied to the
translation extraction script.

This commit adds these method names and argument order to Python
extraction: "node_operator", "node_operator_with_outputs",
"simulation_zone", "repeat_zone", "for_each_element_zone",
"closure_zone".

Tooltips specified in a special structure are manually extracted using
`n_()`.

Actual translation is done manually in the UI methods inside NodeMenu,
in order to override the context, which by default would have been
"Operator".

Reported by Ye Gui in #43295.

Pull Request: https://projects.blender.org/blender/blender/pulls/147582
2025-10-09 12:09:25 +02:00
Sybren A. Stüvel
8b5c13ac28 Anim: do not access clipboard in Paste Global Transform poll function
Remove access to the clipboard from the Paste Global Transform operator
poll function, as it can cause slowdowns when there is a lot of data on
the clipboard.

This also means that the parsing code has to be a bit more lenient to the
contents of the clipboard. And, because the error message that there is
no matrix on the clipboard is now going to be shown more often, I made it
a bit more friendly.

Pull Request: https://projects.blender.org/blender/blender/pulls/147562
2025-10-09 11:01:25 +02:00
Jacques Lucke
4ca8cf27aa Fix: quick fur operator reads asset from wrong file
The assets files were moved a couple of days ago.
2025-10-08 20:00:15 +02:00
Campbell Barton
bd8fc0807c UV: update align, randomize & follow active quads for recent API changes
Recent changes to UV selection missed updating this operator.
2025-10-08 17:45:52 +11:00
quackarooni
1a6d932fbd Fix: Nodes: Inaccurate placement of framed nodes in swap operators
The swap operators use `Node.location` for location calculations. This expresses
a node's location relative to their parent frames.

This can lead to inaccurate location calculations if nodes have different parent
frames. This was partly addressed by using the custom `temporary_unframe`
context manager. However, that method is sensitive to the order of steps
executed by the operator, making it easy to accidentally let a few location bugs
go through.

This patch fixes the issue by using `Node.location_absolute` which gives the
node's absolute location. This also gets rid of the need for
`temporary_unframe`, and makes the location calculations more straightforward.

Pull Request: https://projects.blender.org/blender/blender/pulls/147424
2025-10-07 12:33:30 +02:00
Campbell Barton
8663f704a2 Cleanup: remove use of f-strings in core scripts 2025-10-07 10:19:46 +11:00
Campbell Barton
cc1a3f19b4 Cleanup: resolve various pylint warnings from recent changes 2025-10-07 10:19:46 +11:00
Campbell Barton
77f5119f77 Cleanup: import modules lazily 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
8d417cb280 Refactor: lazy import anim_utils from bpy_extras
Import `anim_utils` from `bpy_extras` in a lazy way, instead of at the top
of the module. This will improve load times of Blender.

No functional changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/147215
2025-10-02 17:00:13 +02:00
Sybren A. Stüvel
6f844409b6 Refactor: convert sequencer "Clear Fades" to current Action API
Convert the code for the sequencer "Clear Fades" operator from the
legacy Actions API to the current API.

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
Sybren A. Stüvel
2cabaeb4a7 Refactor: convert rigid body "Bake to Keyframes" to current Action API
Convert the code for the rigid body "Bake to Keyframes" operator from the
legacy Actions API to the current API.

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
Sybren A. Stüvel
89d059c5d7 Refactor: convert "Animated Transforms to Deltas" to current Action API
Convert the code for the "Animated Transforms to Deltas" operator from the
legacy Actions API to the current API.

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
Sybren A. Stüvel
bafddfd9fb Refactor: convert "Clear Useless Actions" operator to current Action API
Convert the code for the "Clear Useless Actions" operator from the
legacy Actions API to the current API.

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
8269e17186 Cleanup: defer import of anim_utils 2025-10-01 23:22:43 +00:00
Habib Gahbiche
fb7818e55e Python: Create default node tree for new materials and worlds
The motivation is to keep backward compatibility after deprecating
 `material.use_nodes()` and `world.use_nodes`. For example the
following script would behave the same way in 4.5 and 5.0:
```python
mat = bpy.data.materials.new("My new mat")
mat.use_nodes = True
```

Pull Request: https://projects.blender.org/blender/blender/pulls/147052
2025-10-01 15:05:16 +02:00
Habib Gahbiche
5c58e29bd2 Fix: Motion Tracking: Clip->Setup Tracking Scene broken
Using the operator caused Python exceptions. The reason was the script
was not updated after the recent breaking changes in the compositor.

Pull Request: https://projects.blender.org/blender/blender/pulls/147109
2025-10-01 11:48:51 +02:00
Sybren A. Stüvel
acde9be6fd Fix: correctly update Actions when renaming/re-typing a custom property
Fix: correctly update Actions when renaming/re-typing a custom property

When renaming a custom property on a data-block, only update the
animation in a slot for that data-block. Previously all F-Curves were
updated, even when they were meant for other data-blocks.

This also handles the cases where the type of a custom property is
changed, and not just its name.

This is part of #146586

Pull Request: https://projects.blender.org/blender/blender/pulls/146979
2025-09-30 10:23:20 +02:00
Casey Bianco-Davis
d2269441bb Python: Rename bpy.data.grease_pencils_v3 to bpy.data.grease_pencils
This renames `bpy.data.grease_pencils_v3` to `bpy.data.grease_pencils`.

Part of #125058.

Pull Request: https://projects.blender.org/blender/blender/pulls/146904
2025-09-29 12:32:08 +02:00
Casey Bianco-Davis
f8d2a3af38 Python: Rename bpy.types.GreasePencilv3 to bpy.types.GreasePencil
This renames python Grease Pencil type
from `bpy.types.GreasePencilv3` to `bpy.types.GreasePencil`.

Part of #125058.

Pull Request: https://projects.blender.org/blender/blender/pulls/146902
2025-09-29 12:25:23 +02:00
Damien Picard
6983b97640 I18n: Translate newly-created node group names
Reported by Ye Gui in #43295.
2025-09-29 11:07:03 +02:00
Jacques Lucke
fa03d2558c UI: support searching for more recent files
When trying to find and open an older file, it is annoying when it is not in the
recent files list anymore. This patch increases the length of the recent files
list, without making the menu huge by making better use of menu-search.

Specifically the following is changed: * Number of remembered recent files is
increased from 20 to 200 by default. * The recent files menu is limited to 20
entries. * When activating menu search (by pressing space when in the menu), all
available recent files can be searched. * There is a new "More..." menu entry at
the bottom, which also activates the menu search.

Pull Request: https://projects.blender.org/blender/blender/pulls/146884
2025-09-28 20:22:02 +02:00
quackarooni
e7cae0b220 Fix: Nodes: Occasional crashing when using swap operators
Calling the swap operators can result in Blender crashing. From my
testing, the behavior is inconsistent, as sometimes a crash is triggered
and other times it isn't. Though notably, they seem involve nodes
already linked to other nodes, or zones.

The crashing stems from the operators trying to access deleted data.
There were two places where this happens that were identified, one
involving removed links and the other involving removed nodes.

Pull Request: https://projects.blender.org/blender/blender/pulls/146909
2025-09-28 19:40:55 +02:00
Campbell Barton
9ebc02fc99 Cleanup: spelling, repeated words (make check_spelling_*) 2025-09-26 22:00:27 +10:00
Jacques Lucke
4e4976804e Core: Add packed linked data-blocks
This adds support for packed linked data. This is a key part of an improved
asset workflow in Blender.

Packed IDs remain considered as linked data (i.e. they cannot be edited),
but they are stored in the current blendfile. This means that they:
* Are not lost in case the library data becomes unavailable.
* Are not changed in case the library data is updated.

These packed IDs are de-duplicated across blend-files, so e.g. if a shot
file and several of its dependencies all use the same util geometry node,
there will be a single copy of that geometry node in the shot file.

In case there are several versions of a same ID (e.g. linked at different
moments from a same library, which has been modified in-between), there
will be several packed IDs.

Name collisions are averted by storing these packed IDs into a new type of
'archive' libraries (and their namespaces). These libraries:
* Only contain packed IDs.
* Are owned and managed by their 'real' library data-block, called an
  'archive parent'.

For more in-depth, technical design: #132167
UI/UX design: #140870

Co-authored-by: Bastien Montagne <bastien@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/133801
2025-09-26 10:53:40 +02:00
Campbell Barton
9c5fda87a5 Cleanup: use format specifier, full sentences 2025-09-26 05:10:23 +00:00
Campbell Barton
945590c1d9 Fix: un-escaped strings for node operators/UI
Correct error [0] constructing data paths without escaping.

[0]: 2a1a658492
2025-09-26 14:40:43 +10:00
Campbell Barton
b4fbc0c32d Cleanup: remove f-strings use, use double quotes, quiet pylint warnings 2025-09-26 14:31:05 +10:00
Pablo Vazquez
06b13c8fb4 UI: Splash: Adjust layout and add icons
Small layout and links adjustments to the splash screen.

- Extend list of templates to fit the new Storyboarding template.
- Extend the list of recent files by one row, so it matches templates.
- Add icons to templates.
- Rename `Donate` to `Donate to Blender`.
- Move donate link down so it's more prominent.
- Make separator visible.
- Add "Get Involved" link.
- Remove "Tutorials" link. The Support link already provides help, and
it's been a while since we no longer promote tutorials on blender.org.

See PR for details and screenshots.

Pull Request: https://projects.blender.org/blender/blender/pulls/146730
2025-09-26 00:45:10 +02:00
quackarooni
2a1a658492 Nodes: Swap Node Operator
Implement a native method to swap between different node and zone types.

This implementation repurposes the existing menu definitions as base
classes, from which both an "Add" and a "Swap" version would be generated
from. This allows both menus to have the same layout, but use their own
operators for handling the different node/zone types.

In this PR, support for all node editors has been implemented.

Invoking the menu is currently bound to `Shift + S`, same as the old
implementation in Node Wrangler. Since "Swap" is implemented as a
regular menu, features that menus already have such as type-to-search
and adding to Quick Favorites don't require any extra caveats to
consider.

Resolves #133452

Pull Request: https://projects.blender.org/blender/blender/pulls/143997
2025-09-25 16:12:02 +02:00
Bastien Montagne
00612f0960 Fix (unreported) broken ui_undo_tests due to mistake in geonode code.
poll function expects a modifier or `None` from `get_context_modifier`,
and was getting `False` instead...
2025-09-24 11:51:15 +02:00
Simon Thommes
40ecce9843 Fix: Geometry Nodes: Move to Nodes operator not disabled on linked data
This operator can only be used if the data-block the modifier belongs to
is editable.
2025-09-21 13:44:06 +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
Damien Picard
ddbc6ed858 I18n: Allow translation of some messages using string formatting
- Add `iface_` translation functions and `translate=False` to a few UI
  elements.
- Add `rpt_` translation functions to a few reports.
2025-09-12 18:30:56 +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
Habib Gahbiche
ac84e076db Nodes: Deactivate viewer if shortcut exists and viewer is active
Original right click select:
https://blender.community/c/rightclickselect/wRzz/

Pressing 1,2,3,... to activate a viewer with shortcut now toggles that
viewer instead of always activating it. See PR description for examples

The code is generic but the compositor requires one viewer to be active
so only geometry nodes viewers are supported.

Pull Request: https://projects.blender.org/blender/blender/pulls/145509
2025-09-10 15:17:16 +02:00
Campbell Barton
85788f3dea Cleanup: resolve pylint warnings 2025-09-10 11:31:23 +10:00
Jacques Lucke
32c301e3cf Shader Nodes: support repeat zones, closures and bundles
This adds a function that can turn an existing `bNodeTree` into an inlined one.
The new node tree has all node groups, repeat zones, closures and bundles
inlined. So it's just a flat tree that ideally can be consumed easily by render
engines. As part of the process, it also does constant folding.

The goal is to support more advanced features from geometry nodes (repeat zones,
etc.) in shader nodes which the evaluator is more limited because it has to be
able to run on the GPU. Creating an inlined `bNodeTree` is likely the most
direct way to get but may also be limiting in the future. Since this is a fairly
local change, it's likely still worth it to support these features in all render
engines without having to make their evaluators significantly more complex.

Some limitations apply here that do not apply in Geometry Nodes. For example,
the iterations count in a repeat zone has to be a constant after constant
folding.

There is also a `Test Inlining Shader Nodes` operator that creates the inlined
tree and creates a group node for it. This is just for testing purposes.

#145811 will make this functionality available to the Python API as well so that
external renderers can use it too.
2025-09-09 16:15:43 +02:00
Damien Picard
3611b8a592 Fix: Operator cheatsheet error due to property items not available
When collecting operators for the operator cheatsheet (Help menu),
`node.interface_item_new` gave an error because its property
`active_item` could not gather items. This happened because `context`
was unavailable to its `get_items` method at that time.

This commit refactors the method to return early in case the context is not
found.

Pull Request: https://projects.blender.org/blender/blender/pulls/145930
2025-09-09 12:05:20 +02:00
Eitan Traurig
919acbbf7f Refactor: Convert Copy Mirror UV Coordinates operator from Python to C++
Migrate Copy Mirror UV Coordinates operator to C++. The ID has changed
from `mesh.faces_mirror_uv` to `uv.copy_mirrored_faces`

Ref !145531
2025-09-09 13:03:48 +10:00
Damien Picard
f2b61b0874 UI: Fix and improve a few messages
- "grease pencil" -> "Grease Pencil": title case.
- "Display type" -> "Display Type": title case for property name.
- "Bezier" -> "Bézier": proper noun.
- "Mem:%dM, Peak %dM" -> "Mem:%dM, Peak: %dM": missing colon.
- "cannot save image while rendering" -> "Cannot": Sentence case.
- "Linked data cannot text-space transform" -> "Cannot create
  transform on linked data": rephrase strange sentence.
- "Unsupported object type for text-space transform" -> "... for
  texture space transform": unnecessary abbreviation.
- "Cannot write to asset %s:  %s": remove double space.
- "Failed to set tmpact" -> "temporary action": unclear abbreviation.
- "luminance at which the midetones of the image" -> "midtones: typo.
- "Line angle where the image should be split." -> trailing full stop.
- "... instances all the children in the collection" -> "... instances
  of all the children...": missing "of".
- "Curves to generated rounded corners on" -> "generate": typo.
- "Instances that converted to a point per instance" -> "Instances to
  convert to points": rephrase unclear sentence.
- "Great Pencil to set the depth order of" -> "Grease Pencil": typo.
- "Description to set the smoothness of" -> "Geometry to set the
  smoothness of": typo.
- "A cannot use current file as library" -> "cannot use...": typo.

Pull Request: https://projects.blender.org/blender/blender/pulls/145840
2025-09-07 00:26:31 +02:00
Alex Zhornyak
7a4f8ffc17 Fix #121408: "Online Manual" button doesn't work with add-on preferences
Resolve the situation when addon preferences classes which are
inherited from bpy.types.AddonPreferences are not recognized in
online-manual context help

Ref !145799
2025-09-06 09:55:55 +10:00
Habib Gahbiche
588052f97f Fix: viewer shortcut description mentions compositor only
Pull Request: https://projects.blender.org/blender/blender/pulls/145513
2025-09-02 16:19:30 +02:00
John Kiril Swenson
7bd19f7efb Fix: VSE: Various crashes when sequencer scene is not initialized
Most of these crashes happen because it is assumed that the scene will
always be present even if we have an uninitialized `Editing`, which is
no longer the case with #140271.

- Fix crash when clicking and dragging in the scrub area by checking for
  valid `sequencer_scene` in `change_frame_poll`
- Fix crashes when selecting menu items by disabling them in the UI
  until a `sequencer_scene` is present
- Fix crashes running operators from the F3 menu by changing to more
  restrictive polls that check for `sequencer_scene`
- For good measure, check before dereferencing in
  `channels_displayed_get`, `active_seqbase_get`, and `editing_get`

Pull Request: https://projects.blender.org/blender/blender/pulls/145145
2025-08-26 11:53:49 +02:00
Omar Emara
3d7c8d022e Refactor: Nodes: Generalize node tree subtypes
This patch generalizes node tree subtypes to be usable for node trees
other than Geometry Nodes. In particular, this:

- Renames SpaceNode.geometry_nodes_type to node_tree_sub_type, which now
  store a tree type-specific enum.
- Renames SpaceNode.geometry_nodes_tool_tree to selected_node_group,
  which now stores any context-less tree of any type.

This breaks the python API due to renaming.

Pull Request: https://projects.blender.org/blender/blender/pulls/144544
2025-08-21 09:04:13 +02:00
Maxime-Cots
7a01f736a5 Nodes: Make context path breadcrumbs interactive
Make it possible to navigate in/out node groups through the breacrumbs
context path overlay.

See PR for details and screenshots.

Pull Request: https://projects.blender.org/blender/blender/pulls/141292
2025-08-20 17:53:34 +02:00
Julian Eisel
3c3c01a67c UI: Gray out or hide asset shelf toggle if not available
The "Asset Shelf" checkbox can be confusing for people, they enable it
but it still can't get the shelf to show up. This is because the shelf
is only available in certain contexts (e.g. pose mode and paint modes
in the 3D view, more is planned see blender/blender#135061). Gray out
the toggle with a disabled hint when not available.

The region toggle pie menus will hide the item.

Pull Request: https://projects.blender.org/blender/blender/pulls/113063
2025-08-13 11:38:11 +02:00