Commit Graph

421 Commits

Author SHA1 Message Date
Bastien Montagne
78a3ef1d53 Merge branch 'blender-v4.3-release' 2024-10-14 10:55:42 +02:00
Falk David
89e3ab2a45 Fix: GPv3: Error when calling add_points or remove_points
The `drawing.resize_curves` function had been renamed in
1899ea25d5 but this wasn't
updated in the strokes API.
2024-10-14 10:40:52 +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
52ced621c7 Merge branch 'blender-v4.3-release' 2024-10-09 17:42:05 +11:00
nutti
e7747c0d93 PyAPI: add type of bpy.types.NodeSocket.links
Ref !128626
2024-10-09 17:41:09 +11:00
Falk David
da339407a9 Fix: Python: Empty list of drawing.strokes doesn't have length of 0
The API would return `None` if the number of strokes in the drawing was `0`.
Instead this should return a slice that has a length of 0 to be consistent.
2024-10-08 12:43:58 +02:00
Falk David
09ca5a4c5f Fix: Python: Empty list of drawing.strokes doesn't have length of 0
The API would return `None` if the number of strokes in the drawing was `0`.
Instead this should return a slice that has a length of 0 to be consistent.
2024-10-08 11:43:56 +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
Falk David
68c665ffa1 Fix #128646: Wrong selection results using the high-level python API
The issue was that the API assumed that the `.selection` attribute
was always on either the point domain for points or the stroke domain
for strokes.
Internally the attribute domain depends on the current selection mode.

To fix the issue, the API now checks for the domain of the attribute
and handles it accordingly.

If the selection attribute is on the `'POINT'` domain:
* Reading the `stroke.select` property will check if *any* of the points of
the stroke are selected and return `True` or `False`.
* Writing to the `stroke.select` property will write `True` or `False` to *all* the
points in the stroke.

Also resolves #128645.

Pull Request: https://projects.blender.org/blender/blender/pulls/128687
2024-10-07 18:17:45 +02:00
Aaron Carlisle
522a21c58b Docs: Update RNA to user manual URL mapping 2024-10-05 00:51:36 -04:00
Lukas Tönne
c986aa03b9 GPv3: Remove unused GPv2 keymap entries
This should free up references to GPv2 types and operators and should
in turn make their removal easier.

- Remove keymaps for GPv2 operators from `blender_default.py` and
  `industry_compatible_data.py`
- Remove keymap poll callback assignment from `gpencil_ops.cc`
- Remove keymap handler registration from `area.cc:ed_default_handlers`

Pull Request: https://projects.blender.org/blender/blender/pulls/128480
2024-10-03 11:18:31 +02:00
Campbell Barton
1563ba7e6c Fix #128175: Updating extension can remove the extension on WIN32
On Windows an entire directory may be locked when any files inside it
are opened by another process. This can cause operations that
recursively remove a directory (uninstalling & updating) to fail
with a partially removed extension.

The case of uninstalling was already handled, where failure to remove
a directory would stage the extension for later removal.
In the case of updating however, the user could be left with a broken
(partially removed) extension where some files were removed, as the
directory was locked, the update would fail to extract new files.

Address this issue by renaming the directory before recursive removal.

The following logic has been implemented:

- If any files in the directory are locked, renaming will fail.
  So even though the operation fails the extension is left intact.

- If renaming succeeds, it's possible to apply the update.

  While it's possible (albeit unlikely) recursive removal fails,
  which could be caused by file-system permissions issues corruption or
  a process could open a file between rename & removal.

  In this case the renamed directory is staged for later removal.

Other changes:

- Resolve a related problem where the user could install an
  extension previously staged for removal, now installing an extension
  ensured it's not removed later.

  This would occur if uninstalling failed, the user resolves
  directory-lock, uninstalls again, then re-installs the extension.

- When an extension fails to be removed, don't attempt to remove
  user configuration for that extension.

  Prefer to keep the extension & it's settings in their "current state"
  if it can't be removed.
2024-10-03 12:15:27 +10: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
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
9f072ecefb Cleanup: remove unused exception values 2024-10-01 10:30:04 +10:00
Campbell Barton
0afce08c20 Cleanup: use Python format specifiers 2024-10-01 10:14:48 +10:00
Jeroen Bakker
b6da18172b Cleanup: Make format 2024-09-16 13:30:21 +02:00
Bastien Montagne
d52d70324d Fix (chat-reported) Py-defined operators id being added to translation files.
Yet another consequence/fix from fixing the type value of
`bpy.types.*.bl_rna` in our BPY code (21b820cd33).
2024-09-16 12:56:35 +02:00
Bastien Montagne
81cdcf8326 Fix (unreported) I18N tool failing to process RTL languages on Linux. 2024-09-16 12:41:11 +02:00
Bastien Montagne
902693a6a5 Add Urdu language entry. 2024-09-16 12:41:11 +02:00
Andres Stephens
7cff7998ad Fix: #127522: Preferences: GPv3: Show GP3 categories in the keymap editor
Shows the GPv3 keymap categories in the list for editing, adding and discoverability.

Fix for #127522.

Pull Request: https://projects.blender.org/blender/blender/pulls/127533
2024-09-16 12:05:41 +02:00
Campbell Barton
c6afb0e270 Core: remove sdlew/WITH_SDL_DYNLOAD & disable SDL by default
Disable dynamic SDL loading as well as disable SDL for release builds.

This was only used for audio output which can already use OpenAL
if there are back-ends not natively supported by Blender.

- Remove extern/sdlew/
- Remove the WITH_SDL_DYNLOAD build option.
- Remove `bpy.app.sdl.available`.

Ref !127554
2024-09-13 22:44:35 +10:00
Campbell Barton
43f7b50df3 Fix #127127: bpy.types sometimes reference their parent's "bl_rna"
Accessing `bl_rna` for type defined in `scripts/modules/bpy_types.py`
could return their parent-classes RNA when accessed via their parent
types __subclasses__() method.
2024-09-06 14:57:26 +10:00
Campbell Barton
97179b10fb Refactor: make "sys_info" an internal module, rename for clarity
- Move sys_info into an internal module to avoid having so many
  top level modules for Blender's internal functionality.
- Rename system_info sub-modules that pre-fill URL's for clarity.
- Move top-level exception handling into the operator.
- Report an error if an unexpected exception occurs.
- Use `Exception` instead of `BaseException` as there is no reason to
  catch the additional exceptions.
- Remove use of sys_info from the command line example,
  replace with in-lined system info.
2024-09-06 11:11:26 +10:00
Campbell Barton
3cb95b0be9 Cleanup: avoid repetition in version extraction 2024-09-03 13:44:44 +10:00
Alaska
3196ef1636 Add a script to collect system information when Blender isn't opening
This commit adds a python script that can collect some of the
information necessary to fill out a bug report.

The primary use case is to help users collect system information for
a bug report in the case that Blender can't open.

CMD and sh files are included to help users use the Python script.

Ref !122191
2024-09-03 13:26:54 +10:00
Miguel Pozo
7a55bdeaf9 EEVEE: Enable translation of screen messages
Add `Instance::info_append` so it's easier to log correctly formatted
info, and `Instance::info_append_i18n` to support string localization.

Co-authored-by: Damien Picard
Co-authored-by: Bastien Montagne <mont29@noreply.localhost>
Pull Request: https://projects.blender.org/blender/blender/pulls/124257
2024-09-02 20:13:31 +02:00
Bastien Montagne
b5ea3beaf9 Fix i18n message extraction tool after recent BPY/RNA fix.
Recent fix 21b820cd33 in BPY/RNA code broke introspection code of RNA
data in i18n message extraction code.

Luckily, it actually fixes things, and allows to remove some of the ugly
hacks we had in this code, especially regarding Operators handling.
2024-09-02 15:59:16 +02:00
Aaron Carlisle
a08005f484 Docs: Update rna manual references 2024-08-30 17:18:23 -04:00
YimingWu
c5bdaaf96c Python: Add a note for clarifying GreasePencilDrawing::strokes() validity
When point/curves count of a `GreasePencilDrawing` is changed, prior stroke
slices are no longer valid. This is not obvious when using the `stroke()`
call since it is meant to provide a easier access to the drawing data and
did not represent the actual data layout in the drawing, hence we need an
additional note in the document to tell users to be more careful.

Pull Request: https://projects.blender.org/blender/blender/pulls/126815
2024-08-27 17:51:30 +02:00
Campbell Barton
5cb29528e6 Cleanup: spelling in comments 2024-08-26 11:50:15 +10:00
Falk David
3ca9396cc3 Fix #126613: GPv3: Python: Writing to stroke.curve_type crashes Blender
Writing to the `curve_type` attribute directly is not allowed as there are other
updates needed and otherwise will result in a crash.

The fix makes sure the `curve_type` is read-only. To change the curve type,
the `grease_pencil.set_curve_type` operator has to be used for now.
2024-08-23 18:24:37 +02: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
Falk David
850e316688 Refactor: Move Grease Pencil helper classes to _bpy_internal
This moves the helper python classes from `scripts/modules/grease_pencil_python.py`
to `scripts/modules/_bpy_internal/grease_pencil.py`.

It also cleans up the code a bit more. No functional changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/126403
2024-08-20 11:11:53 +02:00
Campbell Barton
8a7ff41a85 Cleanup: wrap long lines in Python scripts 2024-08-19 10:48:07 +10:00
Campbell Barton
fe6ab4f344 PyDoc: corrections to formatting and resolve warnings
Use RST formatting for doc-strings used in Python API docs
as well as minor corrections, also add links for foreach_get/set.
2024-08-19 10:48:06 +10:00
Campbell Barton
f9a16c4cdb Fix failure to remove libraries when removing wheels
Disabling wheels wasn't removing the modules "*.libs" directories.
2024-08-16 18:12:57 +10:00
Campbell Barton
58c7237bbf Fix #125958: Disabling/uninstalling extensions doesn't remove wheels
Cleaning up wheels was skipped when there were no enabled extensions.

Now this is only skipped when there are no extensions on startup.
2024-08-16 18:12:57 +10:00
Campbell Barton
d777267982 Cleanup: use str.format instead of f-strings 2024-08-16 09:33:20 +10:00
Campbell Barton
d6c5010936 Cleanup: use deferred import for faster startup 2024-08-16 09:33:20 +10:00
Campbell Barton
d71d325692 Cleanup: spelling in comments, strings 2024-08-16 09:33:20 +10:00
Falk David
ed3c16624b GPv3: High level python API
This extends the `GreasePencilDrawing` rna type using python.
The goal is to add an API that allows developers to transition to
the new grease pencil API a bit more smoothly.

Adds the following endpoints to the `GreasePencilDrawing`:
* `drawing.strokes`: Returns a list/slice of `GreasePencilStroke`s in the drawing.

Adds a python class `GreasePencilStroke`:
* `stroke.points`: Returns a list/slice of `GreasePencilStrokePoint`s.
* Getters/Setters of attributes for this stroke:
   * `stroke.cyclic`
   * `stroke.material_index`
   * `stroke.select`
   * `stroke.softness` (used to be `hardness`)
   * `stroke.start_cap`
   * `stroke.end_cap`
   * `stroke.curve_type`: The type of curve: `POLY`,`BEZIER`,`CATMULL_ROM`,`NURBS`.
   * `stroke.aspect_ratio`
   * `stroke.fill_opacity`
   * `stroke.fill_color`
   * `stroke.time_start`
* High-level functions:
   * `stroke.add_points(count)`: Adds `count` points at the end of the stroke.
  * `stroke.remove_points(count)`: Removes `count` points from the end of the stroke. Note that this will not remove the stroke if the count is greater than the number of points in the stroke. A stroke has at least 1 point. Removing strokes can be done from the drawing.

Adds a python class `GreasePencilStrokePoint`:
* Getters/Setters of attributes for this point:
   * `position`
   * `radius`
   * `opacity`
   * `select`
   * `vertex_color`
   * `rotation`
   * `delta_time`

Note that `GreasePencilStroke` and `GreasePencilStrokePoint` are not stored in the file and don't have an RNA API. This means that they are not compatible with e.g. `layout.prop`.

This API should not be used for performance critical code. It's likely
even slower than the python API from 4.2.

There will be migration documentation for addon developers here:
https://developer.blender.org/docs/release_notes/4.3/grease_pencil/#python-api-changes

Pull Request: https://projects.blender.org/blender/blender/pulls/125599
2024-08-15 10:58:21 +02:00
Campbell Barton
9f931ee3d2 Presets: consider presets within the extensions repo to be "built-in"
It was possible to remove a preset defined within an extension,
the only way to restore it was to uninstall & re-install the extension.
2024-08-15 16:06:11 +10:00
Campbell Barton
f42713ab1d Fix unhandled permissions exception in bpy.utils.is_path_builtin
An excepting would be raised when the parent/child paths didn't
have permissions to access.
2024-08-15 16:06:10 +10:00
Campbell Barton
5f9be675f0 Cleanup: move bpy.utils parent-path check into a function 2024-08-15 16:06:08 +10: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
Bastien Montagne
7d52265771 Fix several issues with i18n tools on non-linux platforms.
- Paths of C++-parsed files were not properly 'unixified' on Windows.
  This was bad both for changes noisyness in PO files, and broke on
  the un-escaping of `\n` and `\t` sequences.
- The `ProcessPoolExecutor` starts sub-processes differently on Linux
  than on Windows or OSX. While Linux's `fork` keeps the same
  environment (i.e. all Blender stuff remains available in workers
  subprocesses), the 'spawn' used on Windows (and reportedly OSX) starts
  a new bare python interpreter. This means that code executed by these
  needs to be Blender-agnostic to be portable.

The only thing that is currently known broken on non-Linux platforms is
the RTL processing of some languages like Arabic or Hebrew.
2024-08-10 17:35:28 +02:00
Campbell Barton
fc6a99e0d2 Fix #77837: Error removing addons/extension/wheels on WIN32
When deleting files on WIN32, open files cannot be removed.
This is especially a problem for compiled Python modules which
remain open once imported.

Previously it was not as common for add-ons to include compiled Python
modules however with extensions supporting Python-wheels,
it's increasingly likely users run into this.

Workaround the problem by:
- Scheduling the files for removal next time Blender starts.
- Rename paths that cannot be removed to avoid collisions when
  the paths is reused (re-installing for example).

This is supported for:
- Extensions.
- Python wheels.
- Legacy user add-ons.
- App-templates.

Details:
- On startup, a file exists that indicates cleanup is needed.
  In the common case the file doesn't exist.
  Otherwise module paths are scanned for files to remove.
- Since errors resolving paths to remove could result in user data loss,
  ensure the paths are always within the (extension/addon/app-template)
  directory.
- File locking isn't used, if multiple Blender instances start at the
  same time and try to remove the same files, this won't cause errors.
  Even so, remove the checking file immediately avoid unnecessary
  file-system access overhead for other Blender instances.

Also resolves #125049.
2024-08-05 09:49:14 +10:00