api
Public API
Anything that isn't defined here is INTERNAL and unreliable for external use.
BlenderCreator
Bases: Creator
Base class for Blender Creator plug-ins.
Source code in client/ayon_blender/api/plugin.py
221 222 223 224 225 226 227 228 229 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 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 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 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 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 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 | |
cache_instance_data(shared_data) staticmethod
Cache instances for Creators shared data.
Create blender_cached_instances key when needed in shared data and fill it with all collected instances from the scene under its respective creator identifiers.
If legacy instances are detected in the scene, create blender_cached_legacy_instances key and fill it with all legacy products from this family as a value. # key or value?
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shared_data | Dict[str, Any] | Shared data. | required |
Source code in client/ayon_blender/api/plugin.py
227 228 229 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 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | |
collect_instances()
Override abstract method from BlenderCreator. Collect existing instances related to this creator plugin.
Source code in client/ayon_blender/api/plugin.py
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 | |
create(product_name, instance_data, pre_create_data)
Override abstract method from Creator. Create new instance and store it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
product_name | str | Product name of created instance. | required |
instance_data | dict | Instance base data. | required |
pre_create_data | dict | Data based on pre creation attributes. Those may affect how creator works. | required |
Source code in client/ayon_blender/api/plugin.py
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | |
imprint(node, data)
Imprint data to the instance node.
This can be overridden by a sub-class to store certain data of the instance in a different way, e.g. in a custom property or the 'mute' state of a node.
Source code in client/ayon_blender/api/plugin.py
481 482 483 484 485 486 487 488 489 | |
read(node)
Read data from the instance node.
The data dictionary is the readily stored
Source code in client/ayon_blender/api/plugin.py
491 492 493 494 495 496 497 498 499 500 501 502 | |
set_instance_data(product_name, instance_data)
Fill instance data with required items.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
product_name | str | Product name of created instance. | required |
instance_data | dict | Instance base data. | required |
instance_node | ID | Instance node in blender scene. | required |
Source code in client/ayon_blender/api/plugin.py
434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 | |
update_instances(update_list)
Override abstract method from BlenderCreator. Store changes of existing instances so they can be recollected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
update_list | List[UpdateData] | Changed instances and their changes, as a list of tuples. | required |
Source code in client/ayon_blender/api/plugin.py
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 | |
BlenderHost
Bases: HostBase, IWorkfileHost, IPublishHost, ILoadHost
Source code in client/ayon_blender/api/pipeline.py
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 173 174 175 176 177 178 | |
get_containers()
List containers from active Blender scene.
Source code in client/ayon_blender/api/pipeline.py
94 95 96 | |
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
157 158 159 160 161 162 163 164 165 166 167 | |
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
126 127 128 129 130 131 132 133 | |
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
98 99 100 101 102 103 104 105 | |
install()
Override install method from HostBase. Install Blender host functionality.
Source code in client/ayon_blender/api/pipeline.py
89 90 91 92 | |
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
117 118 119 120 121 122 123 124 | |
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
107 108 109 110 111 112 113 114 115 | |
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
169 170 171 172 173 174 175 176 177 178 | |
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
145 146 147 148 149 150 151 152 153 154 155 | |
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
135 136 137 138 139 140 141 142 143 | |
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
721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 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 | |
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
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 | |
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
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | |
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
837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 | |
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
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | |
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
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | |
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
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 | |
maintained_time()
Maintain current frame during context.
Source code in client/ayon_blender/api/lib.py
482 483 484 485 486 487 488 489 | |
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, *, selected_view_layers=None)
Initialize render setup using render settings from project settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variant_name | str | Render variant name used when generating the output node tree and output paths. | required |
project_settings | Optional[dict] | Project settings dictionary. If | None |
selected_view_layers | Optional[list[str]] | Optional list of Blender view-layer names to limit which render layer nodes are used or created. Use | None |
Returns:
| Type | Description |
|---|---|
CompositorNodeOutputFile | bpy.types.CompositorNodeOutputFile: The compositor file output node created for the render setup. |
Source code in client/ayon_blender/api/render_lib.py
531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 | |
publish()
Shorthand to publish from within host.
Source code in client/ayon_blender/api/pipeline.py
892 893 894 895 | |
read(node)
Return user-defined attributes from node
Source code in client/ayon_blender/api/lib.py
275 276 277 278 279 280 281 282 283 284 285 286 | |
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
216 217 218 219 220 221 222 223 224 225 226 227 228 | |
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 | |