Commit Graph

442 Commits

Author SHA1 Message Date
Aaron Carlisle
d8b90ee422 Docs: Update RNA to user manual URL mapping 2024-11-13 01:26:36 -05:00
Campbell Barton
325c8c0190 PyDoc: add doc-string for addon_utils.extensions_refresh 2024-11-09 13:19:27 +11:00
Campbell Barton
cd07e729a2 Fix #130024: addon_utils.enable(..) doesn't setup extensions wheels
addon_utils.enable/disable now handle wheels so that the functions can
be used with extension add-ons.

A new argument `refresh_handled` supports scripts handing refresh
themselves which is needed to avoid refreshing many times in cases
when there are multiple calls to enable/disable.

This is mostly useful for internal operations.
2024-11-09 11:44:34 +11:00
Campbell Barton
eb390425f3 Fix missing extensions refresh after the repository config changed
Enabling/disabling a repository was not refreshing its wheels or
compatibility data.
2024-11-09 11:10:26 +11:00
Alaska
79cb23b049 Add GPU backend to "Report a Bug" script
Adds the current GPU backend to the `Help -> Report a bug` script
when using the OpenGL or Vulkan backend. This makes it easier for
triagers to figure out if a user is using OpenGL or Vulkan
in cases the user doesn't explictly state which they're using.

Pull Request: https://projects.blender.org/blender/blender/pulls/130006
2024-11-08 14:25:35 +01: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
091ee2833b PyDoc: replace references to the deprecated "bgl" with "gpu"
Also correct bullet-points in gpu.state.blend_set.
2024-11-03 21:50:33 +11:00
Campbell Barton
b00550916c PyDoc: correct use of single back-ticks 2024-11-03 21:50:33 +11:00
Campbell Barton
901359abf7 Cleanup: replace doc-strings with comments for internal logic
There is no need to store text in memory for comments on functions
that aren't exposed publicly and are only of used when reading
the code.
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
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
a05345e139 PyDoc: various corrections to function doc-strings
Add missing arguments, corrections & remove unchecked type info.
2024-11-02 17:48:21 +11:00
Falk David
7e87da72ab Fix #129637: GPv3: Python: add_points raises exception
Introduced by 68c665ffa1.
This fix forgot to change parameters of `GreasePencilStrokePointSlice`
in `add_points`.
The fix also adds a test for `add_points` and `remove_points`.

Pull Request: https://projects.blender.org/blender/blender/pulls/129640
2024-10-31 16:22:44 +01:00
Falk David
ab3186120c Fix #129239: GPv3: Python: Vertex color is initialized as white
The default value for `FLOAT_COLOR` attributes is white. We can't
change this default easily.
This fix will initialize the attributes accessed through the high-level
python API with their expected default value. In the case of
vertex colors, this is fully transparent black.

Pull Request: https://projects.blender.org/blender/blender/pulls/129638
2024-10-31 15:37:02 +01:00
Falk David
b05e9f7bd6 Fix #127523: Missing update when updating positions with Python
The issue was that the strokes were not using the `POLY` type and
needed to be tagged.

This adds a function `tag_positions_changed` on the `GreasePencilDrawing`
so that the high-level python API can tag the positions if
the `point.position` attibute is written to.

Pull Request: https://projects.blender.org/blender/blender/pulls/129292
2024-10-21 14:10:32 +02:00
Bastien Montagne
2e6c24c58e I18N: Enable Romanian UI translation. 2024-10-20 18:20:01 +02:00
Bastien Montagne
387502ec53 I18N: Add Lithuanian UI translation. 2024-10-20 18:05:18 +02:00
Campbell Barton
528df90336 Cleanup: remove use of deprecated types for extensions (#2)
Missed these in a66601ee95.
2024-10-18 10:21:03 +11:00
Campbell Barton
f4f50fa2c5 Cleanup: replace typing.Union/Option with logical OR for extensions
Also remove use of deprecated typing.Sequence.
2024-10-18 10:08:12 +11:00
Campbell Barton
a66601ee95 Cleanup: remove deprecated typing built-ins for extension logic
Deprecated since Python 3.9 but still used in many docs/examples.
2024-10-17 19:11:40 +11:00
Campbell Barton
e2862ed7ca Cleanup: rename variables handling modules loaded at startup
The term "global" isn't meaningful in this context,
use "registered" instead.
2024-10-17 15:46:42 +11:00
Campbell Barton
6d24201045 Fix error on script reload if the modules aren't found in sys.modules
While unlikely, account for modules loaded on startup not being in
`sys.modules` when reloading scripts.
2024-10-17 12:59:07 +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
Campbell Barton
c3b067dc80 Cleanup: single/double quote use in scripts 2024-10-16 14:45:08 +11:00
Falk David
251250a3fb Fix #128991: GPv3: Python: Writing to invalid properties doesn't raise exception
When writing to a property that doesn't exist e.g. `frame.drawing.strokes.test = 42`
no exception would be raised and it would silently fail.

The fix defines the `__slots__` on the classes explicitly which then raises an exception
if the user tries to write something that wasn't previously defined.

Pull Request: https://projects.blender.org/blender/blender/pulls/129047
2024-10-15 12:23:02 +02:00
Falk David
39675bb0fb Fix: GPv3: Python: Setting attribute value always creates new attribute
When e.g. executing `drawing.strokes[0].softness = 3`, the API would
always create a new attribute `softness` even if that attribute existed
already.

The issue was that the code was using the `.get(value, fallback)` syntax
but the `fallback` expression is always evaluated by python.

The fix removes the use of the `fallback` and uses a simple `if/else` to
check if the attribute doesn't exist yet and only then create it.

Pull Request: https://projects.blender.org/blender/blender/pulls/129044
2024-10-15 12:22:32 +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
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
nutti
e7747c0d93 PyAPI: add type of bpy.types.NodeSocket.links
Ref !128626
2024-10-09 17:41:09 +11: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
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