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
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 |
|
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
29 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 |
|
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
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 |
|
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
400 401 402 403 404 405 406 407 408 409 410 411 412 413 |
|
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
416 417 418 419 420 421 |
|
get_main_window()
Get the main Qt window of the application.
Source code in client/ayon_silhouette/api/lib.py
24 25 26 |
|
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
424 425 426 427 428 429 430 |
|
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
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 546 547 548 549 550 551 |
|
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
114 115 116 117 118 119 120 121 122 123 124 125 126 |
|
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
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 |
|
maintained_selection()
Maintain selection during context.
Source code in client/ayon_silhouette/api/lib.py
85 86 87 88 89 90 91 92 93 |
|
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
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
|
reset_session_settings(session=None, task_entity=None)
Reset the session settings to the task context defaults.
Source code in client/ayon_silhouette/api/lib.py
245 246 247 248 249 250 251 252 253 254 255 256 |
|
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
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
|
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
197 198 199 200 201 202 203 204 205 206 207 208 209 |
|
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
212 213 214 215 216 217 218 219 220 221 222 223 224 |
|
transfer_connections(source, destination, inputs=True, outputs=True)
Transfer connections from one node to another.
Source code in client/ayon_silhouette/api/lib.py
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 |
|
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
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
|
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
387 388 389 390 391 392 393 394 395 396 397 |
|
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
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 |
|