Project class¶
Project class.
Project(project_id: str)
¶
Bases: pytvpaint.utils.Refreshable
, pytvpaint.utils.Renderable
A TVPaint project is the highest object that contains everything in the data hierarchy.
It looks like this: Project -> Scene -> Clip -> Layer -> LayerInstance
Source code in pytvpaint/project.py
32 33 34 35 36 |
|
id: str
property
¶
The project id.
Note
the id is persistent on project load/close.
position: int
property
¶
The project's position in the project tabs.
Raises:
Type | Description |
---|---|
ValueError
|
if project cannot be found in open projects |
Note
the indices go from right to left in the UI
is_closed: bool
property
¶
Returns True
if the project is closed.
exists: bool
property
¶
Checks if the project exists on disk.
is_current: bool
property
¶
Returns True
if the project is the current selected one in the UI.
name: str
property
¶
The name of the project which is the filename without the extension.
width: int
property
¶
The width of the canvas.
height: int
property
¶
The height of the canvas.
fps: float
property
¶
The project's framerate.
playback_fps: float
property
¶
The project's playback framerate.
field_order: george.FieldOrder
property
¶
The field order.
start_frame: int
property
writable
¶
The project's start frame.
end_frame: int
property
¶
The project's end frame, meaning the last frame of the last clip in the project's timeline.
current_frame: int
property
writable
¶
Get the current frame relative to the timeline.
background_mode: george.BackgroundMode
property
writable
¶
Get/Set the background mode.
background_colors: tuple[george.RGBColor, george.RGBColor] | george.RGBColor | None
property
writable
¶
header_info: str
property
writable
¶
The project's header info.
author: str
property
writable
¶
The project's author info.
notes: str
property
writable
¶
The project's notes text.
current_scene: Scene
property
¶
Get the current scene of the project.
Raises:
Type | Description |
---|---|
ValueError
|
if scene cannot be found in project |
scenes: Iterator[Scene]
property
¶
Yields the project's scenes.
current_clip: Clip
property
¶
Returns the project's current clip.
clips: Iterator[Clip]
property
¶
Iterates over all the clips in the project's scenes.
clip_names: Iterator[str]
property
¶
Optimized way to get the clip names. Useful for get_unique_name
.
sounds: Iterator[ProjectSound]
property
¶
Iterator over the project sounds.
mark_in: int | None
property
writable
¶
Get the project mark in or None if no mark in set.
mark_out: int | None
property
writable
¶
Get the project mark out or None if no mark out set.
refresh() -> None
¶
Refreshed the project data.
Raises:
Type | Description |
---|---|
ValueError
|
if project has been closed |
Source code in pytvpaint/project.py
48 49 50 51 52 53 54 55 56 57 58 59 60 |
|
make_current() -> None
¶
Make the project the current one.
Source code in pytvpaint/project.py
107 108 109 110 111 |
|
path() -> Path
¶
The project path on disk.
Source code in pytvpaint/project.py
113 114 115 116 |
|
resize(width: int, height: int, overwrite: bool = False, resize_opt: george.ResizeOption | None = None) -> Project
¶
Resize the current project and returns a new one.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
width |
int
|
the new width |
required |
height |
int
|
the new height |
required |
overwrite |
bool
|
overwrite the original project, default is to create a new project |
False
|
resize_opt |
pytvpaint.george.ResizeOption | None
|
how to resize the project |
None
|
Returns:
Type | Description |
---|---|
pytvpaint.project.Project
|
the newly resized project |
Source code in pytvpaint/project.py
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 |
|
set_fps(fps: float, time_stretch: bool = False, preview: bool = False) -> None
¶
Set the project's framerate.
Source code in pytvpaint/project.py
188 189 190 191 192 193 194 195 196 |
|
pixel_aspect_ratio() -> float
¶
The project's pixel aspect ratio.
Source code in pytvpaint/project.py
203 204 205 206 207 |
|
clear_background() -> None
¶
Clear the background color and set it to None.
Source code in pytvpaint/project.py
278 279 280 281 282 283 284 285 |
|
get_project(by_id: str | None = None, by_name: str | None = None) -> Project | None
classmethod
¶
Find a project by id or by name.
Source code in pytvpaint/project.py
314 315 316 317 318 319 320 321 322 323 324 325 |
|
current_scene_ids() -> Iterator[int]
staticmethod
¶
Yields the current project's scene ids.
Source code in pytvpaint/project.py
327 328 329 330 |
|
get_scene(by_id: int | None = None, by_name: str | None = None) -> Scene | None
¶
Find a scene in the project by id or name.
Source code in pytvpaint/project.py
353 354 355 356 357 358 359 360 361 362 363 |
|
add_scene() -> Scene
¶
Add a new scene in the project.
Source code in pytvpaint/project.py
365 366 367 368 369 370 |
|
get_clip(by_id: int | None = None, by_name: str | None = None, scene_id: int | None = None) -> Clip | None
¶
Find a clip by id, name or scene_id.
Source code in pytvpaint/project.py
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 |
|
add_clip(clip_name: str, scene: Scene | None = None) -> Clip
¶
Add a new clip in the given scene or the current one if no scene provided.
Source code in pytvpaint/project.py
415 416 417 418 |
|
add_sound(sound_path: Path | str) -> ProjectSound
¶
Add a new sound clip to the project.
Source code in pytvpaint/project.py
430 431 432 |
|
render(output_path: Path | str | FileSequence, start: int | None = None, end: int | None = None, use_camera: bool = False, alpha_mode: george.AlphaSaveMode = george.AlphaSaveMode.PREMULTIPLY, background_mode: george.BackgroundMode | None = None, format_opts: list[str] | None = None) -> None
¶
Render the project to a single frame or frame sequence or movie.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
output_path |
pathlib.Path | str | fileseq.filesequence.FileSequence
|
a single file or file sequence pattern |
required |
start |
int | None
|
the start frame to render or the mark in or the project's start frame if None. Defaults to None. |
None
|
end |
int | None
|
the end frame to render or the mark out or the project's end frame if None. Defaults to None. |
None
|
use_camera |
bool
|
use the camera for rendering, otherwise render the whole canvas. Defaults to False. |
False
|
alpha_mode |
pytvpaint.george.AlphaSaveMode
|
the alpha mode for rendering. Defaults to george.AlphaSaveMode.PREMULTIPLY. |
pytvpaint.george.AlphaSaveMode.PREMULTIPLY
|
background_mode |
pytvpaint.george.BackgroundMode | None
|
the background mode for rendering. Defaults to george.BackgroundMode.NONE. |
None
|
format_opts |
list[str] | None
|
custom format options. Defaults to None. |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
if requested range (start-end) not in project range/bounds |
ValueError
|
if output is a movie, and it's duration is equal to 1 frame |
FileNotFoundError
|
if the render failed and no files were found on disk or missing frames |
Note
This functions uses the project's timeline as a basis for the range (start-end). This timeline includes all
the project's clips and is different from a clip range. For more details on the differences in frame ranges
and the timeline in TVPaint, please check the Usage/Rendering
section of the documentation.
Warning
Even tough pytvpaint does a pretty good job of correcting the frame ranges for rendering, we're still encountering some weird edge cases where TVPaint will consider the range invalid for seemingly no reason.
Source code in pytvpaint/project.py
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 506 |
|
render_clips(clips: list[Clip], output_path: Path | str | FileSequence, use_camera: bool = False, alpha_mode: george.AlphaSaveMode = george.AlphaSaveMode.PREMULTIPLY, background_mode: george.BackgroundMode | None = None, format_opts: list[str] | None = None) -> None
¶
Render sequential clips as a single output.
Source code in pytvpaint/project.py
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 |
|
current_project_id() -> str
staticmethod
¶
Returns the current project id.
Source code in pytvpaint/project.py
532 533 534 535 |
|
current_project() -> Project
staticmethod
¶
Returns the current project.
Source code in pytvpaint/project.py
537 538 539 540 |
|
open_projects_ids() -> Iterator[str]
staticmethod
¶
Yields the ids of the currently open projects.
Source code in pytvpaint/project.py
542 543 544 545 |
|
open_projects() -> Iterator[Project]
classmethod
¶
Iterator over the currently open projects.
Source code in pytvpaint/project.py
547 548 549 550 551 |
|
new(project_path: Path | str, width: int = 1920, height: int = 1080, pixel_aspect_ratio: float = 1.0, frame_rate: float = 24.0, field_order: george.FieldOrder = george.FieldOrder.NONE, start_frame: int = 1) -> Project
classmethod
¶
Create a new project.
Source code in pytvpaint/project.py
607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 |
|
new_from_camera(export_path: Path | str | None = None) -> Project
¶
Create a new cropped project from the camera view.
Source code in pytvpaint/project.py
630 631 632 633 634 635 636 637 638 639 640 641 |
|
duplicate() -> Project
¶
Duplicate the project and return the new one.
Source code in pytvpaint/project.py
643 644 645 646 647 648 649 |
|
close() -> None
¶
Closes the project.
Source code in pytvpaint/project.py
651 652 653 654 |
|
close_all(close_tvp: bool = False) -> None
classmethod
¶
Closes all open projects.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
close_tvp |
bool
|
close the TVPaint instance as well |
False
|
Source code in pytvpaint/project.py
656 657 658 659 660 661 662 663 664 665 666 667 |
|
load(project_path: Path | str, silent: bool = True) -> Project
classmethod
¶
Load an existing .tvpp/.tvp project or .tvpx file.
Source code in pytvpaint/project.py
669 670 671 672 673 674 675 676 677 678 679 680 |
|
save(save_path: Path | str | None = None) -> None
¶
Saves the project on disk.
Source code in pytvpaint/project.py
682 683 684 685 |
|
load_panel(panel_path: Path | str) -> None
¶
Load an external TVPaint panel.
Source code in pytvpaint/project.py
687 688 689 690 |
|
load_palette(palette_path: Path | str) -> None
¶
Load a palette.
Source code in pytvpaint/project.py
692 693 694 695 |
|
save_palette(save_path: Path | str | None = None) -> None
¶
Save a palette to the given path.
Source code in pytvpaint/project.py
697 698 699 700 701 |
|
save_video_dependencies(on_save: bool = True, now: bool = True) -> None
¶
Saves the video dependencies.
Source code in pytvpaint/project.py
703 704 705 706 |
|
save_audio_dependencies(on_save: bool = True) -> None
¶
Saves audio dependencies.
Source code in pytvpaint/project.py
708 709 710 711 |
|