api
Public API
Anything that isn't defined here is INTERNAL and unreliable for external use.
BlenderHost
Bases: HostBase
, IWorkfileHost
, IPublishHost
, ILoadHost
Source code in client/ayon_blender/api/pipeline.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
|
get_containers()
List containers from active Blender scene.
Source code in client/ayon_blender/api/pipeline.py
74 75 76 |
|
get_context_data()
Override abstract method from IPublishHost. Get global data related to creation-publishing from workfile.
Returns:
Name | Type | Description |
---|---|---|
dict | dict | Context data stored using 'update_context_data'. |
Source code in client/ayon_blender/api/pipeline.py
137 138 139 140 141 142 143 144 145 146 147 |
|
get_current_workfile()
Override get_current_workfile method from IWorkfileHost. Retrieve currently opened workfile path.
Returns:
Name | Type | Description |
---|---|---|
str | str | Path to currently opened workfile. |
Source code in client/ayon_blender/api/pipeline.py
106 107 108 109 110 111 112 113 |
|
get_workfile_extensions()
Override get_workfile_extensions method from IWorkfileHost. Get workfile possible extensions.
Returns:
Type | Description |
---|---|
List[str] | List[str]: Workfile extensions. |
Source code in client/ayon_blender/api/pipeline.py
78 79 80 81 82 83 84 85 |
|
install()
Override install method from HostBase. Install Blender host functionality.
Source code in client/ayon_blender/api/pipeline.py
69 70 71 72 |
|
open_workfile(filepath)
Override open_workfile method from IWorkfileHost. Open workfile at specified filepath in the host.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath | str | Path to workfile. | required |
Source code in client/ayon_blender/api/pipeline.py
97 98 99 100 101 102 103 104 |
|
save_workfile(dst_path=None)
Override save_workfile method from IWorkfileHost. Save currently opened workfile.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dst_path | str | Where the current scene should be saved. Or use current path if | None |
Source code in client/ayon_blender/api/pipeline.py
87 88 89 90 91 92 93 94 95 |
|
update_context_data(data, changes)
Override abstract method from IPublishHost. Store global context data to workfile.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data | dict | New data as are. | required |
changes | dict | Only data that has been changed. Each value has tuple with '( | required |
Source code in client/ayon_blender/api/pipeline.py
149 150 151 152 153 154 155 156 157 158 |
|
work_root(session)
Override work_root method from IWorkfileHost. Modify workdir per host.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session | dict | Session context data. | required |
Returns:
Name | Type | Description |
---|---|---|
str | str | Path to new workdir. |
Source code in client/ayon_blender/api/pipeline.py
125 126 127 128 129 130 131 132 133 134 135 |
|
workfile_has_unsaved_changes()
Override wokfile_has_unsaved_changes method from IWorkfileHost. Returns True if opened workfile has no unsaved changes.
Returns:
Name | Type | Description |
---|---|---|
bool | bool | True if scene is saved and False if it has unsaved modifications. |
Source code in client/ayon_blender/api/pipeline.py
115 116 117 118 119 120 121 122 123 |
|
containerise(name, namespace, nodes, context, loader=None, suffix='CON')
Bundle nodes
into an assembly and imprint it with metadata
Containerisation enables a tracking of version, author and origin for loaded assets.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | Name of resulting assembly | required |
namespace | str | Namespace under which to host container | required |
nodes | List | Long names of nodes to containerise | required |
context | Dict | Asset information | required |
loader | Optional[str] | Name of loader used to produce this container. | None |
suffix | Optional[str] | Suffix of container, defaults to | 'CON' |
Returns:
Type | Description |
---|---|
Collection | The container assembly |
Source code in client/ayon_blender/api/pipeline.py
499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 |
|
current_file()
Return the path of the open scene file.
Source code in client/ayon_blender/api/workio.py
61 62 63 64 65 66 67 |
|
file_extensions()
Return the supported file extensions for Blender scene files.
Source code in client/ayon_blender/api/workio.py
76 77 78 79 |
|
get_selection(include_collections=False)
Returns a list of selected objects in the current Blender scene.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
include_collections | bool | Whether to include selected | False |
Returns:
Type | Description |
---|---|
List[Object] | List[bpy.types.Object]: A list of selected objects. |
Source code in client/ayon_blender/api/lib.py
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 |
|
has_unsaved_changes()
Does the open scene file have unsaved changes?
Source code in client/ayon_blender/api/workio.py
70 71 72 73 |
|
install()
Install Blender configuration for Avalon.
Source code in client/ayon_blender/api/pipeline.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
|
ls()
List containers from active Blender scene.
This is the host-equivalent of api.ls(), but instead of listing assets on disk, it lists assets already loaded in Blender; once loaded they are called containers.
Source code in client/ayon_blender/api/pipeline.py
613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 |
|
lsattr(attr, value=None)
Return nodes matching attr
and value
Parameters:
Name | Type | Description | Default |
---|---|---|---|
attr | str | Name of Blender property | required |
value | Union[str, int, bool, List, Dict, None] | Value of attribute. If none is provided, return all nodes with this attribute. | None |
Example
lsattr("id", "myId") ... [bpy.data.objects["myNode"] lsattr("id") ... [bpy.data.objects["myNode"], bpy.data.objects["myOtherNode"]]
Returns:
Type | Description |
---|---|
List | list |
Source code in client/ayon_blender/api/lib.py
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
|
lsattrs(attrs)
Return nodes with the given attribute(s).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
attrs | Dict | Name and value pairs of expected matches | required |
Example
lsattrs({"age": 5}) # Return nodes with an
age
of 5
Return nodes with both age
and color
of 5 and blue
lsattrs({"age": 5, "color": "blue"})
Returns a list.
Source code in client/ayon_blender/api/lib.py
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
|
maintained_selection()
Maintain selection during context
Example
with maintained_selection(): ... # Modify selection ... bpy.ops.object.select_all(action='DESELECT')
Selection restored
Source code in client/ayon_blender/api/lib.py
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 |
|
maintained_time()
Maintain current frame during context.
Source code in client/ayon_blender/api/lib.py
369 370 371 372 373 374 375 376 |
|
open_file(filepath)
Open the scene file in Blender.
Source code in client/ayon_blender/api/workio.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
|
publish()
Shorthand to publish from within host.
Source code in client/ayon_blender/api/pipeline.py
658 659 660 661 |
|
read(node)
Return user-defined attributes from node
Source code in client/ayon_blender/api/lib.py
264 265 266 267 268 269 270 271 272 273 274 275 |
|
save_file(filepath, copy=False)
Save the open scene file.
Source code in client/ayon_blender/api/workio.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
|
uninstall()
Uninstall Blender configuration for Avalon.
Source code in client/ayon_blender/api/pipeline.py
188 189 190 191 192 193 194 195 196 197 198 199 |
|
work_root(session)
Return the default root to browse for work files.
Source code in client/ayon_blender/api/workio.py
82 83 84 85 86 87 88 89 |
|