Commit Graph

2862 Commits

Author SHA1 Message Date
Lukas Tönne
400c738db9 GPv3: Import and export for SVG and PDF
Implements the SVG import/export and PDF export operators for GPv3.

Pull Request: https://projects.blender.org/blender/blender/pulls/123996
2024-08-20 11:41:37 +02:00
Iliya Katueshenock
1b67be14c6 Cleanup: BKE: Nodes: Functions renaming
Use snake style naming for all the kernel nodes functions.
Omit kernel prefix in the names since of the using namespace.
Use full forms of the terms
('iter' -> 'iterator', 'ntree' -> 'node_tree', 'rem' -> 'remove', ...).

Pull Request: https://projects.blender.org/blender/blender/pulls/126416
2024-08-19 20:27:37 +02:00
Campbell Barton
976062c771 Cleanup: use prefix comments before struct members 2024-08-19 11:37:20 +10:00
Campbell Barton
b5e0b59736 Cleanup: remove space around identifiers in C-style comments 2024-08-15 20:46:00 +10:00
Jacques Lucke
5861b078f7 Core: rename ID.flag and ID.tag values
Previously, values for `ID.flag` and `ID.tag` used the prefixes `LIB_` and
`LIB_TAG` respectively. This was somewhat confusing because it's not really
related to libraries in general. This patch changes the prefix to `ID_FLAG_` and
`ID_TAG_`. This makes it more obvious what they correspond to, simplifying code.

Pull Request: https://projects.blender.org/blender/blender/pulls/125811
2024-08-07 12:12:17 +02:00
nutti
1c3a2d1f5f Fix: temp_override doc not to take the positional arguments
Add positional argument to `temp_override` pyapi docs

Pull Request: https://projects.blender.org/blender/blender/pulls/125132
2024-08-05 13:28:25 +02:00
Campbell Barton
14b03fca3c PyAPI: add bpy.app.python_args, use when calling Python from Blender
Expose arguments to use when creating a Python sub-process.

Python could fail to start when loaded in a customized environment,
with PYTHONPATH set for e.g. Blender ignores these and loads but a
Python sub-process attempts to use these environment variables which
may point to incompatible Python versions.

Resolve the root cause of #124731.
2024-07-31 11:59:23 +10:00
Falk David
cd577f02b9 Python: Trigger property update in foreach_get/set
Calling `foreach_get/set` on a collection property did not trigger
a property update. In the attribute API, this lead to missing
updates after e.g. setting the values of an attribute.

This adds a call to `RNA_property_update` for the getter/setter
bpy rna function and adds a property update callback to all the
different attribute collection properties.

Pull Request: https://projects.blender.org/blender/blender/pulls/125518
2024-07-29 11:14:20 +02:00
Campbell Barton
111a40239a Cleanup: match argument names for function & declarations
Match function and declaration names, picking names based on
consistency with related code & clarity.

Also changes for old conventions, missed in previous cleanups:

- name -> filepath
- tname -> newname
- maxlen -> maxncpy
2024-07-27 13:32:51 +10:00
Christoph Lendenfeld
ebd123c90b Refactor: delete_keyframe function arguments
No functional changes intended.

This simplifies the arguments for the `delete_keyframe` function.
The `bAction *` was always a `nullptr` so I just removed it.
The rna path char array and the array index were merged into the `RNAPath` struct.

Pull Request: https://projects.blender.org/blender/blender/pulls/125479
2024-07-26 13:29:25 +02:00
Campbell Barton
e2bc41598d Fix drivers showing "Python restricted for security" when they weren't
Regression from [0], drivers were tagged as being disabled with a flag
that was never cleared. Causing the label to be displayed for files
where the expressions were enabled and in use.

Resolve by clearing this flag on file load and when re-compiling
expressions - since an expressions block flag may be cleared if it
becomes a simple expression.

[0]: 1a8053939b
2024-07-22 10:39:50 +10:00
Andrej730
627bd7e51c Fix: API docs: bpy.app.timers function argument types
Fixed the "function" argument types of `is_registered` and `unregistered`
to be consistent with the correct typing from `bpy.app.timers.register`

Pull Request: https://projects.blender.org/blender/blender/pulls/125052
2024-07-20 14:52:37 +02:00
Bastien Montagne
c607ead4b7 Refactor: Makesrna: move generated code further in C++.
This commit moves generated `RNA_blender.h`, `RNA_prototype.h` and
`RNA_blender_cpp.h` headers to become C++ header files.

It also removes the now useless `RNA_EXTERN_C` defines, and just
directly use the `extern` keyword. We do not need anymore `extern "C"`
declarations here.

Pull Request: https://projects.blender.org/blender/blender/pulls/124469
2024-07-15 16:39:45 +02:00
Campbell Barton
8fcd1812b4 Merge branch 'blender-v4.2-release' 2024-07-15 11:07:54 +10:00
Nathan Burnham
988bf2b88f Fix incorrect exception message on collection key type error
String keys aren't supported.

Ref: !123577
2024-07-15 11:07:27 +10:00
Campbell Barton
8fdb190278 Cleanup: typos in comments (duplicate words) 2024-07-14 18:55:43 +10:00
Christoph Lendenfeld
1a8053939b Fix #106372: Wrong message in driver for disabled execution
When using a python expression, its execution is disabled by
default unless specified differently in the user preferences.
Previously this only produced the error
"Error: Invalid Python expression". However that isn't really the correct error.

Now the error reads "Python restricted for security".

I've added a new flag to the driver `DRIVER_FLAG_PYTHON_BLOCKED` that is set
if the driver can't run because python is blocked

Co-authored by Phillip Oeser

Pull Request: https://projects.blender.org/blender/blender/pulls/124587
2024-07-12 12:37:15 +02:00
Bastien Montagne
57e9abb564 Cleanup: Remove left-over call to BKE_blendfile_write_partial_end.
BPY `library.write` has been moved to new PartialWriteContext code a few
weeks ago, removing this call to `BKE_blendfile_write_partial_end` was
somehow missed then.
2024-07-09 15:27:12 +02:00
Campbell Barton
bf68ce401d Merge branch 'blender-v4.2-release' 2024-07-09 13:47:12 +10:00
nutti
5523662414 Docs: add default parameters to Context.temp_override
Ref: !124348
2024-07-09 13:44:09 +10:00
Campbell Barton
48383cf20e Cleanup: avoid shadowing, redundant assignment & minor changes
Quiet cppecheck warnings, use const pointers, ELEM(..) macro,
replace NULL -> nullptr, unsigned int -> uint.
2024-07-07 00:18:00 +10:00
Bastien Montagne
96198e88e1 Refactor: BPY: make 'libraries.write' code use the new PartialWriteContext class.
This makes code behind the `bpy.data.libraries.write()` API use the new
`PartialWriteContext` class, instead of the old
`BKE_blendfile_write_partial` API.

NOTE: This also means that the `blendfile_io` tests using this python
API are now using the new class.

No behavioral changes are expected here.

Pull Request: https://projects.blender.org/blender/blender/pulls/122118
2024-07-01 15:28:15 +02:00
Nathan Vegdahl
38f889d07a Fix #123538: Crossfade sounds sets volume to 0
The issue was that the Python keyframing code was already resolving the
RNA path fully to the owning ID, but then erroneously passing the
non-ID RNA pointer (in this case the sound sequence pointer) to the
keyframing code with that fully resolved path.

Notably, it wasn't just the VSE keyframing that was broken: keying any
non-ID structs via the Python API was broken. A good example is pose
bones: the Python keyframing code was resolving e.g. "location" on
the bone to "pose.bones["Bone"].location", but then passing that
path along with the pose bone struct to the keyframing code.  Since
that fully resolved path of course doesn't exist on the bone itself,
keying would fail.

This fixes it by simply passing the owning ID's RNA pointer instead,
which it should have been doing in the first place.

Pull Request: https://projects.blender.org/blender/blender/pulls/123719
2024-06-25 14:16:55 +02:00
Lukas Stockner
25d4d645cd UI: Add Color Temperature unit
The current temperature unit adjusts to Celsius or Fahrenheit based on
unit system, but specifically for color temperatures the convention is
to display them in Kelvin, and it'd be strange to e.g. see 11240°F when
opening the white balance panel.

Therefore, this adds a dedicated Color Temperature unit, and uses it
for the two existing blackbody temperature inputs in shader nodes.

Pull Request: https://projects.blender.org/blender/blender/pulls/123337
2024-06-17 23:50:05 +02:00
Bastien Montagne
286319bbe3 Merge branch 'blender-v4.2-release' 2024-06-11 19:56:13 +02:00
Nathan Burnham
6ea1d2131d Fix: PyAPI Doc: unexpected indentation error
7413031dd6 introduced an error and related warning when generating Py API docs:

```
/blender/doc/python_api/sphinx-in/bpy.app.translations.rst:132: ERROR: Unexpected indentation.
...
/blender/doc/python_api/sphinx-in/bpy.app.translations.rst:132: WARNING: Lexing literal_block 'See :func:`pgettext` notes.' as "python3" resulted in an error at token: '`'. Retrying in relaxed mode.
```

Pull Request: https://projects.blender.org/blender/blender/pulls/123097
2024-06-11 19:55:24 +02:00
Nathan Vegdahl
1a4f084806 Refactor: combine insert_keyframe() and insert_key_rna() into a single function
The goal of this PR is to merge `insert_keyframe()` and `insert_key_rna()` into
a single function, `insert_keyframes()`, that fully accommodates the
functionality of both.  This results in a bit of a mega function, which isn't
great, but it centralizes a lot of otherwise redundant keyframing code so it
only needs to be changed in one place in the future.

Future PRs can work to reduce the "mega" aspect of this function, stripping it
down to its core functionality and eliminating left over incidental redundancy
(e.g. passing both `scene_frame` and `anim_eval_context`).

As a wonderful side effect, this PR also makes layered action keyframing work in
most of the remaining places left over from #121661, such as buttons, the
dopesheet, the graph editor, etc.

Pull Request: https://projects.blender.org/blender/blender/pulls/122053
2024-06-11 16:42:55 +02:00
Damien Picard
203600d441 Add msgctxt arg to docs 2024-06-11 15:09:09 +02:00
Damien Picard
7413031dd6 I18n: Add Python function to extract messages without translating
The new `pgettext_n` function (typically imported as `n_`) can be used
when there is a need to extract messages, without translating them. It
is essentially a no-op equivalent to the C++ version `N_`.
2024-06-11 15:09:09 +02:00
Sybren A. Stüvel
83311ef96d Fix #122777: The keyframe_insert method throws python exceptions
Just for the `pyrna_struct_keyframe_insert()` function, reduce the
reporting level of keyframe insertion failures from `RPT_ERROR` to
`RPT_WARNING`. This prevents the conversion of these reports to a Python
exception.

`CombinedKeyingResult::generate_reports()` now accepts an option
argument `report_level`, so that the caller is in control over the type
of reports it generates.

Previously only errors were converted to exceptions; warnings were
implicitly cleared and never displayed. To avoid these 'keyframe
insertion failure' reports from becoming invisible, the
`pyrna_struct_keyframe_insert()` function now sends any warnings to
stdout (unless there were errors, in which case the old
error-to-exception behaviour is still there).

Pull Request: https://projects.blender.org/blender/blender/pulls/122827
2024-06-11 11:11:16 +02:00
Campbell Barton
dc0e559cbb Extensions: remove intermediate operators for upgrade and sync
The buttons to upgrade or sync extensions called extension
operators via bpy.app.handlers, requiring awkward glue-code
which didn't show error reports in to the user.

Remove these operators and call the upgrade & sync operators directly.
2024-06-07 16:33:03 +10:00
Campbell Barton
dc9430c480 Extensions: support system repositories & BLENDER_SYSTEM_EXTENSIONS
Support for "System" extensions as an alternative to the current
"User" extensions repository.

The purpose of this change is to support bundling extensions for
offline work or in environments where users setting up thier own
extensions isn't desirable, see #122512.

Details:

The default "System" repository on Linux will for example use:
- `/usr/share/blender/4.2/extensions/{system}` For system installs.
- `./4.2/extensions/{system}` For portable installs.

- Blender's default startup now has a "System" repository
  which users or administrators may populate.

- Repositories can select between User/System paths,
  setting a custom path overrides overrides this setting.

- Add "BLENDER_SYSTEM_EXTENSIONS" (matching "BLENDER_LOCAL_EXTENSIONS").

Ref !122832
2024-06-07 11:36:20 +10:00
Campbell Barton
7f7648c6ed Cleanup: spelling in code comments & minor edits
- Use uppercase NOTE: tags.
- Correct bNote -> bNode.
- Use colon after parameters.
- Use doxy-style doc-strings.
2024-06-06 09:55:13 +10:00
Nathan Burnham
1c92d26bfc PyAPI Doc: fix typos causing untyped parameters
The type for `bpy_struct.keyframe_insert()`'s `options` parameter was
instead applied to a non-existent `flag` parameter.

The description and type for `mathutils.Vector.Repeat()`'s `vector`
parameter was instead applied to a non-existent `tuple` parameter.

Also fix a reference to `BMElemeSeq` instead of `BMElemSeq`.

Ref: !122734
2024-06-05 16:25:05 +10:00
Campbell Barton
d002703484 PyAPI: fixes for defining operator macros
- Support passing in operator ID's using Python dot syntax.
- Support define operators that haven't yet been registered
  matching Blender's own behavior.

Also add doc-string for bpy.types.Macro.define.
2024-06-01 16:17:02 +10:00
Philipp Oeser
fcc481a407 Render: include info string for "render_stats" handler
The "render_stats" handler now includes the message line that was
written to stdout as the first arg (using `BKE_callback_exec_string`
instead of just `BKE_callback_exec_null`).

This can be useful to track render progress (and people were relying on
parsing stdout in the past).

Was a request in chat.

This also corrects possible output from the callback being written in
between message parts in `do_write_image_or_movie` (which was probably a
mistake in 93d5e106aa).

Pull Request: https://projects.blender.org/blender/blender/pulls/119789
2024-05-28 17:07:27 +02:00
Julian Eisel
2fbf206491 UI: Allow passing named strings via context
Sometimes it is necessary to pass additional data through generic UI entities,
to specific implementations. For example to pass additional options to panel
polling & drawing when instantiating a panel through its panel type. Or storing
additional data in a button, without hardcoding it in the button struct/class.

Passing data via context is a simple solution to this, however so far this only
works using hardcoded context queries or RNA pointers. For passing arbitrary
strings we've used workarounds like creating an RNA type to wrap it already.
For example `RNA_AssetCatalogPath`, which is used to dynamically populate menu
items based on an asset catalog path, via a generic menu type.
type instantiation. This makes it possible to invoke specific asset shelves as
popover panels.

Idea is simply to let `bContextStore` entries hold copies of the string (as
`std::string`), avoiding lifetime issues. Context APIs are extended to support
setting/querying strings via a context member name.

Pull Request: https://projects.blender.org/blender/blender/pulls/122113
2024-05-27 18:46:19 +02:00
Campbell Barton
4f73df2b7b Extensions: enable extensions.blender.org, adjust welcome screen
Splash screen notification text:

- When starting in "Offline mode" with repositories with installed
  packages enabled, the text is clickable unless launched with
  `--offline-mode`, the tooltip notes that the command line setting
  can't be changed at run-time.
- Don's show anything if there are not extensions installed.

Preferences:

- Don't show the welcome message on preferences if:
  - Blender is online.
  - The message was dismissed.
  - There are no enabled remote repositories.

- The option to enable extensions.blender.org has been replaced with
  a button that switches to the "System" tab where Online Access
  can be enabled.

Also expose bpy.app.online_access_override needed for the UI to check
if online access was disabled using command line arguments.
2024-05-24 16:51:36 +10:00
Campbell Barton
57c023d580 Preference: add option allow internet access
Add a preference to "Work Offline" system preference as well as command
line options `--offline-mode` & `--online-mode`
(which overrides the preference).
This option is displayed in the initial setup screen too.

This is currently respected by:

- Check for updates on startup
- Disables running an update when enabling extensions.

When Blender is launched with `--offline-mode` the option cannot be
enabled in the preferences. This is intended for environments
where internet access is intentionally disallowed.

Background: with Blender supporting access to online-repositories
as well as 3rd party extensions themselves potentially accessing the
internet. This setting provides a way for users to disable online
functionality.

This prevents error messages when online access fails in environments
without internet access as well as the ability for users who prefer
Blender doesn't access the internet to have one place to turn this off.

While it does not enforce limitations on add-ons, 3rd party scripts
are expected to respect this setting using `bpy.app.internet_offline`.

The details for this will be handled along with other policies scripts
are expected to follow.

Ref !121994
2024-05-23 13:50:06 +10:00
Iliya Katueshenock
75d17b1db5 Cleanup: Move BKE_node to namespace
Move all header file into namespace.
Unnecessary namespaces was removed from implementations file.
Part of forward declarations in header was moved in the top part
of file just to do not have a lot of separate namespaces.

Pull Request: https://projects.blender.org/blender/blender/pulls/121637
2024-05-13 16:07:12 +02:00
Bastien Montagne
a6153bb7d5 Fix (unreported) crash when linking data from other endianness files.
Handling of the blendfile handle freeing when linking data from a
blendfile requiring endianness conversion was totally broken, leading
to double-freeing attempts.

Guess that the fact that this was never reported shows how rare
'big-endian' blendfiles are nowadays... But we still have a few in our
test repo.
2024-05-10 16:00:30 +02:00
Sybren A. Stüvel
45bf2eae98 Refactor: Anim: simplify ANIM_remove_driver()
Simplify `ANIM_remove_driver()` by removing unused parameters and handling
simple cases first.

No functional changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/121655
2024-05-10 15:43:31 +02:00
Ahmed Essam
0ca1386426 Fix assert in debug mode when built as Python module
Ref: !121500
2024-05-09 09:51:11 +10:00
Campbell Barton
41efa30a75 Fix failure to catch errors parsing arguments to Context.temp_override
Resolve unhandled exception when invalid types for StructRNA arguments
were passed to temp_override(..).
2024-05-08 23:37:22 +10:00
Campbell Barton
c34a1b5c47 Cleanup: use return instead of an argument for PyC_MainModule_Backup 2024-05-04 16:42:08 +10:00
Campbell Barton
cd5dd6e454 Fix #115648: Crash on startup with an incompatible PYTHONPATH
Regression in [0]. PyPreConfig.use_environment was internalized to 0
but PyConfig.use_environment wasn't.

Thanks to @unwave for finding the root cause.

[0]: cafd6b519c
2024-05-03 15:48:35 +10:00
Jacques Lucke
71ba360ddc Cleanup: use Map for operator types
This simplifies the code, makes it more type safe and also makes it
easier to use the construct-on-first-use-idiom.

Pull Request: https://projects.blender.org/blender/blender/pulls/121170
2024-04-27 21:44:55 +02:00
Campbell Barton
95315e34bf PyAPI: add private API to access WM capabilities
Add _bpy._wm_capabilities(), needed for preferences code to check if
WM functionality is supported. This could be made into a public
function, see code comments for details.
2024-04-26 21:26:49 +10:00
Campbell Barton
91cf938e40 Fix #120859: Script errors longer jump to the line in the text-editor
Since upgrading to Python 3.11, errors (other than syntax errors)
no longer jumped to the location of the error as they used to.

This was caused by the line number being unset, relying on the
attribute access to return the actual value.

Resolve by using attribute access when the struct member can't be used.
2024-04-23 18:18:49 +10:00
Christoph Lendenfeld
c30647a6fc Refactor: remove ReportList argument from insert_key
The insert key function in `animrig/keyframing.cc` took a `ReportList`
argument which it used to print messages in case of failures.

Instead this now returns a `CombinedKeyingResult` and the caller is
responsible for creating reports out of that.

To make that simpler the `ID` argument has been changed from a pointer to a reference.
The calling functions now make sure that it's not a `nullptr`.

This has the effect that there will be less messages printed in the Info panel when e.g. inserting keys with a keyingset.
This still doesn't make an error message pop up though.

Related to #119776

Pull Request: https://projects.blender.org/blender/blender/pulls/120784
2024-04-23 10:10:23 +02:00