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
 | 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 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |  | 
 get_containers() 
 List containers from active Blender scene.
Source code in client/ayon_blender/api/pipeline.py
 | 88 89 90 |  | 
 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
 | 151 152 153 154 155 156 157 158 159 160 161 |  | 
 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
 | 120 121 122 123 124 125 126 127 |  | 
 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
 | 92 93 94 95 96 97 98 99 |  | 
 install() 
 Override install method from HostBase. Install Blender host functionality.
Source code in client/ayon_blender/api/pipeline.py
 | 83 84 85 86 |  | 
 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
 | 111 112 113 114 115 116 117 118 |  | 
 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
 | 101 102 103 104 105 106 107 108 109 |  | 
 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
 | 163 164 165 166 167 168 169 170 171 172 |  | 
 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
 | 139 140 141 142 143 144 145 146 147 148 149 |  | 
 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
 | 129 130 131 132 133 134 135 136 137 |  | 
 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
 | 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 656 657 658 659 660 661 662 663 664 665 666 667 668 |  | 
 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
 | 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 |  | 
 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 AYON.
Source code in client/ayon_blender/api/pipeline.py
 | 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |  | 
 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
 | 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 |  | 
 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
 | 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |  | 
 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
ageof 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
 | 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 262 263 264 265 266 |  | 
 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
 | 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 367 368 369 370 371 |  | 
 maintained_time() 
 Maintain current frame during context.
Source code in client/ayon_blender/api/lib.py
 | 374 375 376 377 378 379 380 381 |  | 
 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 |  | 
 prepare_rendering(variant_name, project_settings=None) 
 Initialize render setup using render settings from project settings.
Source code in client/ayon_blender/api/render_lib.py
 | 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 |  | 
 publish() 
 Shorthand to publish from within host.
Source code in client/ayon_blender/api/pipeline.py
 | 789 790 791 792 |  | 
 read(node) 
 Return user-defined attributes from node
Source code in client/ayon_blender/api/lib.py
 | 269 270 271 272 273 274 275 276 277 278 279 280 |  | 
 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 AYON.
Source code in client/ayon_blender/api/pipeline.py
 | 202 203 204 205 206 207 208 209 210 211 212 213 |  | 
 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 |  |