Commit Graph

87 Commits

Author SHA1 Message Date
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
Campbell Barton
6ccbafc5dc Cleanup: spelling in comments 2024-11-06 10:49:51 +11:00
Campbell Barton
4210a4f1cf Fix error keymap conflict operator
Detecting conflicts was failing because of an undefined function call &
an unknown "Timeline" keymap in the keymap hierarchy.
2024-11-06 10:49:41 +11:00
Campbell Barton
d920ef5425 Merge branch 'blender-v4.3-release' 2024-11-03 22:04:44 +11:00
Campbell Barton
b00550916c PyDoc: correct use of single back-ticks 2024-11-03 21:50:33 +11:00
Campbell Barton
ca8d00d0bb Cleanup: add doc-strings for bpy_extras.id_map_utils 2024-11-03 21:50:29 +11:00
Campbell Barton
f17379a5d0 Merge branch 'blender-v4.3-release' 2024-11-03 16:07:40 +11:00
Campbell Barton
3bcfb151c1 PyDoc: use Python's type annotation syntax for doc-strings
Replace plain-text type information with the type syntax used
for Python's type annotations as it's more concise, especially for
callbacks which often didn't include useful type information.

Note that this change only applies to inline doc-strings,
generated doc-strings from RNA need to be updated separately.

Details:

- Many minor corrections were made when "list" was incorrectly used
  instead of "sequence".
- Some type information wasn't defined in the doc-strings and has been
  added.
- Verbose type info would benefit from support for type aliases.
2024-11-03 15:44:35 +11:00
Campbell Barton
71a38df6fa Merge branch 'blender-v4.3-release' 2024-11-02 18:02:15 +11:00
Campbell Barton
a05345e139 PyDoc: various corrections to function doc-strings
Add missing arguments, corrections & remove unchecked type info.
2024-11-02 17:48:21 +11:00
Christoph Lendenfeld
2fb0847dd1 Fix #129385: Bake Action operator not working with slots
This fixes the issue by traversing the new data structure for actions.
* When a slot is assigned, the action is baked into the slot.
* if no slot is assigned, it creates a new slot and bakes into that. However since no slot was assigned, the animation will be static.

Pull Request: https://projects.blender.org/blender/blender/pulls/129525
2024-10-29 16:39:10 +01:00
Campbell Barton
a0453ab87a Cleanup: update use of typing in for Python scripts 2024-10-23 12:48:09 +11:00
Campbell Barton
6d1e235f15 Cleanup: remove use of deprecated typing from scripts/modules/
Also use comments for typing that can't be checked.
2024-10-18 10:43:14 +11:00
Campbell Barton
b3c9c7c496 Merge branch 'blender-v4.3-release' 2024-10-16 21:08:17 +11:00
Christoph Lendenfeld
88f298f66f Fix: Error when baking custom properties of unavailable addon
When baking an Action on an object which has custom properties that come
from an addon or python script that isn't loaded, the baking would fail with:
```
TypeError: Cannot assign a 'dict' value to the existing 'hops' Group IDProperty
```

This comes from an addon that isn't present or loaded on a users machine.
The fix is to check for `IDProperty` and skip those.

Pull Request: https://projects.blender.org/blender/blender/pulls/129057
2024-10-16 10:42:32 +02:00
Sybren A. Stüvel
43d7558e5b Anim: Remove 'Slotted Actions' experimental flag
This commit takes the 'Slotted Actions' out of the experimental phase.
As a result:

- All newly created Actions will be slotted Actions.
- Legacy Actions loaded from disk will be versioned to slotted Actions.
- The new Python API for slots, layers, strips, and channel bags is
  available.
- The legacy Python API for accessing F-Curves and Action Groups is
  still available, and will operate on the F-Curves/Groups for the first
  slot only.
- Creating an Action by keying (via the UI, operators, or the
  `rna_struct.keyframe_insert` function) will try and share Actions
  between related data-blocks. See !126655 for more info about this.
- Assigning an Action to a data-block will auto-assign a suitable Action
  Slot. The logic for this is described below. However, There are cases
  where this does _not_ automatically assign a slot, and thus the Action
  will effectively _not_ animate the data-block. Effort has been spent
  to make Action selection work both reliably for Blender users as well
  as keep the behaviour the same for Python scripts. Where these two
  goals did not converge, reliability and understandability for users
  was prioritised.

Auto-selection of the Action Slot upon assigning the Action works as
follows. The first rule to find a slot wins.

1. The data-block remembers the slot name that was last assigned. If the
    newly assigned Action has a slot with that name, it is chosen.
2. If the Action has a slot with the same name as the data-block, it is
    chosen.
3. If the Action has only one slot, and it has never been assigned to
    anything, it is chosen.
4. If the Action is assigned to an NLA strip or an Action constraint,
    and the Action has a single slot, and that slot has a suitable ID
    type, it is chosen.

This last step is what I was referring to with "Where these two goals
did not converge, reliability and understandability for users was
prioritised." For regular Action assignments (like via the Action
selectors in the Properties editor) this rule doesn't apply, even though
with legacy Actions the final state ("it is animated by this Action")
differs from the final state with slotted Actions ("it has no slot so is
not animated"). This is done to support the following workflow:

- Create an Action by animating Cube.
- In order to animate Suzanne with that same Action, assign the Action
  to Suzanne.
- Start keying Suzanne. This auto-creates and auto-assigns a new slot
  for Suzanne.

If rule 4. above would apply in this case, the 2nd step would
automatically select the Cube slot for Suzanne as well, which would
immediately overwrite Suzanne's properties with the Cube animation.

Technically, this commit:
- removes the `WITH_ANIM_BAKLAVA` build flag,
- removes the `use_animation_baklava` experimental flag in preferences,
- updates the code to properly deal with the fact that empty Actions are
  now always considered slotted/layered Actions (instead of that relying
  on the user preference).

Note that 'slotted Actions' and 'layered Actions' are the exact same
thing, just focusing on different aspects (slot & layers) of the new
data model.

The "Baklava phase 1" assumptions are still asserted. This means that:
- an Action can have zero or one layer,
- that layer can have zero or one strip,
- that strip must be of type 'keyframe' and be infinite with zero
  offset.

The code to handle legacy Actions is NOT removed in this commit. It will
be removed later. For now it's likely better to keep it around as
reference to the old behaviour in order to aid in some inevitable
bugfixing.

Ref: #120406
2024-10-15 16:29:53 +02:00
Philipp Oeser
e89cf5ecc0 Merge branch 'blender-v4.3-release' 2024-10-10 13:55:29 +02:00
Philipp Oeser
9baf082dc5 Fix #128760: NLA bake action throws error
Caused by db6113048d

Above commit was accessing action properties which are only available if
experimental baklava is enabled.
Now check for this.

Pull Request: https://projects.blender.org/blender/blender/pulls/128762
2024-10-10 13:54:58 +02:00
Campbell Barton
3525b83c6b Cleanup: use specific exception types where appropriate 2024-10-08 09:41:53 +11:00
Campbell Barton
1a1e75c253 Cleanup: replace implicit BaseException with Exception
Exception is more appropriate as a general exception in these cases.
2024-10-08 09:41:51 +11:00
Campbell Barton
0b69e1d6f5 Cleanup: double quotes for strings, replace f-string with str.format 2024-10-02 15:46:11 +10:00
Campbell Barton
0afce08c20 Cleanup: use Python format specifiers 2024-10-01 10:14:48 +10:00
Christoph Lendenfeld
db6113048d Fix #126129: Bake Action not working
With layered actions, the bake action wasn't working.
More specifically it failed to create a slot on the action
and link that slot on the animation data.

The fix is to create the slot.

Pull Request: https://projects.blender.org/blender/blender/pulls/126546
2024-08-20 16:45:34 +02:00
Jacques Lucke
d81ba55ce4 Fix #124467: lazy-connect does not work with Capture Attribute node
The lazy-connect feature of node wrangler uses the built-in `connect_sockets`
function which automatically handles virtual sockets in group input and output
nodes already. However, it does not handle virtual sockets in other nodes.

The fix is to generalize this behavior. For that, a new `handle_dynamic_sockets`
boolean input is added to `tree.links.new`. When enabled, virtual sockets are
handled properly by internally calling the `bNodeType.insert_link` methods.

The new behavior is turned of by default for compatibility reasons.

Pull Request: https://projects.blender.org/blender/blender/pulls/126282
2024-08-13 16:25:20 +02:00
Dalai Felinto
b528aca711 Merge remote-tracking branch 'origin/blender-v4.2-release' 2024-06-28 11:46:45 +02:00
Campbell Barton
ac8da6c72e Extensions: move junction_module to a private location
bpy_extras is part of the public API where as the junction_module
is part of the internal implementation of extensions.
Move to "_bpy_internal".
2024-06-28 14:30:11 +10:00
Campbell Barton
0f5e816a7d Merge branch 'blender-v4.2-release' 2024-06-06 11:28:06 +10: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
Julian Eisel
a6ed013baa Refactor: Get asset data via asset representation, not file
The "active_file" context member as a way to get the active asset should be
avoided, in favor of "asset". This moves us away from the file browser backend
as basis of the asset system,
2024-06-05 13:46:33 +02:00
Jeroen Bakker
c7807a425a EEVEE: Alias/remove legacy RNA material attributes
- `bpy.types.Material.blend_method` aliases `bpy.types.Material.surface_render_method`.
  'Opaque' and 'Alpha Clip' maps to deferred.
- Renamed `show_transparent_back` to `use_transparency_overlap`
- Renamed `use_screen_refraction` to `use_raytrace_refraction`
- Deprecate `use_sss_translucency` and `use_sss_translucency`

Related to: #113976

**NOTE**
The light probe changes will be done in a different patch.
Both patches should land just before we remove EEVEE Legacy
from the code-base.

Pull Request: https://projects.blender.org/blender/blender/pulls/122297
2024-06-04 14:48:40 +02:00
Damien Picard
b37d121e0a I18n: extract and disambiguate a few messages
Extract
- Add to Quick Favorites tooltip.
- "Mask", the name of a newly created mask (DATA_).
- "New" in the context of the new mask ID button.
- A few strings using BLI_STR_UTF8_ defines were not extracted.
  Take the special characters out of the translation macros.
- "External" menu items from the filebrowser's Files context
  menu (right-click on a file). These items were already extracted,
  but not translated.

Improve
- Separate formatted error message "%s is not compatible with
  ["the specified", "any"] 'refresh' options" into two messages.

Disambiguate
- Use Action context for new F-modifiers' names. This is already used
  for the "type" operator prop.
- Translate ImportHelper's default confirmation text using the
  Operator context, as it uses the operator name which is extracted
  with this context.
- "Scale" can be a noun, the scale of something, or a verb, to scale
  something. The latter mostly uses the Operator context, so apply
  this context to verbs, and the default contexts to nouns.
- "Scale Influence" can mean "Influence on Scale" (tracking
  stabilization) and "to Scale the Influence" (dynamic paint canvas).
- "Object Line Art" as type of Line Art to add, as opposed to the
  active object's Line Art settings.
- Float to Integer node: use NodeTree context for the node label, as
  this is already extracted and used for the enum.

Do not translate
- Sequencer labels containing only a string formatting field.

Some issues reported by Gabriel Gazzán and Ye Gui.

Pull Request: https://projects.blender.org/blender/blender/pulls/122283
2024-05-27 19:33:35 +02:00
Campbell Barton
774f59dd07 Cleanup: remove unnecessary check left in last commit
Should have been removed in 236c0f61b1.
2024-05-22 20:22:47 +10:00
Campbell Barton
236c0f61b1 Cleanup: avoid duplicate attribute access in scripts 2024-05-22 20:20:47 +10:00
Christoph Lendenfeld
eee32726c7 Fix #121349: Baking adds keys on custom properties that are non-keyable
When keying custom properties that are defined by an addon,
you can't use square brackets. The GUI buttons already reflect that.
The baking code and the keyframe insertion code didn't respect
that and so were able to key properties that are defined as non-keyable.

## Solutions
I've solved the issue on the C++ side by resolving
the path twice, once without and in case that didn't work the
second time with brackets. While that does solve the issue
this feels really dirty and I feel like I am misusing the system here.
**However it is absolutely needed**.
When resolving a path with brackets to a property defined
by an addon, you get an `IDProperty` disguised as a `PropertyRNA`
which will not have the correct flags set.

By checking if a property `is_animatable` in python, all that do not have that can be skipped.
Also making sure the path is passed without brackets in the correct cases.

Pull Request: https://projects.blender.org/blender/blender/pulls/121520
2024-05-10 17:03:52 +02:00
Campbell Barton
5088b0154d Cleanup: replace %-formatting with str.format in scripts/modules/
The "bl_i18n_utils" module has been excluded I'm not sure how best
to run it with reasonable code coverage.
2024-04-27 16:06:51 +10:00
Hans Goudey
e6808cd558 Cleanup: Make format 2024-03-28 20:55:23 -04:00
Jesse Yurkovich
af7a34dee7 ImportHelper: Common methods for FileHandler drag and drop support
Provide common implementations for two operations that all Python
FileHandlers will typically use.

- `poll_file_object_drop` To be used inside the FileHandler `poll_drop`
   callback
- `invoke_popup` To be used inside the Operator `invoke` callback

The above code closely mirrors what is currently done inside the
existing Blender c++ FileHandlers.

Pull Request: https://projects.blender.org/blender/blender/pulls/119774
2024-03-29 01:22:51 +01:00
Campbell Barton
f347706ecd Cleanup: add "unreachable" message to "assert False" statements
Clarify that these blocks are unreachable so the intention is clear
if they're ever encountered.
2024-03-15 13:20:11 +11:00
Jacques Lucke
653108068d Merge branch 'blender-v4.1-release' 2024-03-13 10:39:48 +01:00
Jacques Lucke
5c65dba14c Cleanup: make format 2024-03-13 10:39:22 +01:00
Jesse Yurkovich
3762ead281 Merge branch 'blender-v4.1-release' 2024-03-12 21:23:58 -07:00