64 Commits

Author SHA1 Message Date
Habib Gahbiche
bd61e69be5 Compositor: make compositor node trees reusable
This is part of the short term roadmap goal of simplifying the
compositor workflow
(see https://projects.blender.org/blender/blender/issues/134214).
The problem is that many users don't know how to get started with
compositing in Blender, even when they have used Blender for other
areas, e.g. modeling.

Note: although the solution makes compositor node trees reusable
accross blend files, this is a nice side effect and not the main goal
of the PR.

This PR implements a "New" button that creates a new compositing node
tree, and manages trees as IDs. This has following advantages:
- Consistent with other node editors and other parts of Blender,
therefore making it easier to getting started with compositing if users
are familiar with shading or geometry nodes
- Give users the ability to reuse the compositing node tree by linking
or appending it.

Note: The parameter "Use Nodes" is still present in this PR, but will
be removed (in a backward compatible way) in a follow up PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/135223
2025-06-10 17:46:55 +02:00
Sybren A. Stüvel
f6167aab31 Anim: name new action slots after the last-used slot
When creating a new action slot for a data-block, via the '+ New' button
of the slot selector, use the name of the slot that was last used by
that data-block. Previously, it would always use the name of the
data-block, interfering with slot auto-selection when toggling between
Actions.

Pull Request: https://projects.blender.org/blender/blender/pulls/138326
2025-05-02 16:03:00 +02:00
Sybren A. Stüvel
9b1a34e83e Fix #136947: Duplicate Action Slot doesn't duplicate animation data
The "new/duplicate" button in the Action Slot selector did not actually
duplicate, and always acted as a "new" button.

This introduces the RNA function `ActionSlot.duplicate()`, which takes
care of duplicating all the animation data associated with the slot as
well. The semantics of this function should remain valid in the
future, when Actions support multiple layers & strips. Note that this
new function does not assign the slot, it just duplicates it and its
data. The assignment of this duplicated slot is done in Python,
through the already-existing API for this.

Pull Request: https://projects.blender.org/blender/blender/pulls/137087
2025-04-07 16:14:49 +02:00
Campbell Barton
5b04f13219 Cleanup: wrap long lines 2025-03-21 22:08:31 +11:00
Campbell Barton
6fcd84721c Cleanup: quiet some warnings from check_pep8 target 2025-02-04 14:51:17 +11:00
Campbell Barton
be0c9174aa Cleanup: argument wrapping for Python scripts
- Wrap the closing parenthesis onto it's own line
  which makes assignments to the return value
  read better.
- Reduce right-shift with multi-line function calls.
2025-01-14 12:53:32 +11:00
Campbell Barton
a7bc3e3418 Cleanup: quiet Python linter warnings 2024-12-11 11:26:24 +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
Hans Goudey
39ecbe496d Merge branch 'blender-v4.3-release' 2024-11-05 10:02:52 +01:00
Christoph Lendenfeld
be54e36333 Fix #125816: Clear constraint while action baking not doing visual keying
When doing action baking, the option "Clear Constraints" mentions
it's doing visual keying while not actually using that option.
Just fixing the description, even though a better solution
would be to revisit the design of the options to see if they
even make sense in some configurations.

Pull Request: https://projects.blender.org/blender/blender/pulls/129052
2024-11-05 09:41:29 +01:00
Sybren A. Stüvel
411f399a7f Anim: disable 'New Slot' operator on linked Actions
The 'New Slot' operator now checks for editability of the Action.

Pull Request: https://projects.blender.org/blender/blender/pulls/128708
2024-10-08 15:20:55 +02:00
Sybren A. Stüvel
dba78ebb66 Cleanup: clarify 'disabled' message in anim.slot_new_for_id poll function
The old text seemed to suggest that an Action Slot can only be created at
the moment of assigning the Action to something. That is not the case.
The operator just works on the assigned Action, and if none is assigned,
there is nothing it can do.
2024-10-07 18:29:50 +02:00
Campbell Barton
a7ab81d927 PyAPI: remove use of BaseException
BaseException was used as a catch-all in situations where it
didn't make sense and where "Exception" is more appropriate
based on Python's documentation & error checking tools,
`pylint` warns `broad-exception-caught` for e.g.

BaseException includes SystemExit, KeyboardInterrupt & GeneratorExit,
so unless the intention is to catch calls to `sys.exit(..)`,
breaking a out of a loop using Ctrl-C or generator-exit,
then it shouldn't be used.

Even then, it's preferable to catch those exceptions explicitly.
2024-10-01 13:18:46 +10:00
Campbell Barton
4c36f9a566 Cleanup: simplify attribute access
Avoid getattr(..) when values are know to exist.
2024-10-01 10:23:04 +10:00
Sybren A. Stüvel
615cb46412 Anim: add Action Slot selector to Action Constraint
Add slotted Actions support to Action constraints.

The user interface can be improved once #127751 lands.

Ref: #120406
Pull Request: https://projects.blender.org/blender/blender/pulls/127749
2024-09-20 08:07:15 +02:00
Sybren A. Stüvel
3417934eff Anim: add Action Slot assignment to NLA strip
For an NLA strip to use a slotted Action, it needs to specify which slot
to use in that action. This is now handled by two new properties on the
strip in DNA & RNA: `action_slot_handle` and `action_slot_name`.

These serve the same purpose as their counterparts on the `AnimData`
struct.

Note that this commit does NOT add NLA evaluation support for slotted
Actions. It merely allows assigning them. Evaluation, tweak mode
support, etc. will be implemented in future commits.

Pull Request: https://projects.blender.org/blender/blender/pulls/127359
2024-09-12 14:08:16 +02:00
Campbell Barton
e34d9eeac7 Cleanup: use C-style comments, double quote Python text 2024-09-03 21:22:34 +10:00
Sybren A. Stüvel
a6d7e12e22 Anim: New/Un-assign Slot operators
Add two new operators, `anim.slot_new_for_id` and
`anim.slot_unassign_from_id`. These are used in the Action editor and
the Animation panels in the Properties editor, to respectively create a
new Action Slot for an ID and to unassign whatever slot is currently
assigned to that ID.

The latter operator also replaces the C++ operator
`anim.slot_unassign_object`, which was specifically made for the
Dopesheet header. The Python ones are generic enough to be used there
too.

Pull Request: https://projects.blender.org/blender/blender/pulls/126943
2024-09-02 14:10:49 +02:00
Campbell Barton
949dfbfaa8 Cleanup: Python script formatting
- Double quotes for strings.
- Trailing commas when wrapped lines.
2024-06-06 11:26:28 +10:00
Campbell Barton
56388dc8fe Cleanup: reduce right-shift in startup scripts
Also un-wrap lines that fit in the column width.
2024-04-30 12:46:05 +10:00
Campbell Barton
0c4d3754f1 Cleanup: replace {!s} with {:s} when used with strings
When passing strings to str.format(..) use `{:s}` format specifier
which only takes strings and wont run `.__str__()` on non-strings.

While `{!s}` is an equivalent to `%s`, for the most part `%s` was
used for strings, so using `{:s}` is clearer and more specific.
2024-04-27 16:02:37 +10:00
Campbell Barton
0e3b594edb Refactor: scripts under scripts/startup/ to use str.format
Part of modernizing scripts in Blender, where the previous convention
was to use percentage formatting which has become the "old" way to
format strings in Python.

See proposal for details #120453.

Ref !120552
2024-04-27 16:02:36 +10:00
Campbell Barton
2b7f46bc0b Fixes for keying-set export operator
- Escape identifiers for data-paths.
- Use repr for literal strings.
- Don't set the read-only is_path_absolute property.
2024-04-16 12:26:20 +10:00
Christoph Lendenfeld
8ea7d44e62 Fix #120470: Keying Set export fails in python
Caused by 30b0c5b225
That commit removed `use_insertkey_xyz_to_rgb` but
I didn't see the use of that in the python script.
Fixed by removing the usage of that property from the python script as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/120509
2024-04-11 11:15:28 +02:00
Campbell Barton
99f93aa4c8 Cleanup: assign object & space variables from the context for reuse 2024-03-29 10:08:59 +11:00
Campbell Barton
a2dae7e4b4 Cleanup: consistent quotes for Python scripts 2024-03-29 10:07:28 +11:00
Hans Goudey
803c783e52 Merge branch 'blender-v4.1-release' 2024-03-19 11:59:26 -04:00
Sybren A. Stüvel
cd476226d8 Fix #119402: Bone collections layers fail with pinned object or armature #119434
Don't assume armature of active object is what is displayed in the properties editor, both in C++ and Python code.

Object pointer was left out from some notifiers, as this means only that object was changed. But an armature datablock can be shared by multiple objects.

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/119663
2024-03-19 16:27:06 +01:00
Brecht Van Lommel
7a395e2e7f Revert changes from main commits that were merged into blender-v4.1-release
The last good commit was f57e4c5b98c075f3dfc61faebbcb43c99a778956.

After this one more fix was committed, this one is preserved as well:
67bd678887d7f8aec9f3b23bbf1aaf29f80d0da4.
2024-03-18 15:04:12 +01:00
Campbell Barton
cf1ab3ec6e Cleanup: consistent quotes in Python 2024-03-14 10:38:45 +11:00
Sybren A. Stüvel
5531a191e8 Fix #117798: "Nothing to Bake" when pose object is not selected
Use `context.pose_object` when baking a pose, on on top of the objects
in `context.selected_editable_objects`. When in pose mode, it's expected
that the pose of the active will be baked, regardless of whether the
pose object is selected itself.

Pull Request: https://projects.blender.org/blender/blender/pulls/119317
2024-03-11 17:11:14 +01:00
Sybren A. Stüvel
848f83e210 Anim: bone collections, add 'un-solo all' operator
Add an operator that clears the 'solo' flag from all bone collections.
2024-01-26 11:09:06 +01:00
Sybren A. Stüvel
f623c8f7bc Anim: remove 'Solo Visibility' bone collections operator
Remove the 'Solo Visibility' operator that singles out a bone collection.
It was a workaround for not having a true 'solo' flag, which is there
now.
2024-01-26 11:05:00 +01:00
Campbell Barton
0ea0573349 PyDoc: remove unnecessary newlines which caused invalid syntax
Resolves all warnings building Python docs.
2024-01-25 10:22:15 +11:00
Campbell Barton
1fa896bb9a Cleanup: move bl_description to doc-strings
This is already done almost everywhere, prefer doc-strings unless
there is a reason for the tool-tip and Python doc-string to differ.
2024-01-23 13:59:15 +11:00
Sybren A. Stüvel
9e5cdf52f6 Cleanup: fix indent in anim.py 2024-01-22 16:45:29 +01:00
Sybren A. Stüvel
a7354fb2af Anim: add operator to remove unused bone collections
Add an operator to remove all unused bone collections. This is added to
the bone collections "specials" menu and the tree view context menu.

A bone collection is considered "unused" when it has no bones assigned,
and also no child collection that has bones assigned.
2024-01-22 13:34:25 +01:00
Sybren A. Stüvel
acbb91b192 Fix: Anim, replace last arm.collections.all with arm.collections_all
Replace the last occurrences of `arm.collections.all` to
`arm.collections_all`. This has been the API since
015555b07a0aa8fa5e0ca8692eafd2c44dca429e.
2024-01-15 11:36:48 +01:00
Damien Picard
3bd41cf9bc I18n: Go over TIP_ and IFACE_ usages, change to RPT_ when relevant
The previous commit introduced a new `RPT_()` macro to translate
strings which are not tooltips or regular interface elements, but
longer reports or statuses.

This commit uses the new macro to translate many strings all over the
UI.

Most of it is a simple replace from `TIP_()` or `IFACE_()` to
`RPT_()`, but there are some additional changes:
- A few translations inside `BKE_report()` are removed altogether
  because they are already handled by the translation system.
- Messages inside `UI_but_disable()` are no longer translated
  manually, but they are handled by a new regex in the translation
  system.

Pull Request: https://projects.blender.org/blender/blender/pulls/116804

Pull Request: https://projects.blender.org/blender/blender/pulls/116804
2024-01-12 13:37:32 +01:00
Sybren A. Stüvel
2274f2be4b Anim: fix Solo Bone Collection operator
Fix the 'Show All' bone collection operator, by making it operate on all
collections instead of just the roots. It also now ensures that all
ancestors of the solo'ed collection are shown (otherwise it's the only
visible one, but given that its parent is hidden, it's still not
visible).

This also fixes a related issue, where calling the operator without
passing the `name` parameter would do nothing. Now it soloes the active
bone collection.
2024-01-08 14:34:10 +01:00
Sybren A. Stüvel
ef5dd0e451 Anim: fix Show All Bone Collections operator
Fix the 'Show All' bone collections operator, by making it operate on all
collections instead of just the roots.
2024-01-08 14:34:10 +01:00
Nate Rupsis
4ddb52a775 Anim: Action bake custom properties
Add custom properties to Action Bake.

objects will bake all animatable custom properties. Armatures will bake all bone custom properties,
as well as object (armature) custom properties.

Pull Request: https://projects.blender.org/blender/blender/pulls/113208
2023-12-29 17:59:24 +01:00
Damien Picard
faefaa4447 I18n: extract and disambiguate a few messages
Extract:
- Compositor error messages.
- `bUnitDef`s were broken after cleanup commit 2b77cd726d. Since each
  unit's "display name" is now preceded by a consistent "name_display"
  comment, the regex which extracts the unit is greatly simplified.
  It now relies on the presence of the comment instead of the struct
  order.
- "Preset" menu and "Apply Preset" button from the curveprofile
  template.
- Operator labels from the catalog context menu.

Disambiguate:
- "Bake Data": can mean "Which data to bake" (verb), or "The data that
  were baked" (noun).
- "Cache" in the Simulation Nodes panel is a verb, not a noun.
- "Mix" in the snapping menu is a noun, not a verb.
- "Top" and "Bottom" can mean the upper part of an object or the
  highest point or element of something like a menu or list.

Pull Request: https://projects.blender.org/blender/blender/pulls/115963
2023-12-19 18:41:09 +01:00
Damien Picard
6d70e9b05f UI: fix and improve a few messages
- "Frame Step" -> "Number of frames to skip forward while baking each
  frame": expand description which was just copying the prop name.
- "b-bone" -> "B-Bone": title case.
- "Volumes Lighting" -> "Volume Lighting": typo.
- "Volumes Shadows" -> "Volume Shadows": typo.
- "Insert Blank Keyframe (All Layer)" -> "(All Layers)": typo.
- "the an" -> "an", typo.
- "Inverse" -> "Invert": use verb instead of noun for an action.
- "Desination" -> "Destination": typo.
- "Hides all other F-Curves other than the ones being framed": remove
  extra "other".
- "Remove Bone from Bone collections" -> "Collection", singular because
  the operator is only applied to the active collection. Also title
  case on "Collection".
- "Change Stroke material with selected material" -> "Assign the
  active material slot to the selected strokes": rephrase by reusing
  the message from the non-Grease Pencil materials.
- "VisAction", "VisArea" -> "Visibility Action", "Visibility Area":
  expand abbreviation. This is not exposed in the UI right now but
  will show up in the API docs.
- "Stop Mode Right / Global Down" -> "Stop Move" (typo).
- "... for node input  %s": remove extra space.
- "Move along their normal" -> "Move shadows along their normal":
  rephrase unclear sentence.
- "Stat Vis" -> "Mesh Analysis": stands for "Statistical
  visualization"? Unclear and not shown anywhere. Reuse the label
  specified in the UI code instead.
- " Output data...": remove leading space.
- "Attribute domain for the selection and group id inputs": title case
  on "Selection" and "Group ID" as that is how they appear in the UI.
- "Ior" -> "IOR": uppercase acronym, for consistency.

Pull Request: https://projects.blender.org/blender/blender/pulls/115964
2023-12-11 00:23:03 +01:00
Bastien Montagne
7ce745a76b UI messages fixes/cleanups. 2023-11-20 12:20:58 +01:00
Campbell Barton
8eb5223663 Cleanup: remove unused variables & imports in scripts/ 2023-11-10 10:06:41 +11:00
Sybren A. Stüvel
0e420ea7ba Merge remote-tracking branch 'origin/blender-v4.0-release' 2023-10-05 14:36:46 +02:00
Sybren A. Stüvel
cf591606d1 Anim: change "Sync to Selected" to "Copy Colors to Selected"
"Sync" may imply that things are kept synchronous, while the operator
only performs a one-time copy. The new name & identifier reflect this
better.
2023-10-05 14:32:10 +02:00
Brecht Van Lommel
3bbd4294d9 Merge branch 'blender-v4.0-release' into main 2023-10-04 21:32:58 +02:00
Brecht Van Lommel
61f982f0d1 Cleanup: make format 2023-10-04 21:30:41 +02:00