Commit Graph

608 Commits

Author SHA1 Message Date
Campbell Barton
eb2cc80cd0 PyAPI: move bpy_types.py to a private module
Use an underscore prefix as this module should not be accessed directly.
2025-08-10 13:45:40 +10:00
Campbell Barton
b3e36d6983 Cleanup: replace unused RNA doc-string with comment
The doc-string used in the manual is stored in RNA.
2025-08-10 11:23:45 +10:00
Aaron Carlisle
8c932cb507 Docs: Update RNA to user manual URL mapping 2025-08-09 19:28:54 -04:00
Aaron Carlisle
86cd240c57 PyDocs: Add Macro example
- Adds a doc string for the Macro class
- Adds a basic example

Fixes #blender-manual/issues/51387
2025-08-09 18:43:14 -04:00
Pratik Borhade
7fd85e28ce Fix #143638: Spreadsheet Generic context is missing from Keymaps list
Spreadsheet generic keymap was missing from the keymap UI. To fix this,
add entry in `keymap_hierarchy.py`.

Pull Request: https://projects.blender.org/blender/blender/pulls/143689
2025-08-08 15:46:06 +02:00
Campbell Barton
53cae68ee8 Cleanup: hyphenate the term data-blocks in strings/doc-strings 2025-08-08 08:47:13 +10:00
Sean Kim
5066173fbf Fix #143110: Custom keymaps missing versioning for unified settings
Introduced in 4434a30d40

The above commit changed many of the `wm.radial_control` default
keybinds used in various paint modes to support accessing the "unified"
properties on a per-mode basis. While the base Blender keymap and the
industry compatible keymap were updated, this change was not applied
to custom keymaps, leading to confusing behavior for the users.

Pull Request: https://projects.blender.org/blender/blender/pulls/143872
2025-08-06 18:23:11 +02:00
Sybren A. Stüvel
9b0b011f5d HTTP Downloader: ensure __main__.__file__ is not set when spawning process
Ensure that `__main__.__file__` is not set to "<blender string>" when
spawning the subprocess for the background downloader. Blender sets this
value when executing a Python string from C++ code. However, this value
causes issues with Python's `multiprocessing` module, as it expects that
IF the attribute is set, it contains the actual file of the actual main
module. Clearing it works fine, as `__file__` is optional anyway.

Pull Request: https://projects.blender.org/blender/blender/pulls/143985
2025-08-06 14:22:47 +02:00
Damien Picard
5998795aa6 UI: Replace contractions with long-form text
Avoid using contractions for can't, aren't, doesn't, and shouldn't.
Following the writing style guide in the Human Interface Guidelines.

Pull Request: https://projects.blender.org/blender/blender/pulls/143852
2025-08-05 11:16:22 +02:00
Bastien Montagne
6acdca7b92 I18N: Add Malayalam language to UI translations. 2025-08-04 12:08:17 +02:00
Campbell Barton
9c29815d00 Docs: include a note on when key-map versioning runs 2025-08-02 13:37:19 +10:00
Sybren A. Stüvel
3ca28acbb3 Introduce Python code generator for OpenAPI spec to dataclasses
Add a [Python code generator][1] that takes an OpenAPI definition and
outputs the corresponding data model as [dataclasses][2]

This is intended to be used in the Remote Asset Library project, to
create, download, parse, and validate information of a remote asset
library.

[1]: https://koxudaxi.github.io/datamodel-code-generator/
[2]: https://docs.python.org/3/library/dataclasses.html

## Running the Generator

The generator is a Python script, which creates its own Python
virtualenv, installs the dependencies it needs, and then runs the
generator within that virtualenv.

The script is intended to run via the `generate_datamodels` CMake
target. For example, `ninja generate_datamodels` in the build
directory.

## Details

The virtualenv is created in Blender's build directory, and is not
cleaned up after running. This means that subsequent runs will just
use it directly, instead of reinstalling dependencies on every run.

## Generated Code & Interaction with Build System

It is my intention that the code generation _only_ happens when the
OpenAPI specification changes. This means that the generated code will
be committed to Git like any hand-written code. Building Blender will
therefore _not_ require the code generator to run. Only people working
on the area that uses the generated code will have to deal with this.

Pull Request: https://projects.blender.org/blender/blender/pulls/139495
2025-08-01 16:33:56 +02:00
Campbell Barton
2c27d2be54 Cleanup: grammar corrections, minor improvements to wording 2025-08-01 21:41:24 +10:00
Sybren A. Stüvel
3d40246e94 Python: add HTTP file downloader
Add a new package `scripts/modules/_bpy_internal/http`, containing
classes to download files via HTTP.

The code is intentionally put into the `_bpy_internal` package, as I
don't intend it to be the end-all-be-all of downloaders for general
use in add-ons. It's been written to support the Remote Asset Library
project (#134495), where it will be used to download JSON files (to
get the list of assets on the server) as well as the asset files
themselves.

The module consists of several parts. The main ones are:

`class ConditionalDownloader`
: File downloader, which downloads a URL to a file on disk.

  It supports conditional requests via `ETag`/`If-None-Match` and
  `Last-Modified`/`If-Modified-Since` HTTP headers (RFC 7273, section 3.
  Precondition Header Fields). A `304 Not Modified` response is
  treated as a succesful download.

  Metadata of the request (the response length in bytes, and the above
  headers) are stored on disk, in a location that is determined by the
  user of the class. Probably in the future it would be nice to have a
  single sqlite database for this (there's a TODO in the code about
  this).

  The downloader uses the Requests library, and manages its own HTTP
  session object. This way it can handle TCP/IP connection reuse,
  automatically retry failing connections, and in the future
  HTTP-level authentication.

`class BackgroundDownloader`
: Wrapper for a `ConditionalDownloader` that manages a background
  process for the actual downloading.

  It runs the downloader in a background process, while ensuring that
  its reporters (see below) get called on the main process. This way
  it's possible to do background downloading, while still receiving
  progress reports in a modal operator, which in turn can directly
  call Blender's Python API. Care was taken to [not use Python
  threads][1]

`class DownloadReporter`
: Protocol class. Objects adhering to the protocol can be given to a
  `ConditionalDownloader` or `BackgroundDownloader`. The protocol has
  functions like `download_starts(…)`, `download_progress(…)`,
  `download_error(…)`, which will be called by the downloader to
  report on what it's doing.

  I chose to make this a protocol, rather than an abstract superclass,
  because then it's possible to make an Operator a DownloadReporter
  without requiring multi-classing.

[1]: https://docs.blender.org/api/main/info_gotchas_threading.html

Pull Request: https://projects.blender.org/blender/blender/pulls/138327
2025-08-01 12:27:56 +02:00
Falk David
cd7b933cb6 Fix #143715: Grease Pencil: Replace uses of legacy BlendData type
There were some more uses of the legacy Grease Pencil type
in `BlendData`.

Pull Request: https://projects.blender.org/blender/blender/pulls/143716
2025-07-31 18:14:44 +02:00
Campbell Barton
3de916ca25 RNA: support for marking properties as deprecated
Deprecation meta-data support for RNA properties.

- Properties may have a deprecated note and version.
- Warnings shown when these are accessed from Python.
- A note is included in the generated documentation.

Support for marking functions as deprecated can be added in the future.

Ref !139487
2025-07-29 22:09:59 +10:00
Brecht Van Lommel
eb8dc8f535 Fix: Operator, app template and benchmarking script errors after media type
Always set the media type before the file format.

Ref #142955

Pull Request: https://projects.blender.org/blender/blender/pulls/143433
2025-07-28 11:55:11 +02:00
Campbell Barton
2d0a418a47 Fix #141853: Enum values aren't quoted in API doc function signatures
Regression in [0] which used string literals for enum lists
unintentionally removed the quotes for function signatures.

[0]: 0fb80f698a
2025-07-27 16:45:03 +10:00
Campbell Barton
81e4558ab6 Cleanup: reduce right-shift in Python scripts 2025-07-22 11:59:43 +10:00
Campbell Barton
e5947bdf63 Cleanup: spelling (make check_spelling_*)
Also exclude some files that have too many false positives.
2025-07-20 14:59:19 +10:00
Aaron Carlisle
4a17e42e2b Merge branch 'blender-v4.5-release' 2025-07-09 00:56:00 -04:00
Aaron Carlisle
5bf8edb589 Docs: Update RNA to user manual URL mapping 2025-07-09 00:53:41 -04:00
Bastien Montagne
a345b83f1a Merge branch 'blender-v4.5-release' 2025-07-07 15:53:53 +02:00
Damien Picard
3aa633304a I18n: Disambiguate "Strip" for exporter filepath mode
"Strip" generally is a sequencer or animation strip, but in this
context it is a string manipulation action for file names. It is
defined as part of the Path Mode defined in the FBX and OBJ exporters.
Those exporters are defined in Python and C++, respectively. This
commit changes both exporters to use the "File browser" translation
context.

In addition, the tooltip for "Relative" from the FBX exporter was
changed to match its OBJ counterpart, and the "Strip Path" mode was
also matched to the other version which reads better as an enum item.

Reported by Ye Gui in #43295.
2025-07-07 12:02:25 +02:00
Damien Picard
61b0ff9e57 I18n: Extract node panel names using translation contexts
Commit 9ce0a2d1d5 added the ability to specify translation contexts to
node UI panels, but it failed to update the regex that extracts them.
This commit solves that by adding the proper `add_panel` function to
the extraction regex.

Reported by Satoshi Yamasaki in #43295.
2025-07-07 12:02:25 +02:00
Damien Picard
14957fe2ac I18n: Translate Window manager job names
Job names displayed in the status bar were not extracted or
translated. This commit adds a regex to the bl_i18n_utils settings to
detect `WM_jobs_get()`, and the `RPT_` translation macro to translate
the message in the UI.

About 30 new messages are translated.

Reported by Ye Gui in #43295.
2025-07-07 12:02:25 +02:00
Andrej730
560e81075a Fix: PyDocs - add missing Context.copy() return type
Ref !141359
2025-07-03 10:59:17 +10:00
Andrej730
b06bf220b9 Fix: PyDocs - add missing Context.copy() return type
Ref !141359
2025-07-03 10:15:32 +10:00
Aras Pranckevicius
293cdac6ab Merge branch 'blender-v4.5-release' 2025-07-01 11:53:30 +03:00
Damien Picard
0ba83d8958 I18n: Translate GN Add > Input > Import menu items
Geometry Nodes' Add > Input > Import menu includes file format items
such as "Standford PLY (.ply)", "STL (.stl)", "Text (.txt)". The
latter needs to be translated because "Text" is a generic format.

These items are declared using a custom function
`node_add_menu.add_node_type`, with a `label` argument. This commit
adds the `label` argument to the function arguments that can be
extracted from specific node declaration functions, and specifies the
argument position for each:

"add_node_type", "add_node_type_with_outputs", "add_simulation_zone",
"add_repeat_zone", "add_foreach_geometry_element_zone",
"add_closure_zone".

There is currently no facility to specify a translation context but it
could be easily added if the need arises.

Most of these functions do not actually declare new, unique messages,
but it could happen in the future. In addition, two messages were
extracted using manual `iface_()` calls, which are no longer needed
after this change.

Reported by Ye Gui in #43295.
2025-07-01 10:47:09 +02:00
Campbell Barton
084ded1c07 Merge branch 'blender-v4.5-release' 2025-06-30 17:21:10 +10:00
Campbell Barton
0fb80f698a PyDoc: use string literals for enum values
Use literals since their literal values need to be used in code.
2025-06-30 17:12:04 +10:00
Aaron Carlisle
60ba9a2595 Merge branch 'blender-v4.5-release' 2025-06-29 15:29:29 -04:00
Aaron Carlisle
03d7ed05b9 Docs: Update RNA to user manual URL mapping 2025-06-29 15:28:46 -04:00
Campbell Barton
0d3826b354 Cleanup: make the blend file header private
This was split out as part of a refactor but isn't intended to be a
new public module for other scripts to use.

Ref !141088
2025-06-28 08:40:31 +10:00
Ramon Klauck
53578d33ae VSE: Keyframing in Preview
This PR makes it easier to add keyframes for strips in preview.
This works same way as in 3D viewport, using keying sets. Pressing I
key adds keyframe to default keying set, pressing K dhows menu with
available keying sets. For VSE, location, rotation and scale properties
are available for now. Other existing keying sets are not valid for
VSE.

Deleting keyframes and potentially adding more keying sets will be
handled in separate PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/140107
2025-06-25 02:56:55 +02:00
Campbell Barton
b2f8f1c1c5 Cleanup: remove unused variable, imports, correct typo 2025-06-24 11:35:53 +10:00
Jacques Lucke
f0c7e52ff2 Core: extract blendfile_header.py as common utility for parsing .blend files
This new file can parse the file header (first few bytes) as well as the block
headers.

Right now, this is used by two places:
* `blendfile.py` which is used by `blend2json.py`
* `blend_render_info.py`

This new module is shipped with Blender because it's needed for
`blend_render_info.py` which is shipped with Blender too. This makes using it in
`blendfile.py` (which is not shipped with Blender) a bit more annoying. However,
this is already not ideal, because e.g. `blend2json` also has to add to
`sys.path` already to be able to import `blendfile.py`.

This new file could also be used by blender-asset-tracer (BAT).

The new `BlendFileHeader` and `BlockHeader` types may be subclassed by code
using it, because it wants to store additional derived data (`blendfile.py` and
BAT need this).

New tests have been added that check that the file and block header is parsed
correctly for different kinds of .blend files.

Pull Request: https://projects.blender.org/blender/blender/pulls/140341
2025-06-23 12:53:55 +02:00
Michal Krupa
fdaaea6328 Core: Increase MAX_ID_NAME length from 66 to 258 (Blender 5.0)
Change the maximum data-block name from 64 to 256 bytes by increasing MAX_ID_NAME value.

Also increase a few related non-ID data name max size, essentially the action slots identifiers, as these are the primary key used to match an Action's slot to an ID by name.

Other sub-data (bones, modifiers, etc.) lengths are not modified here, as these can be made actual dynamic strings in the future, while keeping (a reasonable level of) forward compatibility, during the course of Blender 5 release cycles.

Implements #137608.

Co-authored-by: Bastien Montagne <bastien@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/137196
2025-06-19 16:39:20 +02:00
Clément Foucault
decd88f67e Python: Remove deprecated BGL API
The API was in a deprecation state for many years now.
This API was not compatible with Metal nor Vulkan.

This also remove `Image.bindcode`.

Pull Request: https://projects.blender.org/blender/blender/pulls/140370
2025-06-16 12:50:50 +02:00
Brecht Van Lommel
b920f6f1a7 Shaders: Remove point density texture node
This is replaced by geometry nodes, where volumes can now be generated from
point clouds and meshes with more control, and more efficient rendering as a
sparse volume.

No backwareds compatibility is provided, as this would be complicated, and
probably this feature was not used much in the past few years.

This node was supported in Cycles only, not by EEVEE.

Pull Request: https://projects.blender.org/blender/blender/pulls/140292
2025-06-16 12:06:02 +02:00
Bastien Montagne
d7b6c584e1 Merge branch 'blender-v4.5-release' 2025-06-11 13:12:48 +02:00
Damien Picard
798f85a710 Fix #139838: UI: Improve languages list and labels
Edit the language list to make it simpler to scan.

- Display languages in a form "Language (Variant)", such as
  "English (US)" instead of "American English" and
  "Portuguese (Brazil)" instead of "Brazilian Portuguese".
  This allows alphabetical sorting by language first.
  This does not apply to endonyms (languages in their own language).
- Use a dash instead of parentheses to separate the endonyms.
- Deduplicate languages (Automatic, American English, British
  English), which all are in English and don't appear in another
  language.

- Remove language categories as headers. They are replaced with
  percentages in the language tooltips. The percentages are
  generated in utils_languages_menu.py and stored in
  locale/languages.

Co-authored-by: Bastien Montagne <bastien@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/140087
2025-06-11 13:11:40 +02:00
Falk David
d4c143957f Merge branch 'blender-v4.5-release' 2025-06-09 14:16:12 +02:00
Clément Foucault
1c47e31367 GPU: Enable GL multithreaded compilation by default
This allows to reduce the waiting time caused by
shader compilation on some GPU-driver combo.

A new settings in the User Preferences make it
possible to override the default amount of worker
threads and optionally use subprocesses.

We still use only one worker thread in cases where
there is no benefit with adding more workers
(like AMD pro driver and Intel windows).

It doesn't scale as much as subprocesses for material
shader compilation but that is for other reasons
explained in #139818.

Add some heuristic to avoid too much memory usage
and / or too many stalls.

Also add some heuristic to the default number of subprocess for
the platform that shows scalling.

Historically, multithreaded compilation was prevented by the
need of context per thread inside `DRWShader` module.
Also there was no good scaling at that time. But
nowadays numbers shows different results with
good scaling with reasonable amount of threads on many
platforms.

Even if we are going for vulkan in the next release
most of the legacy hardware will still use OpenGL for
a few other releases. So it is relevant to make this
easy improvement.

See pull request for measurements.

Pull Request: https://projects.blender.org/blender/blender/pulls/139821
2025-06-09 12:36:06 +02:00
Aras Pranckevicius
f685f23434 ImBuf: Remove pre-2.80 Texture mipmaps/filters
Removes various image filtering/mipmapping leftovers from
pre-2.80 days.

Code: removes all mipmap handling from ImBuf (which is about half of
ImBuf struct size), removes now unused "sample procedural texture
with mipmaps" code, now-unused FELINE filter, etc. The osatex
parameter to various CPU texture sampling functions is never
actually used, which means none of the mipmap code was ever executing.

User visible part: there were settings on the legacy Texture data
block (as used by Brushes etc.), under Sampling section: "MIP Map",
"Gaussian Filter", "Filter Type", "Eccentricity", "Minimum Size" --
they had no effect anywhere, so they are gone, and what remains is
only "Interpolation" and "Size".

RNA / Python API part: removes the ImageTexture RNA properties
corresponding to the above: filter_type, use_mipmap, use_mipmap_gauss,
filter_lightprobes, filter_eccentricity, use_filter_size_min.

Pull Request: https://projects.blender.org/blender/blender/pulls/139978
2025-06-09 11:35:19 +02:00
Aras Pranckevicius
5ad6d42c83 IO: Remove Collada import/export
Removes Collada import/export (has been deprecated since 4.2).

Pull Request: https://projects.blender.org/blender/blender/pulls/139337
2025-06-06 08:38:57 +02:00
Campbell Barton
6fbef14f4b PyDoc: quiet wanings/prints when building docs 2025-06-05 05:31:51 +00:00
Hans Goudey
77b14f2dcb Cleanup: Grammar: Fallback vs. fall back
The former is a noun or adjective, the latter is a verb.
2025-06-02 17:13:56 -04:00
Campbell Barton
50f3240abd Cleanup: spelling & duplicate terms (check_spelling.py) 2025-05-30 11:03:56 +10:00