lib
Library functions for Silhouette.
 capture_messageboxes(callback) 
 Capture messageboxes and call a callback with them.
This is a workaround for Silhouette not allowing the Python code to suppress messageboxes and supply default answers to them. So instead we capture the messageboxes and respond to them through a rapid QTimer.
Source code in client/ayon_silhouette/api/lib.py
 | 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 |  | 
 collect_animation_defs(create_context, fps=False) 
 Get the basic animation attribute definitions for the publisher.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| create_context | CreateContext | The context of publisher will be used to define the defaults for the attributes to use the current context's entity frame range as default values. | required | 
| step | bool | Whether to include  | required | 
| fps | bool | Whether to include  | False | 
Returns:
| Type | Description | 
|---|---|
| List[NumberDef]: List of number attribute definitions. | 
Source code in client/ayon_silhouette/api/lib.py
 | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |  | 
 copy_session_nodes(source_session, destination_session) 
 Merge all nodes from source session into destination session.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| source_session | Session | The source session to clone nodes from. | required | 
| destination_session | Session | The destination session to merge into. | required | 
Returns:
| Type | Description | 
|---|---|
| List[Node] | List[fx.Node]: The cloned nodes in the destination session. | 
Source code in client/ayon_silhouette/api/lib.py
 | 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 |  | 
 get_connections(node, inputs=True, outputs=True) 
 Return connections from destination ports to their source ports.
Source code in client/ayon_silhouette/api/lib.py
 | 439 440 441 442 443 444 445 446 447 448 449 450 451 452 |  | 
 get_input_port_by_name(node, port_name) 
 Return the input port with the given name.
Source code in client/ayon_silhouette/api/lib.py
 | 455 456 457 458 459 460 |  | 
 get_main_window() 
 Get the main Qt window of the application.
Source code in client/ayon_silhouette/api/lib.py
 | 25 26 27 |  | 
 get_output_port_by_name(node, port_name) 
 Return the output port with the given name.
Source code in client/ayon_silhouette/api/lib.py
 | 463 464 465 466 467 468 469 |  | 
 import_project(path, merge_sessions=True) 
 Import Silhouette project into current project.
Silhouette can't 'import' projects natively, so instead we will use our own logic to load the content from a project file into the currently active project.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| path | str | The project path to import. Since Silhouette projects are folders this should be the path to the project folder. | required | 
| merge_sessions | bool | When enabled, sessions with the same label will be 'merged' by adding all nodes of the imported session to the existing session. | True | 
Source code in client/ayon_silhouette/api/lib.py
 | 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 |  | 
 imprint(node, data, key='AYON') 
 Write data to node as userDefined attributes
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| node | Object | Node | The selection object | required | 
| data | dict | Dictionary of key/value pairs | required | 
Source code in client/ayon_silhouette/api/lib.py
 | 118 119 120 121 122 123 124 125 126 127 128 129 130 |  | 
 iter_children(node, prefix=None) 
 Iterate over all children of a node recursively.
This yields the node together with a label that indicates the full path from the root node passed to the function.
Source code in client/ayon_silhouette/api/lib.py
 | 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 |  | 
 maintained_selection(preserve_active_node=True) 
 Maintain selection during context.
Source code in client/ayon_silhouette/api/lib.py
 | 86 87 88 89 90 91 92 93 94 95 96 97 |  | 
 read(node, key='AYON') 
 Return user-defined attributes from node
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| node | Object | Node | Node or object to redad from. | required | 
| key | str | The key to read from. | 'AYON' | 
Returns:
| Type | Description | 
|---|---|
| Optional[dict] | Optional[dict]: The data stored in the node. | 
Source code in client/ayon_silhouette/api/lib.py
 | 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |  | 
 reset_session_settings(session=None, task_entity=None, project_settings=None) 
 Reset the session settings to the task context defaults.
Source code in client/ayon_silhouette/api/lib.py
 | 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 |  | 
 set_bit_depth_from_settings(session, project_settings) 
 Set the bit depth from project settings.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| session | Session | The Silhouette session. | required | 
| project_settings | dict | Project settings containing bit depth. | required | 
Source code in client/ayon_silhouette/api/lib.py
 | 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 |  | 
 set_frame_range_from_entity(session, task_entity) 
 Set frame range and FPS from task entity attributes.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| session | Session | The Silhouette session. | required | 
| task_entity | dict | Task entity. | required | 
Source code in client/ayon_silhouette/api/lib.py
 | 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 |  | 
 set_new_node_position(node) 
 Position the node near the active node, or the top-right of the scene
Source code in client/ayon_silhouette/api/lib.py
 | 201 202 203 204 205 206 207 208 209 210 211 212 213 |  | 
 set_resolution_from_entity(session, task_entity) 
 Set resolution and pixel aspect from task entity attributes.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| session | Session | The Silhouette session. | required | 
| task_entity | dict | Task entity. | required | 
Source code in client/ayon_silhouette/api/lib.py
 | 216 217 218 219 220 221 222 223 224 225 226 227 228 |  | 
 transfer_connections(source, destination, inputs=True, outputs=True) 
 Transfer connections from one node to another.
Source code in client/ayon_silhouette/api/lib.py
 | 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 |  | 
 undo_chunk(label='') 
 Open undo chunk during context.
In Silhouette, it's often necessary to group operations into an undo chunk to ensure the UI updates correctly on property and value changes.
Note that contextlib.contextmanager can also be used as function decorators.
Source code in client/ayon_silhouette/api/lib.py
 | 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |  | 
 unzip(source, destination) 
 Unzip a zip file to destination.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| source | str | Zip file to extract. | required | 
| destination | str | Destination directory to extract to. | required | 
Source code in client/ayon_silhouette/api/lib.py
 | 426 427 428 429 430 431 432 433 434 435 436 |  | 
 zip_folder(source, destination) 
 Zip a directory and move to destination.
This zips the contents of the source directory into the zip file. The source directory itself is not included in the zip file.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| source | str | Directory to zip and move to destination. | required | 
| destination | str | Destination file path to zip file. | required | 
Source code in client/ayon_silhouette/api/lib.py
 | 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 |  |