Skip to content

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
def __init__(self, project_id: str) -> None:
    super().__init__()
    self._id = project_id
    self._is_closed = False
    self._data = george.tv_project_info(self._id)

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

Get/Set the background color(s).

Returns:

Type Description
tuple[pytvpaint.george.RGBColor, pytvpaint.george.RGBColor] | pytvpaint.george.RGBColor | None

a tuple of two colors if checker, a single color if solid or None if empty

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
def refresh(self) -> None:
    """Refreshes the project data.

    Raises:
        ValueError: if project has been closed
    """
    if self._is_closed:
        msg = "Project already closed, load the project again to get data"
        raise ValueError(msg)
    if not self.refresh_on_call and self._data:
        return

    self._data = george.tv_project_info(self._id)

make_current() -> None

Make the project the current one.

Source code in pytvpaint/project.py
111
112
113
114
115
def make_current(self) -> None:
    """Make the project the current one."""
    if self.is_current:
        return
    george.tv_project_select(self.id)

path() -> Path

The project path on disk.

Source code in pytvpaint/project.py
117
118
119
120
@refreshed_property
def path(self) -> Path:
    """The project path on disk."""
    return self._data.path

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_as_current
def resize(
    self,
    width: int,
    height: int,
    overwrite: bool = False,
    resize_opt: george.ResizeOption | None = None,
) -> Project:
    """Resize the current project and returns a new one.

    Args:
        width: the new width
        height: the new height
        overwrite: overwrite the original project, default is to create a new project
        resize_opt: how to resize the project

    Returns:
        the newly resized project
    """
    if (width, height) == (self.width, self.height):
        return self

    origin_position = self.position
    origin_path = self.path

    if resize_opt:
        george.tv_resize_page(width, height, resize_opt)
    else:
        george.tv_resize_project(width, height)

    # The resized project is at the same position and replaced the original one
    resized_id = george.tv_project_enum_id(origin_position)
    resized_project = Project(resized_id)

    if overwrite:
        resized_project.save(origin_path)

    return resized_project

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
@set_as_current
def set_fps(
    self,
    fps: float,
    time_stretch: bool = False,
    preview: bool = False,
) -> None:
    """Set the project's framerate."""
    george.tv_frame_rate_set(fps, time_stretch, preview)

pixel_aspect_ratio() -> float

The project's pixel aspect ratio.

Source code in pytvpaint/project.py
207
208
209
210
211
@refreshed_property
@set_as_current
def pixel_aspect_ratio(self) -> float:
    """The project's pixel aspect ratio."""
    return self._data.pixel_aspect_ratio

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
@set_as_current
def clear_background(self) -> None:
    """Clear the background color and set it to None."""
    self.background_mode = george.BackgroundMode.NONE
    self.background_colors = (
        george.RGBColor(255, 255, 255),
        george.RGBColor(0, 0, 0),
    )

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
@classmethod
def get_project(
    cls,
    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:
    """Find a project by id or by name or by path.

    Args:
        by_id: search by id. Defaults to None.
        by_name: search by name, search is case-insensitive. Defaults to None.
        by_regex: search by name using a compiled regex, case-sensitivity is left to the regex. Defaults to None.
        by_path: search by path. Defaults to None.

    Raises:
        ValueError: if none of the search arguments where provided

    Returns:
        Project | None: the searched element or None if search was unsuccessful
    """
    return utils.get_tvp_element(
        Project.open_projects(), by_id=by_id, by_name=by_name, by_regex=by_regex, by_path=by_path
    )

current_scene_ids() -> Iterator[int] staticmethod

Yields the current project's scene ids.

Source code in pytvpaint/project.py
342
343
344
345
@staticmethod
def current_scene_ids() -> Iterator[int]:
    """Yields the current project's scene ids."""
    return utils.position_generator(lambda pos: george.tv_scene_enum_id(pos))

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
def get_scene(self, scene_id: int) -> Scene | None:
    """Find a scene in the project by id.

    Args:
        scene_id: scene id

    Returns:
        Scene | None: the searched element or None if search was unsuccessful
    """
    for scene in self.scenes:
        if scene.id != scene_id:
            continue
        return scene

    return None

add_scene() -> Scene

Add a new scene in the project.

Source code in pytvpaint/project.py
384
385
386
387
388
389
@set_as_current
def add_scene(self) -> Scene:
    """Add a new scene in the project."""
    from pytvpaint.scene import Scene

    return Scene.new(project=self)

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
def get_clip(
    self,
    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.

    Args:
        by_id: search by id. Defaults to None.
        by_name: search by name, search is case-insensitive. Defaults to None.
        by_regex: search by name using a compiled regex, case-sensitivity is left to the regex. Defaults to None.
        scene_id: parent scene id. Defaults to None.

    Raises:
        ValueError: if none of the search arguments where provided

    Returns:
        Clip | None: the searched element or None if search was unsuccessful
    """
    clips = self.clips
    if scene_id:
        selected_scene = self.get_scene(scene_id=scene_id)
        clips = selected_scene.clips if selected_scene else clips

    return utils.get_tvp_element(clips, by_id=by_id, by_name=by_name, by_regex=by_regex)

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
def add_clip(self, clip_name: str, scene: Scene | None = None) -> Clip:
    """Add a new clip in the given scene or the current one if no scene provided."""
    scene = scene or self.current_scene
    return scene.add_clip(clip_name)

add_sound(sound_path: Path | str) -> ProjectSound

Add a new sound clip to the project.

Source code in pytvpaint/project.py
455
456
457
def add_sound(self, sound_path: Path | str) -> ProjectSound:
    """Add a new sound clip to the project."""
    return ProjectSound.new(sound_path, parent=self)

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
@set_as_current
def guidelines(self, by_type: george.GuidelineType | None = None) -> Iterator[guideline.Guideline[Any, Any]]:
    """Iterator for the `Guideline` objects of the project."""
    guideline_classes = {
        c.TYPE: c  # type: ignore[attr-defined]
        for c in [
            guideline.GuidelineImage,
            guideline.GuidelineLine,
            guideline.GuidelineSegment,
            guideline.GuidelineCircle,
            guideline.GuidelineEllipse,
            guideline.GuidelineGrid,
            guideline.GuidelineMarks,
            guideline.GuidelineSafeArea,
            guideline.GuidelineFieldChart,
            guideline.GuidelineAnimatorField,
            guideline.GuidelineVanishPoint1,
            guideline.GuidelineVanishPoint2,
            guideline.GuidelineVanishPoint3,
        ]
    }
    for g_type in george.GuidelineType:
        if by_type and by_type != g_type:
            continue
        if not guideline_classes.get(g_type):
            continue

        guideline_class = guideline_classes[g_type]

        positions = utils.position_generator(lambda pos: george.tv_guideline_enum(pos, g_type))
        for position in positions:
            yield guideline_class(position, project=self)

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
def add_guideline_image(
    self,
    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."""
    return guideline.GuidelineImage.new(self, img_path, x, y, rotation, scale, flip, alpha_mode)

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
def add_guideline_line(
    self,
    x: float | None = None,
    y: float | None = None,
    angle: float | None = None,
) -> guideline.GuidelineLine:
    """Add a new line guideline to the project."""
    return guideline.GuidelineLine.new(self, x, y, angle)

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
def add_guideline_segment(
    self,
    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."""
    return guideline.GuidelineSegment.new(self, x1, y1, x2, y2)

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
def add_guideline_circle(
    self,
    x: float | None = None,
    y: float | None = None,
    radius: float | None = None,
) -> guideline.GuidelineCircle:
    """Add a new segment guideline to the project."""
    return guideline.GuidelineCircle.new(self, x, y, radius)

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
def add_guideline_ellipse(
    self,
    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."""
    return guideline.GuidelineEllipse.new(self, x, y, radius_a, radius_b)

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
def add_guideline_grid(
    self,
    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."""
    return guideline.GuidelineGrid.new(self, x, y, width, height)

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
def add_guideline_marks(
    self,
    count_x: int | None = None,
    count_y: int | None = None,
) -> guideline.GuidelineMarks:
    """Add a new marks guideline to the project."""
    return guideline.GuidelineMarks.new(self, count_x, count_y)

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
def add_guideline_field_chart(
    self,
) -> guideline.GuidelineFieldChart:
    """Add a new field chart guideline to the project."""
    return guideline.GuidelineFieldChart.new(self)

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
def add_guideline_animator_field(
    self,
) -> guideline.GuidelineAnimatorField:
    """Add a new animator field guideline to the project."""
    return guideline.GuidelineAnimatorField.new(self)

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
def add_guideline_safe_area(
    self,
    sf_out: int | None = None,
    sf_in: int | None = None,
) -> guideline.GuidelineSafeArea:
    """Add a new safe area guideline to the project."""
    return guideline.GuidelineSafeArea.new(self, sf_out, sf_in)

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
def add_guideline_vanishing_point1(
    self,
    x: float | None = None,
    y: float | None = None,
    grid: bool | None = None,
) -> guideline.GuidelineVanishPoint1:
    """Add a new vanishing point1 guideline to the project."""
    return guideline.GuidelineVanishPoint1.new(self, x, y, grid)

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
def add_guideline_vanishing_point2(
    self,
    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."""
    return guideline.GuidelineVanishPoint2.new(self, x1, y1, x2, y2)

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
def add_guideline_vanishing_point3(
    self,
    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."""
    return guideline.GuidelineVanishPoint3.new(self, x1, y1, x2, y2, x3, y3)

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
@set_as_current
def render(
    self,
    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.

    Args:
        output_path: a single file or file sequence pattern
        start: the start frame to render or the mark in or the project's start frame if None. Defaults to None.
        end: the end frame to render or the mark out or the project's end frame if None. Defaults to None.
        frame_set: a FrameSet with the frames/range to render. Defaults to None.
        use_camera: use the camera for rendering, otherwise render the whole canvas. Defaults to False.
        alpha_mode: the alpha mode for rendering. Defaults to george.AlphaSaveMode.PREMULTIPLY.
        background_mode: the background mode for rendering. Defaults to george.BackgroundMode.NONE.
        format_opts: custom format options. Defaults to None.

    Raises:
        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:
        the output file path or sequence
    """
    default_start = self.mark_in or self.start_frame
    default_end = self.mark_out or self.end_frame

    return self._render(
        output_path=output_path,
        default_start=default_start,
        default_end=default_end,
        start=start,
        end=end,
        frame_set=frame_set,
        use_camera=use_camera,
        layer_selection=None,
        alpha_mode=alpha_mode,
        background_mode=background_mode,
        format_opts=format_opts,
    )

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
@set_as_current
def render_clips(
    self,
    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."""
    clips = sorted(clips, key=lambda c: c.position)
    start = clips[0].timeline_start
    end = clips[-1].timeline_end

    self.render(
        output_path=output_path,
        frame_set=FrameSet(f"{start}-{end}"),
        use_camera=use_camera,
        alpha_mode=alpha_mode,
        background_mode=background_mode,
        format_opts=format_opts,
    )

current_project_id() -> str staticmethod

Returns the current project id.

Source code in pytvpaint/project.py
730
731
732
733
@staticmethod
def current_project_id() -> str:
    """Returns the current project id."""
    return george.tv_project_current_id()

current_project() -> Project staticmethod

Returns the current project.

Source code in pytvpaint/project.py
735
736
737
738
@staticmethod
def current_project() -> Project:
    """Returns the current project."""
    return Project(project_id=Project.current_project_id())

open_projects_ids() -> Iterator[str] staticmethod

Yields the ids of the currently open projects.

Source code in pytvpaint/project.py
740
741
742
743
@staticmethod
def open_projects_ids() -> Iterator[str]:
    """Yields the ids of the currently open projects."""
    return utils.position_generator(lambda pos: george.tv_project_enum_id(pos))

open_projects() -> Iterator[Project] classmethod

Returns an iterator over the currently open projects.

Source code in pytvpaint/project.py
745
746
747
748
749
@classmethod
def open_projects(cls) -> Iterator[Project]:
    """Returns an iterator over the currently open projects."""
    for project_id in Project.open_projects_ids():
        yield Project(project_id)

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
@classmethod
def new(
    cls,
    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:
    """Create a new project."""
    george.tv_project_new(
        Path(project_path).resolve().as_posix(),
        width,
        height,
        pixel_aspect_ratio,
        frame_rate,
        field_order,
        start_frame,
    )
    return cls.current_project()

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
@set_as_current
def new_from_camera(self, export_path: Path | str | None = None) -> Project:
    """Create a new cropped project from the camera view."""
    cam_project_id = george.tv_project_render_camera(self.id)
    cam_project = Project(cam_project_id)

    if export_path:
        export_path = Path(export_path)
        export_path.mkdir(exist_ok=True, parents=True)
        cam_project.save(export_path)

    return cam_project

duplicate() -> Project

Duplicate the project and return the new one.

Source code in pytvpaint/project.py
835
836
837
838
839
840
841
@set_as_current
def duplicate(self) -> Project:
    """Duplicate the project and return the new one."""
    george.tv_project_duplicate()
    duplicated = Project.current_project()
    self.make_current()
    return duplicated

close() -> None

Closes the project.

Source code in pytvpaint/project.py
843
844
845
846
def close(self) -> None:
    """Closes the project."""
    self._is_closed = True
    george.tv_project_close(self._id)

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
@classmethod
def close_all(cls, close_tvp: bool = False) -> None:
    """Closes all open projects.

    Args:
        close_tvp: close the TVPaint instance as well
    """
    for project in list(cls.open_projects()):
        project.close()

    if close_tvp:
        george.tv_quit()

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
@classmethod
def load(cls, project_path: Path | str, silent: bool = True) -> Project:
    """Load an existing .tvpp/.tvp project or .tvpx file."""
    project_path = Path(project_path)

    # Check if project not already open, if so, return it
    for project in cls.open_projects():
        if project.path == project_path:
            return project

    george.tv_load_project(project_path, silent)
    return cls.current_project()

save(save_path: Path | str | None = None) -> None

Saves the project on disk.

Source code in pytvpaint/project.py
874
875
876
877
def save(self, save_path: Path | str | None = None) -> None:
    """Saves the project on disk."""
    save_path = Path(save_path or self.path).resolve()
    george.tv_save_project(save_path.as_posix())

load_panel(panel_path: Path | str) -> None

Load an external TVPaint panel.

Source code in pytvpaint/project.py
879
880
881
882
@set_as_current
def load_panel(self, panel_path: Path | str) -> None:
    """Load an external TVPaint panel."""
    george.tv_load_project(panel_path, silent=True)

load_palette(palette_path: Path | str) -> None

Load a palette.

Source code in pytvpaint/project.py
884
885
886
887
@set_as_current
def load_palette(self, palette_path: Path | str) -> None:
    """Load a palette."""
    george.tv_save_palette(palette_path)

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
@set_as_current
def save_palette(self, save_path: Path | str | None = None) -> None:
    """Save a palette to the given path."""
    save_path = Path(save_path or self.path)
    george.tv_save_project(save_path)

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
@set_as_current
def save_video_dependencies(self, on_save: bool = True, now: bool = True) -> None:
    """Saves the video dependencies."""
    george.tv_project_save_video_dependencies(self.id, on_save, now)

save_audio_dependencies(on_save: bool = True) -> None

Saves audio dependencies.

Source code in pytvpaint/project.py
900
901
902
903
@set_as_current
def save_audio_dependencies(self, on_save: bool = True) -> None:
    """Saves audio dependencies."""
    george.tv_project_save_audio_dependencies(self.id, on_save)