Skip to content

Project related George functions

Project related George functions and enums.

TVPProject(id: str, path: Path, width: int, height: int, pixel_aspect_ratio: float, frame_rate: float, field_order: FieldOrder, start_frame: int) dataclass

TVPaint project info values.

BackgroundMode

Bases: enum.Enum

The project background mode.

Attributes:

Name Type Description
CHECK
COLOR
NONE

tv_background_get() -> tuple[BackgroundMode, tuple[RGBColor, RGBColor] | RGBColor | None]

Get the background mode of the project, and the color(s) if in color or check mode.

Returns:

Name Type Description
mode pytvpaint.george.grg_project.BackgroundMode

the background mode

colors tuple[pytvpaint.george.grg_base.RGBColor, pytvpaint.george.grg_base.RGBColor] | pytvpaint.george.grg_base.RGBColor | None

the background colors if any

Source code in pytvpaint/george/grg_project.py
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
def tv_background_get() -> (
    tuple[BackgroundMode, tuple[RGBColor, RGBColor] | RGBColor | None]
):
    """Get the background mode of the project, and the color(s) if in `color` or `check` mode.

    Returns:
        mode: the background mode
        colors: the background colors if any

    """
    res = send_cmd("tv_Background")

    mode, *values = res.split(" ")

    if mode == BackgroundMode.NONE.value:
        return BackgroundMode.NONE, None

    if mode == BackgroundMode.CHECK.value:
        c1 = map(int, values[:3])
        c2 = map(int, values[3:])
        return BackgroundMode.CHECK, (RGBColor(*c1), RGBColor(*c2))

    return BackgroundMode.COLOR, RGBColor(*map(int, values))

tv_background_set(mode: BackgroundMode, color: tuple[RGBColor, RGBColor] | RGBColor | None = None) -> None

Set the background mode of the project.

Parameters:

Name Type Description Default
mode pytvpaint.george.grg_project.BackgroundMode

color mode (None, checker or one color)

required
color tuple[pytvpaint.george.grg_base.RGBColor, pytvpaint.george.grg_base.RGBColor] | pytvpaint.george.grg_base.RGBColor | None

None for None mode, RBGColor for one color, and tuple of RGBColors for checker

None
Source code in pytvpaint/george/grg_project.py
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
def tv_background_set(
    mode: BackgroundMode,
    color: tuple[RGBColor, RGBColor] | RGBColor | None = None,
) -> None:
    """Set the background mode of the project.

    Args:
        mode: color mode (None, checker or one color)
        color: None for None mode, RBGColor for one color, and tuple of RGBColors for checker
    """
    args = []

    if mode == BackgroundMode.CHECK and isinstance(color, tuple):
        c1, c2 = color
        args = [c1.r, c1.g, c1.b, c2.r, c2.g, c2.b]
    elif mode == BackgroundMode.COLOR and isinstance(color, RGBColor):
        args = [color.r, color.g, color.b]

    send_cmd("tv_Background", mode.value, *args)

tv_project_new(project_path: Path | str, width: int = 1920, height: int = 1080, pixel_aspect_ratio: float = 1.0, frame_rate: float = 24.0, field_order: FieldOrder = FieldOrder.NONE, start_frame: int = 1) -> str

Create a new project.

Raises:

Type Description
pytvpaint.george.exceptions.GeorgeError

if an error occurred during the project creation

Source code in pytvpaint/george/grg_project.py
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
@try_cmd(exception_msg="Project created but may be corrupted")
def tv_project_new(
    project_path: Path | str,
    width: int = 1920,
    height: int = 1080,
    pixel_aspect_ratio: float = 1.0,
    frame_rate: float = 24.0,
    field_order: FieldOrder = FieldOrder.NONE,
    start_frame: int = 1,
) -> str:
    """Create a new project.

    Raises:
        GeorgeError: if an error occurred during the project creation
    """
    return send_cmd(
        "tv_ProjectNew",
        Path(project_path).as_posix(),
        width,
        height,
        pixel_aspect_ratio,
        frame_rate,
        field_order.value,
        start_frame,
        error_values=[GrgErrorValue.EMPTY],
    )

tv_load_project(project_path: Path | str, silent: bool = False) -> str

Load a file as a project if possible or open Import panel.

Raises:

Type Description
FileNotFoundError

if the project file doesn't exist

pytvpaint.george.exceptions.GeorgeError

if the provided file is in an invalid format

Source code in pytvpaint/george/grg_project.py
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
@try_cmd(exception_msg="Invalid format")
def tv_load_project(project_path: Path | str, silent: bool = False) -> str:
    """Load a file as a project if possible or open Import panel.

    Raises:
        FileNotFoundError: if the project file doesn't exist
        GeorgeError: if the provided file is in an invalid format
    """
    project_path = Path(project_path)

    if not project_path.exists():
        raise FileNotFoundError(f"Project not found at: {project_path.as_posix()}")

    args: list[Any] = [project_path.as_posix()]

    if silent:
        args.extend(["silent", int(silent)])

    return send_cmd("tv_LoadProject", *args, error_values=[-1])

tv_save_project(project_path: Path | str) -> None

Save the current project as tvpp.

Source code in pytvpaint/george/grg_project.py
149
150
151
152
153
154
155
156
157
158
def tv_save_project(project_path: Path | str) -> None:
    """Save the current project as tvpp."""
    project_path = Path(project_path)
    parent = project_path.parent

    if not parent.exists():
        msg = f"Can't save because parent folder does not exist: {parent.as_posix()}"
        raise ValueError(msg)

    send_cmd("tv_SaveProject", project_path.as_posix())

tv_project_duplicate() -> None

Duplicate the current project.

Raises:

Type Description
pytvpaint.george.exceptions.GeorgeError

if an error occurred during the project creation.

Source code in pytvpaint/george/grg_project.py
161
162
163
164
165
166
167
168
@try_cmd(exception_msg="Can't duplicate the current project")
def tv_project_duplicate() -> None:
    """Duplicate the current project.

    Raises:
        GeorgeError: if an error occurred during the project creation.
    """
    send_cmd("tv_ProjectDuplicate", error_values=[0])

tv_project_enum_id(position: int) -> str

Get the id of the project at the given position.

Raises:

Type Description
pytvpaint.george.exceptions.GeorgeError

if no project found at the provided position.

Source code in pytvpaint/george/grg_project.py
171
172
173
174
175
176
177
178
@try_cmd(exception_msg="No project at provided position")
def tv_project_enum_id(position: int) -> str:
    """Get the id of the project at the given position.

    Raises:
        GeorgeError: if no project found at the provided position.
    """
    return send_cmd("tv_ProjectEnumId", position, error_values=[GrgErrorValue.NONE])

tv_project_current_id() -> str

Get the id of the current project.

Source code in pytvpaint/george/grg_project.py
181
182
183
def tv_project_current_id() -> str:
    """Get the id of the current project."""
    return send_cmd("tv_ProjectCurrentId")

tv_project_info(project_id: str) -> TVPProject

Get info of the given project.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid project id

Source code in pytvpaint/george/grg_project.py
186
187
188
189
190
191
192
193
194
195
196
197
198
199
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid project id",
)
def tv_project_info(project_id: str) -> TVPProject:
    """Get info of the given project.

    Raises:
        NoObjectWithIdError: if given an invalid project id
    """
    result = send_cmd("tv_ProjectInfo", project_id, error_values=[GrgErrorValue.EMPTY])
    project = tv_parse_list(result, with_fields=TVPProject)
    project["id"] = project_id
    return TVPProject(**project)

tv_get_project_name() -> str

Returns the save path of the current project.

Source code in pytvpaint/george/grg_project.py
202
203
204
def tv_get_project_name() -> str:
    """Returns the save path of the current project."""
    return send_cmd("tv_GetProjectName")

tv_project_select(project_id: str) -> str

Make the given project current.

Source code in pytvpaint/george/grg_project.py
207
208
209
def tv_project_select(project_id: str) -> str:
    """Make the given project current."""
    return send_cmd("tv_ProjectSelect", project_id)

tv_project_close(project_id: str) -> None

Close the given project.

Source code in pytvpaint/george/grg_project.py
212
213
214
def tv_project_close(project_id: str) -> None:
    """Close the given project."""
    send_cmd("tv_ProjectClose", project_id)

tv_resize_project(width: int, height: int) -> None

Resize the current project.

Note

creates a resized copy of the project with a new id

Source code in pytvpaint/george/grg_project.py
217
218
219
220
221
222
223
def tv_resize_project(width: int, height: int) -> None:
    """Resize the current project.

    Note:
        creates a resized copy of the project with a new id
    """
    send_cmd("tv_ResizeProject", width, height)

tv_resize_page(width: int, height: int, resize_opt: ResizeOption) -> None

Create a new resized project and close the current one.

Source code in pytvpaint/george/grg_project.py
226
227
228
def tv_resize_page(width: int, height: int, resize_opt: ResizeOption) -> None:
    """Create a new resized project and close the current one."""
    send_cmd("tv_ResizePage", width, height, resize_opt.value)

tv_get_width() -> int

Get the current project width.

Source code in pytvpaint/george/grg_project.py
231
232
233
def tv_get_width() -> int:
    """Get the current project width."""
    return int(send_cmd("tv_GetWidth"))

tv_get_height() -> int

Get the current project height.

Source code in pytvpaint/george/grg_project.py
236
237
238
def tv_get_height() -> int:
    """Get the current project height."""
    return int(send_cmd("tv_GetHeight"))

tv_ratio() -> float

Get the current project pixel aspect ratio.

Bug

Doesn't work and always returns an empty string

Source code in pytvpaint/george/grg_project.py
241
242
243
244
245
246
247
def tv_ratio() -> float:
    """Get the current project pixel aspect ratio.

    Bug:
        Doesn't work and always returns an empty string
    """
    return float(send_cmd("tv_GetRatio", error_values=[GrgErrorValue.EMPTY]))

tv_get_field() -> FieldOrder

Get the current project field mode.

Source code in pytvpaint/george/grg_project.py
250
251
252
def tv_get_field() -> FieldOrder:
    """Get the current project field mode."""
    return tv_cast_to_type(send_cmd("tv_GetField"), cast_type=FieldOrder)

tv_project_save_sequence(export_path: Path | str, use_camera: bool = False, start: int | None = None, end: int | None = None) -> None

Save the current project.

Source code in pytvpaint/george/grg_project.py
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
def tv_project_save_sequence(
    export_path: Path | str,
    use_camera: bool = False,
    start: int | None = None,
    end: int | None = None,
) -> None:
    """Save the current project."""
    export_path = Path(export_path).resolve()
    args: list[Any] = [export_path.as_posix()]

    if use_camera:
        args.append("camera")
    if start is not None and end is not None:
        args.extend((start, end))

    send_cmd(
        "tv_ProjectSaveSequence",
        *args,
        error_values=[-1],
    )

tv_project_render_camera(project_id: str) -> str

Render the given project's camera view to a new project.

Returns:

Type Description
str

the new project id

Source code in pytvpaint/george/grg_project.py
277
278
279
280
281
282
283
284
285
286
287
def tv_project_render_camera(project_id: str) -> str:
    """Render the given project's camera view to a new project.

    Returns:
        the new project id
    """
    return send_cmd(
        "tv_ProjectRenderCamera",
        project_id,
        error_values=[GrgErrorValue.ERROR],
    )

tv_frame_rate_get() -> tuple[float, float]

Get the framerate of the current project.

Source code in pytvpaint/george/grg_project.py
290
291
292
293
294
295
296
297
298
299
300
def tv_frame_rate_get() -> tuple[float, float]:
    """Get the framerate of the current project."""
    parse = tv_parse_list(
        send_cmd("tv_FrameRate", 1, "info"),
        with_fields=[
            ("project_fps", float),
            ("playback_fps", float),
        ],
    )
    project_fps, playback_fps = parse.values()
    return project_fps, playback_fps

tv_frame_rate_set(frame_rate: float, time_stretch: bool = False, preview: bool = False) -> None

Get the framerate of the current project.

Source code in pytvpaint/george/grg_project.py
303
304
305
306
307
308
309
310
311
312
313
def tv_frame_rate_set(
    frame_rate: float, time_stretch: bool = False, preview: bool = False
) -> None:
    """Get the framerate of the current project."""
    args: list[Any] = []
    if time_stretch:
        args = ["timestretch"]
    if preview:
        args = ["preview"]
    args.insert(0, frame_rate)
    send_cmd("tv_FrameRate", *args)

tv_frame_rate_project_set(frame_rate: float, time_stretch: bool = False) -> None

Set the framerate of the current project.

Source code in pytvpaint/george/grg_project.py
316
317
318
319
320
321
def tv_frame_rate_project_set(frame_rate: float, time_stretch: bool = False) -> None:
    """Set the framerate of the current project."""
    args: list[Any] = [frame_rate]
    if time_stretch:
        args.append("timestretch")
    send_cmd("tv_FrameRate", *args)

tv_frame_rate_preview_set(frame_rate: float) -> None

Set the framerate of the preview (playback).

Source code in pytvpaint/george/grg_project.py
324
325
326
def tv_frame_rate_preview_set(frame_rate: float) -> None:
    """Set the framerate of the preview (playback)."""
    send_cmd("tv_FrameRate", frame_rate, "preview")

tv_project_current_frame_get() -> int

Get the current frame of the current project.

Source code in pytvpaint/george/grg_project.py
329
330
331
def tv_project_current_frame_get() -> int:
    """Get the current frame of the current project."""
    return int(send_cmd("tv_ProjectCurrentFrame"))

tv_project_current_frame_set(frame: int) -> int

Set the current frame of the current project.

Note

this is relative to the current clip markin

Source code in pytvpaint/george/grg_project.py
334
335
336
337
338
339
340
def tv_project_current_frame_set(frame: int) -> int:
    """Set the current frame of the current project.

    Note:
        this is relative to the current clip markin
    """
    return int(send_cmd("tv_ProjectCurrentFrame", frame))

tv_load_palette(palette_path: Path | str) -> None

Load a palette(s) from a file/directory.

Raises:

Type Description
FileNotFoundError

if palette was not found at the provided path

Source code in pytvpaint/george/grg_project.py
343
344
345
346
347
348
349
350
351
352
def tv_load_palette(palette_path: Path | str) -> None:
    """Load a palette(s) from a file/directory.

    Raises:
        FileNotFoundError: if palette was not found at the provided path
    """
    palette_path = Path(palette_path)
    if not palette_path.exists():
        raise FileNotFoundError(f"Palette not found at: {palette_path.as_posix()}")
    send_cmd("tv_LoadPalette", palette_path.as_posix())

tv_save_palette(palette_path: Path | str) -> None

Save the current palette.

Raises:

Type Description
FileNotFoundError

if palette save directory doesn't exist

Source code in pytvpaint/george/grg_project.py
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
def tv_save_palette(palette_path: Path | str) -> None:
    """Save the current palette.

    Raises:
        FileNotFoundError: if palette save directory doesn't exist
    """
    palette_path = Path(palette_path)

    if not palette_path.parent.exists():
        parent_path = palette_path.parent.as_posix()
        raise NotADirectoryError(
            f"Can't save palette because parent folder doesn't exist: {parent_path}"
        )

    send_cmd("tv_SavePalette", palette_path.as_posix())

tv_project_save_video_dependencies() -> None

Saves current project video dependencies.

Source code in pytvpaint/george/grg_project.py
372
373
374
def tv_project_save_video_dependencies() -> None:
    """Saves current project video dependencies."""
    send_cmd("tv_ProjectSaveVideoDependencies")

tv_project_save_audio_dependencies() -> None

Saves current project audio dependencies.

Source code in pytvpaint/george/grg_project.py
377
378
379
def tv_project_save_audio_dependencies() -> None:
    """Saves current project audio dependencies."""
    send_cmd("tv_ProjectSaveAudioDependencies")

tv_sound_project_info(project_id: str, track_index: int) -> TVPSound

Get information about a project soundtrack.

Source code in pytvpaint/george/grg_project.py
382
383
384
385
386
387
388
def tv_sound_project_info(project_id: str, track_index: int) -> TVPSound:
    """Get information about a project soundtrack."""
    res = send_cmd(
        "tv_SoundProjectInfo", project_id, track_index, error_values=[-1, -2, -3]
    )
    res_parse = tv_parse_list(res, with_fields=TVPSound)
    return TVPSound(**res_parse)

tv_sound_project_new(sound_path: Path | str) -> None

Add a new soundtrack to the current project.

Source code in pytvpaint/george/grg_project.py
391
392
393
394
395
396
397
def tv_sound_project_new(sound_path: Path | str) -> None:
    """Add a new soundtrack to the current project."""
    path = Path(sound_path)
    if not path.exists():
        raise ValueError(f"Sound file not found at : {path.as_posix()}")

    send_cmd("tv_SoundProjectNew", path.as_posix(), error_values=[-1, -3, -4])

tv_sound_project_remove(track_index: int) -> None

Remove a soundtrack from the current project.

Source code in pytvpaint/george/grg_project.py
400
401
402
def tv_sound_project_remove(track_index: int) -> None:
    """Remove a soundtrack from the current project."""
    send_cmd("tv_SoundProjectRemove", track_index, error_values=[-2])

tv_sound_project_reload(project_id: str, track_index: int) -> None

Reload a project soundtracks file.

Source code in pytvpaint/george/grg_project.py
405
406
407
408
409
410
411
412
def tv_sound_project_reload(project_id: str, track_index: int) -> None:
    """Reload a project soundtracks file."""
    send_cmd(
        "tv_SoundProjectReload",
        project_id,
        track_index,
        error_values=[-1, -2, -3],
    )

tv_sound_project_adjust(track_index: int, mute: bool | None = None, volume: float | None = None, offset: float | None = None, fade_in_start: float | None = None, fade_in_stop: float | None = None, fade_out_start: float | None = None, fade_out_stop: float | None = None, color_index: int | None = None) -> None

Change the current project's soundtrack settings.

Source code in pytvpaint/george/grg_project.py
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
441
442
443
def tv_sound_project_adjust(
    track_index: int,
    mute: bool | None = None,
    volume: float | None = None,
    offset: float | None = None,
    fade_in_start: float | None = None,
    fade_in_stop: float | None = None,
    fade_out_start: float | None = None,
    fade_out_stop: float | None = None,
    color_index: int | None = None,
) -> None:
    """Change the current project's soundtrack settings."""
    cur_options = tv_sound_project_info(tv_project_current_id(), track_index)
    args: list[int | float | None] = []

    optional_args = [
        (int(mute) if mute is not None else None, int(cur_options.mute)),
        (volume, cur_options.volume),
        (offset, cur_options.offset),
        (fade_in_start, cur_options.fade_in_start),
        (fade_in_stop, cur_options.fade_in_stop),
        (fade_out_start, cur_options.fade_out_start),
        (fade_out_stop, cur_options.fade_out_stop),
    ]
    for arg, default_value in optional_args:
        args.append(arg if arg is not None else default_value)

    args.append(color_index)
    send_cmd("tv_SoundProjectAdjust", track_index, *args, error_values=[-2, -3])

tv_project_header_info_get(project_id: str) -> str

Get the project header info.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid project id

Source code in pytvpaint/george/grg_project.py
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid project id",
)
def tv_project_header_info_get(project_id: str) -> str:
    """Get the project header info.

    Raises:
        NoObjectWithIdError: if given an invalid project id
    """
    return send_cmd(
        "tv_ProjectHeaderInfo",
        project_id,
        error_values=[GrgErrorValue.ERROR],
    ).strip('"')

tv_project_header_info_set(project_id: str, text: str) -> None

Set the project header info.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid project id

Source code in pytvpaint/george/grg_project.py
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid project id",
)
def tv_project_header_info_set(project_id: str, text: str) -> None:
    """Set the project header info.

    Raises:
        NoObjectWithIdError: if given an invalid project id
    """
    send_cmd(
        "tv_ProjectHeaderInfo",
        project_id,
        text,
        error_values=[GrgErrorValue.ERROR],
    )

tv_project_header_author_get(project_id: str) -> str

Get the project author info.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid project id

Source code in pytvpaint/george/grg_project.py
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid project id",
)
def tv_project_header_author_get(project_id: str) -> str:
    """Get the project author info.

    Raises:
        NoObjectWithIdError: if given an invalid project id
    """
    return send_cmd(
        "tv_ProjectHeaderAuthor",
        project_id,
        error_values=[GrgErrorValue.ERROR],
    ).strip('"')

tv_project_header_author_set(project_id: str, text: str) -> None

Set the project author info.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid project id

Source code in pytvpaint/george/grg_project.py
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid project id",
)
def tv_project_header_author_set(project_id: str, text: str) -> None:
    """Set the project author info.

    Raises:
        NoObjectWithIdError: if given an invalid project id
    """
    send_cmd(
        "tv_ProjectHeaderAuthor",
        project_id,
        text,
        error_values=[GrgErrorValue.ERROR],
    )

tv_project_header_notes_get(project_id: str) -> str

Get the project notes.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid project id

Source code in pytvpaint/george/grg_project.py
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid project id",
)
def tv_project_header_notes_get(project_id: str) -> str:
    """Get the project notes.

    Raises:
        NoObjectWithIdError: if given an invalid project id
    """
    return send_cmd(
        "tv_ProjectHeaderNotes",
        project_id,
        error_values=[GrgErrorValue.ERROR],
    ).strip('"')

tv_project_header_notes_set(project_id: str, text: str) -> None

Set the project notes.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid project id

Source code in pytvpaint/george/grg_project.py
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid project id",
)
def tv_project_header_notes_set(project_id: str, text: str) -> None:
    """Set the project notes.

    Raises:
        NoObjectWithIdError: if given an invalid project id
    """
    send_cmd(
        "tv_ProjectHeaderNotes",
        project_id,
        text,
        error_values=[GrgErrorValue.ERROR],
    )

tv_start_frame_get() -> int

Get the start frame of the current project.

Source code in pytvpaint/george/grg_project.py
551
552
553
def tv_start_frame_get() -> int:
    """Get the start frame of the current project."""
    return int(send_cmd("tv_StartFrame"))

tv_start_frame_set(start_frame: int) -> int

Set the start frame of the current project.

Source code in pytvpaint/george/grg_project.py
556
557
558
def tv_start_frame_set(start_frame: int) -> int:
    """Set the start frame of the current project."""
    return int(send_cmd("tv_StartFrame", start_frame))