1104 Commits

Author SHA1 Message Date
Brecht Van Lommel
a6b293daac Python Module: Bundle VFX library python bindings
When calling bpy.utils.expose_bundled_modules(), these modules are
added to sys.path.

This provides a solution/workaround to two problems:
* Using bpy together with packages like usd-core is problematic. Besides
  crashing due to C++ symbol conflicts, it's just impossible to import
  different versions of the same module, or to have distinct environment
  variables for both. (#127132)
* Blender add-ons using these VFX modules do not currently work with
  the bpy module.

This adds about 15MB to the bpy package.

Pull Request: https://projects.blender.org/blender/blender/pulls/133082
2025-01-17 10:13:31 +01:00
Falk David
6b63ec95d0 Fix: Update type name in sphinx_doc_gen.py
The `Sequence` RNA type has been renamed to `Strip`
in 655a17a6abcf0d949d4932bd4f3349d4e0516229.
2025-01-14 19:13:13 +01:00
nutti
10e3e3b4a0 PyDoc: add bpy_prop_collection_idprop class document
Ref: !132587
2025-01-06 20:29:29 +11:00
nutti
aa81aed109 PyDoc: add 'rtype' field for multiple return values
Ref: !131482
2025-01-06 20:29:29 +11:00
Campbell Barton
4f1817cc18 Cleanup: declare __all__ for Python scripts
Declare all to make public public API's explicit and
help detect unused code.
2025-01-06 16:45:36 +11:00
Campbell Barton
444f1064c9 Cleanup: remove unused functions, imports 2025-01-04 21:09:41 +11:00
Campbell Barton
6216e8574c Cleanup: declare __all__ for doc-generation & icon updating utils 2025-01-04 20:33:53 +11:00
Aaron Carlisle
1bcc01519a Cleanup: Spelling: "Explicitly" 2025-01-03 22:35:05 -05:00
Bastien Montagne
34908de285 Update BPY API 'creation & destruction' section re __del__().
While in theory it would be good to have calls to super classes'
`__del__()` destructors in subclasses, matching the ones to
`__init__()`, several limitations of current CPython implementation do
not make it a practical requirement.

So remove `__del__` from examples, and add a note summarizing the
current problems with using it (aka `tp_finalize` in C++ code).

Also see !132476 for some discussion about that topic.
2025-01-03 12:16:50 +01:00
Campbell Barton
7481355397 Cleanup: scripts, unused variables & re-declaring built-ins 2025-01-02 15:11:15 +11:00
Campbell Barton
d64bd41ee9 Cleanup: wrap long lines 2025-01-02 15:11:14 +11:00
Campbell Barton
54e655f06a PyDoc: correct unbalanced back-tick 2025-01-02 15:03:54 +11:00
nutti
848ec77911 Fix: PyDocs: Title inconsistency on bpy.types.USDHook
Due to 8285d2d, titles "Inherited Properties" and "Inherited Functions" become hidden.
This PR fixes this issue.

Pull Request: https://projects.blender.org/blender/blender/pulls/132481
2025-01-01 07:40:37 +01:00
Brecht Van Lommel
f301952b6a Fix: Missing super().__del__() in Cycles and Hydra render engine
According to the Python API release notes, this is required now along
with super().__init__() which was already done.

Also fixes mistake in example in API docs.

Pull Request: https://projects.blender.org/blender/blender/pulls/132476
2024-12-31 15:18:25 +01:00
Michael Kowalski
9abe161b58 USD: USDHook.py format fix 2024-12-30 10:17:35 -05:00
Michael Kowalski
8285d2d82e USD: update USDHook.py example
Updated the example to include new hook functions
material_import_poll and on_material_import as well
as the new import_texture and export_texture
utilities which were introduced in #131559.

Also reformatted the existing documentation to include
subheaders and internal links, as the previous paragraph
format became difficult to follow.

Pull Request: https://projects.blender.org/blender/blender/pulls/132259
2024-12-30 15:50:08 +01:00
Charles Flèche
0df5d8220b USD: Add new get_prim_map API callable from python on_import hooks
When importing an USD, the Blender object names do not necessarily match
Prim names:

```
#usda 1.0
def Xform "xform1"
{
  def Mesh "MyObject"  # Will be imported as "MyObject"
}
def Xform "xform2"
{
  def Mesh "MyObject"  # Will be imported as "MyObject.001"
}
def Xform "xform2"
{
  def Mesh "MyObject"  # Will be imported as "MyObject.002"
}
```

This makes it difficult in the [USD Import Hooks]
(https://docs.blender.org/api/current/bpy.types.USDHook.html) to link a
Blender object back to its source Prim for additional processing. A
typical use cases for games is to generate UVs, create and apply a
material on the fly when importing a collision shape that does not have
a visual representation (hence no materials) based on some Prim
attributes, but that the artist needs to differenciate in Blender's
viewport.

The Import context exposes a new method `get_prim_map()` that returns a
`dict` of `prim path` / `list of Blender ID`.

For example, given the following USD scene,
```
/
 |--XformThenCube [def Xform]
 |   `--Cube [def Cube]
 |--XformThenXformCube [def Xform]
 |   `--XformIntermediate [def Xform]
 |       `--Cube [def Mesh]
 |--Cube [def Cube]
 `--Material [def Material]
     `--Principled_BSDF [def Shader]
```

the `get_prim_map()` method will return a map as:

```python
@static_method
def on_import(import_context):
  pprint(import_context.get_prim_map())
```

```json
{
  "/Cube": [bpy.data.objects["Cube.002"], bpy.data.meshes["Cube.002"]],
  "/XformThenCube": [bpy.data.objects["XformThenCube"]],
  "/XformThenCube/Cube": [bpy.data.objects["Cube"], bpy.data.meshes["Cube"]],
  "/XformThenXformCube": [bpy.data.objects["XformThenXformCube"]],
  "/XformThenXformCube/XformIntermediate": [bpy.data.objects["XformIntermediate"]],
  "/XformThenXformCube/XformIntermediate/Cube": [bpy.data.objects["Cube.001"], bpy.data.meshes["Cube.001"]],
  "/Material": [bpy.data.materials["Material"]],
}
```

Co-authored-by: Odréanne Breton <odreanne.breton@ubisoft.com>
Co-authored-by: Sttevan Carnali Joga <sttevan.carnali-joga@ubisoft.com>
Co-authored-by: Charles Flèche <charles.fleche@ubisoft.com>
2024-12-11 21:36:09 +01:00
Campbell Barton
a7bc3e3418 Cleanup: quiet Python linter warnings 2024-12-11 11:26:24 +11:00
Aaron Carlisle
d0d936b760 Revert "Docs: Python API: Fix theme dependency"
This reverts commit 4deecd97a9bef68c12ece3fcbd31eadce3008874.
2024-11-28 14:12:06 -05:00
Aaron Carlisle
4deecd97a9 Docs: Python API: Fix theme dependency
The upstream dependency was mistakenly changed in
2ce7e89cb7

PR to fix this here: https://github.com/pradyunsg/furo/pull/853
2024-11-28 12:53:57 -05:00
Aaron Carlisle
7993020085 Docs: Update Sphinx & Website Theme
This now matches the versions used for the user manual.
2024-11-27 22:40:40 -05:00
Campbell Barton
45dfec6c55 Cleanup: trailing space 2024-11-26 12:41:29 +11:00
Bastien Montagne
fcc1c89923 API Doc: improvements/fixes regarding new requirements for __init__/__del__ 2024-11-19 15:37:04 +01:00
Bastien Montagne
b1d044bfb8 Merge branch 'blender-v4.3-release' 2024-11-11 16:17:04 +01:00
Bastien Montagne
69a7948575 Doc: Py API: Add more info about UNDO operator option.
Essentially, any operator modifying Blender data should enable this
`UNDO` option, else bad things (corruption, crashes...) are likely to
happen.

* Added a new Operator example to explain this topic.
* Updated some existing Operator examples that were not correct anymore.
* Added a new small section in the gotchas page linking to it.
* Added also short reminder about this in the `UNDO` 'tooltip'
  description itself.

Related to #77557.
2024-11-11 16:13:37 +01:00
Bastien Montagne
c18ec7e2ad Fix wrong link in Py API docs after recent refactor. 2024-11-10 18:48:56 +01:00
Bastien Montagne
d5c50fc366 API docs: Split 'Gotchas' page, add some info about python instances and subclasses.
This PR:
* Splits the `Gotchas` page into several sub-sections. This was getting too big and hard to navigate.
* Adds some information regarding Python instances life-time of objects wrapping Blender internal data.
* Adds some information about usage of constructors and destructors for sub-classes of Blender-defined types.

Pull Request: https://projects.blender.org/blender/blender/pulls/129814
2024-11-10 18:40:14 +01:00
Bastien Montagne
2910f6dce9 Cleanup: API docs generator: Remove references to removed GP(v2) types. 2024-11-10 18:27:10 +01:00
Bastien Montagne
246b43e136 Merge branch 'blender-v4.3-release' 2024-11-10 18:24:49 +01:00
nutti
1c8669f8c9 Fix: sphinx_doc_gen.py syntax error while generating PyDoc
Ref !130085
2024-11-10 23:35:45 +11:00
Campbell Barton
a3773c827d Merge branch 'blender-v4.3-release' 2024-11-09 13:20:38 +11:00
Campbell Barton
f026c3a80f Merge branch 'blender-v4.3-release' 2024-11-09 13:20:36 +11:00
Campbell Barton
63c56a5d67 PyDoc: show keyword-only signifier for all RNA functions 2024-11-09 13:19:26 +11:00
Campbell Barton
56cea4a36b Fix PyDoc: Invalid signature for functions without arguments
Ref: !130031
2024-11-09 13:17:43 +11:00
Campbell Barton
96ac7b7ff3 Merge branch 'blender-v4.3-release' 2024-11-06 10:51:53 +11:00
Campbell Barton
6ccbafc5dc Cleanup: spelling in comments 2024-11-06 10:49:51 +11:00
Campbell Barton
d40a0fc5c3 Merge branch 'blender-v4.3-release' 2024-11-03 22:04:51 +11:00
Campbell Barton
ba3c53f200 Merge branch 'blender-v4.3-release' 2024-11-03 22:04:48 +11:00
Campbell Barton
d920ef5425 Merge branch 'blender-v4.3-release' 2024-11-03 22:04:44 +11:00
Campbell Barton
e97e2e4b6d Merge branch 'blender-v4.3-release' 2024-11-03 22:04:42 +11:00
Campbell Barton
470173bbc4 PyDoc: use keyword only specifier for bpy.props & bpy.ops 2024-11-03 21:50:33 +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
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
b3919319fb Merge branch 'blender-v4.3-release' 2024-11-02 15:44:18 +11:00
Campbell Barton
c056d03f93 Cleanup: move binary operator to line end in Python scripts 2024-11-02 15:43:26 +11:00
Campbell Barton
f1eb98c427 Merge branch 'blender-v4.3-release' 2024-10-28 09:38:05 +11:00
Campbell Barton
59c52ef2cf Cleanup: remove unused import in CLI example 2024-10-28 09:36:28 +11:00