Project class¶
Project class.
Project(project_id: str)
¶
Bases: pytvpaint.utils.Refreshable, pytvpaint.utils.Renderable
A TVPaint project is the highest/root object that contains everything in the data hierarchy.
The Project structure can be split like so : Project -> Scene -> Clip -> Layer -> LayerInstance Or since TVPaint 12, like so : Project -> Scene -> Clip -> LayerFolder -> Layer -> LayerInstance
Source code in pytvpaint/project.py
36 37 38 39 40 | |
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
¶
Returns an 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_on_call = True
instance-attribute
¶
refresh() -> None
¶
Refreshes the project data.
Raises:
| Type | Description |
|---|---|
ValueError
|
if project has been closed |
Source code in pytvpaint/project.py
52 53 54 55 56 57 58 59 60 61 62 63 64 | |
make_current() -> None
¶
Make the project the current one.
Source code in pytvpaint/project.py
111 112 113 114 115 | |
path() -> Path
¶
The project path on disk.
Source code in pytvpaint/project.py
117 118 119 120 | |
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
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 | |
set_fps(fps: float, time_stretch: bool = False, preview: bool = False) -> None
¶
Set the project's framerate.
Source code in pytvpaint/project.py
192 193 194 195 196 197 198 199 200 | |
pixel_aspect_ratio() -> float
¶
The project's pixel aspect ratio.
Source code in pytvpaint/project.py
207 208 209 210 211 | |
clear_background() -> None
¶
Clear the background color and set it to None.
Source code in pytvpaint/project.py
280 281 282 283 284 285 286 287 | |
get_project(by_id: str | None = None, by_name: str | None = None, by_regex: re.Pattern[str] | None = None, by_path: str | Path | None = None) -> Project | None
classmethod
¶
Find a project by id or by name or by path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
by_id
|
str | None
|
search by id. Defaults to None. |
None
|
by_name
|
str | None
|
search by name, search is case-insensitive. Defaults to None. |
None
|
by_regex
|
re.Pattern[str] | None
|
search by name using a compiled regex, case-sensitivity is left to the regex. Defaults to None. |
None
|
by_path
|
str | pathlib.Path | None
|
search by path. Defaults to None. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
if none of the search arguments where provided |
Returns:
| Type | Description |
|---|---|
pytvpaint.project.Project | None
|
Project | None: the searched element or None if search was unsuccessful |
Source code in pytvpaint/project.py
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 | |
current_scene_ids() -> Iterator[int]
staticmethod
¶
Yields the current project's scene ids.
Source code in pytvpaint/project.py
342 343 344 345 | |
get_scene(scene_id: int) -> Scene | None
¶
Find a scene in the project by id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scene_id
|
int
|
scene id |
required |
Returns:
| Type | Description |
|---|---|
pytvpaint.scene.Scene | None
|
Scene | None: the searched element or None if search was unsuccessful |
Source code in pytvpaint/project.py
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | |
add_scene() -> Scene
¶
Add a new scene in the project.
Source code in pytvpaint/project.py
384 385 386 387 388 389 | |
get_clip(by_id: int | None = None, by_name: str | None = None, by_regex: re.Pattern[str] | None = None, scene_id: int | None = None) -> Clip | None
¶
Find a clip by id or name, filter search by scene_id if needed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
by_id
|
int | None
|
search by id. Defaults to None. |
None
|
by_name
|
str | None
|
search by name, search is case-insensitive. Defaults to None. |
None
|
by_regex
|
re.Pattern[str] | None
|
search by name using a compiled regex, case-sensitivity is left to the regex. Defaults to None. |
None
|
scene_id
|
int | None
|
parent scene id. Defaults to None. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
if none of the search arguments where provided |
Returns:
| Type | Description |
|---|---|
pytvpaint.clip.Clip | None
|
Clip | None: the searched element or None if search was unsuccessful |
Source code in pytvpaint/project.py
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 | |
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
442 443 444 445 | |
add_sound(sound_path: Path | str) -> ProjectSound
¶
Add a new sound clip to the project.
Source code in pytvpaint/project.py
455 456 457 | |
guidelines(by_type: george.GuidelineType | None = None) -> Iterator[guideline.Guideline[Any, Any]]
¶
Iterator for the Guideline objects of the project.
Source code in pytvpaint/project.py
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 | |
add_guideline_image(img_path: Path | str | None = None, x: float | None = None, y: float | None = None, rotation: float | None = None, scale: float | None = None, flip: george.FlipDirection | None = None, alpha_mode: george.GuidelineAlphaMode | None = None) -> guideline.GuidelineImage
¶
Add a new image guideline to the project.
Source code in pytvpaint/project.py
492 493 494 495 496 497 498 499 500 501 502 503 | |
add_guideline_line(x: float | None = None, y: float | None = None, angle: float | None = None) -> guideline.GuidelineLine
¶
Add a new line guideline to the project.
Source code in pytvpaint/project.py
505 506 507 508 509 510 511 512 | |
add_guideline_segment(x1: float | None = None, y1: float | None = None, x2: float | None = None, y2: float | None = None) -> guideline.GuidelineSegment
¶
Add a new segment guideline to the project.
Source code in pytvpaint/project.py
514 515 516 517 518 519 520 521 522 | |
add_guideline_circle(x: float | None = None, y: float | None = None, radius: float | None = None) -> guideline.GuidelineCircle
¶
Add a new segment guideline to the project.
Source code in pytvpaint/project.py
524 525 526 527 528 529 530 531 | |
add_guideline_ellipse(x: float | None = None, y: float | None = None, radius_a: float | None = None, radius_b: float | None = None) -> guideline.GuidelineEllipse
¶
Add a new ellipse guideline to the project.
Source code in pytvpaint/project.py
533 534 535 536 537 538 539 540 541 | |
add_guideline_grid(x: float | None = None, y: float | None = None, width: float | None = None, height: float | None = None) -> guideline.GuidelineGrid
¶
Add a new grid guideline to the project.
Source code in pytvpaint/project.py
543 544 545 546 547 548 549 550 551 | |
add_guideline_marks(count_x: int | None = None, count_y: int | None = None) -> guideline.GuidelineMarks
¶
Add a new marks guideline to the project.
Source code in pytvpaint/project.py
553 554 555 556 557 558 559 | |
add_guideline_field_chart() -> guideline.GuidelineFieldChart
¶
Add a new field chart guideline to the project.
Source code in pytvpaint/project.py
561 562 563 564 565 | |
add_guideline_animator_field() -> guideline.GuidelineAnimatorField
¶
Add a new animator field guideline to the project.
Source code in pytvpaint/project.py
567 568 569 570 571 | |
add_guideline_safe_area(sf_out: int | None = None, sf_in: int | None = None) -> guideline.GuidelineSafeArea
¶
Add a new safe area guideline to the project.
Source code in pytvpaint/project.py
573 574 575 576 577 578 579 | |
add_guideline_vanishing_point1(x: float | None = None, y: float | None = None, grid: bool | None = None) -> guideline.GuidelineVanishPoint1
¶
Add a new vanishing point1 guideline to the project.
Source code in pytvpaint/project.py
581 582 583 584 585 586 587 588 | |
add_guideline_vanishing_point2(x1: float | None = None, y1: float | None = None, x2: float | None = None, y2: float | None = None) -> guideline.GuidelineVanishPoint2
¶
Add a new vanishing point2 guideline to the project.
Source code in pytvpaint/project.py
590 591 592 593 594 595 596 597 598 | |
add_guideline_vanishing_point3(x1: float | None = None, y1: float | None = None, x2: float | None = None, y2: float | None = None, x3: float | None = None, y3: float | None = None) -> guideline.GuidelineVanishPoint3
¶
Add a new vanishing point2 guideline to the project.
Source code in pytvpaint/project.py
600 601 602 603 604 605 606 607 608 609 610 | |
render(output_path: Path | str | FileSequence, start: int | None = None, end: int | None = None, frame_set: FrameSet | 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) -> Path | FileSequence
¶
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
|
frame_set
|
fileseq.frameset.FrameSet | None
|
a FrameSet with the frames/range to render. 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.
Returns:
| Type | Description |
|---|---|
pathlib.Path | fileseq.filesequence.FileSequence
|
the output file path or sequence |
Source code in pytvpaint/project.py
648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 | |
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
706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 | |
current_project_id() -> str
staticmethod
¶
Returns the current project id.
Source code in pytvpaint/project.py
730 731 732 733 | |
current_project() -> Project
staticmethod
¶
Returns the current project.
Source code in pytvpaint/project.py
735 736 737 738 | |
open_projects_ids() -> Iterator[str]
staticmethod
¶
Yields the ids of the currently open projects.
Source code in pytvpaint/project.py
740 741 742 743 | |
open_projects() -> Iterator[Project]
classmethod
¶
Returns an iterator over the currently open projects.
Source code in pytvpaint/project.py
745 746 747 748 749 | |
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
799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 | |
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
822 823 824 825 826 827 828 829 830 831 832 833 | |
duplicate() -> Project
¶
Duplicate the project and return the new one.
Source code in pytvpaint/project.py
835 836 837 838 839 840 841 | |
close() -> None
¶
Closes the project.
Source code in pytvpaint/project.py
843 844 845 846 | |
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
848 849 850 851 852 853 854 855 856 857 858 859 | |
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
861 862 863 864 865 866 867 868 869 870 871 872 | |
save(save_path: Path | str | None = None) -> None
¶
Saves the project on disk.
Source code in pytvpaint/project.py
874 875 876 877 | |
load_panel(panel_path: Path | str) -> None
¶
Load an external TVPaint panel.
Source code in pytvpaint/project.py
879 880 881 882 | |
load_palette(palette_path: Path | str) -> None
¶
Load a palette.
Source code in pytvpaint/project.py
884 885 886 887 | |
save_palette(save_path: Path | str | None = None) -> None
¶
Save a palette to the given path.
Source code in pytvpaint/project.py
889 890 891 892 893 | |
save_video_dependencies(on_save: bool = True, now: bool = True) -> None
¶
Saves the video dependencies.
Source code in pytvpaint/project.py
895 896 897 898 | |
save_audio_dependencies(on_save: bool = True) -> None
¶
Saves audio dependencies.
Source code in pytvpaint/project.py
900 901 902 903 | |