Skip to content

Clip related George functions

Clip related George functions.

TVPClip(id: int, name: str, is_current: bool, is_hidden: bool, is_selected: bool, storyboard_start_frame: int, first_frame: int, last_frame: int, frame_count: int, mark_in: int, mark_out: int, color_idx: int) dataclass

TVPaint clip info values.

PSDSaveMode

Bases: enum.Enum

PSD save modes.

Attributes:

Name Type Description
ALL
IMAGE
MARKIN

tv_clip_info(clip_id: int) -> TVPClip

Get the information of the given clip.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid clip id

Source code in pytvpaint/george/grg_clip.py
59
60
61
62
63
64
65
66
67
68
69
70
71
72
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid clip id",
)
def tv_clip_info(clip_id: int) -> TVPClip:
    """Get the information of the given clip.

    Raises:
        NoObjectWithIdError: if given an invalid clip id
    """
    result = send_cmd("tv_ClipInfo", clip_id, error_values=[GrgErrorValue.EMPTY])
    clip = tv_parse_dict(result, with_fields=TVPClip)
    clip["id"] = clip_id
    return TVPClip(**clip)

tv_clip_enum_id(scene_id: int, clip_position: int) -> int

Get the id of the clip at the given position inside the given scene.

Raises:

Type Description
pytvpaint.george.exceptions.GeorgeError

if given an invalid scene id or clip position or elements have been removed

Source code in pytvpaint/george/grg_clip.py
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
@try_cmd(
    exception_msg="Invalid scene id or clip position or elements have been removed"
)
def tv_clip_enum_id(scene_id: int, clip_position: int) -> int:
    """Get the id of the clip at the given position inside the given scene.

    Raises:
        GeorgeError: if given an invalid scene id or clip position or elements have been removed
    """
    return int(
        send_cmd(
            "tv_ClipEnumId",
            scene_id,
            clip_position,
            error_values=[GrgErrorValue.NONE],
        )
    )

tv_clip_current_id() -> int

Get the id of the current clip.

Source code in pytvpaint/george/grg_clip.py
94
95
96
def tv_clip_current_id() -> int:
    """Get the id of the current clip."""
    return int(send_cmd("tv_ClipCurrentId"))

tv_clip_new(name: str) -> None

Create a new clip.

Source code in pytvpaint/george/grg_clip.py
 99
100
101
def tv_clip_new(name: str) -> None:
    """Create a new clip."""
    send_cmd("tv_ClipNew", name, handle_string=False)

tv_clip_duplicate(clip_id: int) -> None

Duplicate the given clip.

Source code in pytvpaint/george/grg_clip.py
104
105
106
def tv_clip_duplicate(clip_id: int) -> None:
    """Duplicate the given clip."""
    send_cmd("tv_ClipDuplicate", clip_id)

tv_clip_close(clip_id: int) -> None

Remove the given clip.

Source code in pytvpaint/george/grg_clip.py
109
110
111
def tv_clip_close(clip_id: int) -> None:
    """Remove the given clip."""
    send_cmd("tv_ClipClose", clip_id)

tv_clip_name_get(clip_id: int) -> str

Get the clip name.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid clip id

Source code in pytvpaint/george/grg_clip.py
114
115
116
117
118
119
120
121
122
123
124
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid clip id",
)
def tv_clip_name_get(clip_id: int) -> str:
    """Get the clip name.

    Raises:
        NoObjectWithIdError: if given an invalid clip id
    """
    return send_cmd("tv_ClipName", clip_id, error_values=[GrgErrorValue.EMPTY])

tv_clip_name_set(clip_id: int, name: str) -> None

Set the clip name.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid clip id

Source code in pytvpaint/george/grg_clip.py
127
128
129
130
131
132
133
134
135
136
137
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid clip id",
)
def tv_clip_name_set(clip_id: int, name: str) -> None:
    """Set the clip name.

    Raises:
        NoObjectWithIdError: if given an invalid clip id
    """
    send_cmd("tv_ClipName", clip_id, name, error_values=[GrgErrorValue.EMPTY])

tv_clip_move(clip_id: int, scene_id: int, position: int) -> None

Manage clip position.

Source code in pytvpaint/george/grg_clip.py
140
141
142
def tv_clip_move(clip_id: int, scene_id: int, position: int) -> None:
    """Manage clip position."""
    send_cmd("tv_ClipMove", clip_id, scene_id, position)

tv_clip_hidden_get(clip_id: int) -> bool

Get clip visibility.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid clip id

Source code in pytvpaint/george/grg_clip.py
145
146
147
148
149
150
151
152
153
154
155
156
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid clip id",
)
def tv_clip_hidden_get(clip_id: int) -> bool:
    """Get clip visibility.

    Raises:
        NoObjectWithIdError: if given an invalid clip id
    """
    res = send_cmd("tv_ClipHidden", clip_id, error_values=[GrgErrorValue.EMPTY])
    return bool(int(res))

tv_clip_hidden_set(clip_id: int, new_state: bool) -> None

Set clip visibility.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid clip id

Source code in pytvpaint/george/grg_clip.py
159
160
161
162
163
164
165
166
167
168
169
170
171
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid clip id",
)
def tv_clip_hidden_set(clip_id: int, new_state: bool) -> None:
    """Set clip visibility.

    Raises:
        NoObjectWithIdError: if given an invalid clip id
    """
    send_cmd(
        "tv_ClipHidden", clip_id, int(new_state), error_values=[GrgErrorValue.EMPTY]
    )

tv_clip_select(clip_id: int) -> None

Activate/Make current the given clip.

Source code in pytvpaint/george/grg_clip.py
174
175
176
def tv_clip_select(clip_id: int) -> None:
    """Activate/Make current the given clip."""
    send_cmd("tv_ClipSelect", clip_id)

tv_clip_selection_get(clip_id: int) -> bool

Get the clip's selection state.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid clip id

Source code in pytvpaint/george/grg_clip.py
179
180
181
182
183
184
185
186
187
188
189
190
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid clip id",
)
def tv_clip_selection_get(clip_id: int) -> bool:
    """Get the clip's selection state.

    Raises:
        NoObjectWithIdError: if given an invalid clip id
    """
    res = send_cmd("tv_ClipSelection", clip_id, error_values=[-1])
    return bool(int(res))

tv_clip_selection_set(clip_id: int, new_state: bool) -> None

Set the clip's selection state.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid clip id

Source code in pytvpaint/george/grg_clip.py
193
194
195
196
197
198
199
200
201
202
203
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid clip id",
)
def tv_clip_selection_set(clip_id: int, new_state: bool) -> None:
    """Set the clip's selection state.

    Raises:
        NoObjectWithIdError: if given an invalid clip id
    """
    send_cmd("tv_ClipSelection", clip_id, int(new_state), error_values=[-1])

tv_first_image() -> int

Get the first image of the clip.

Source code in pytvpaint/george/grg_clip.py
206
207
208
def tv_first_image() -> int:
    """Get the first image of the clip."""
    return int(send_cmd("tv_FirstImage"))

tv_last_image() -> int

Get the last image of the clip.

Source code in pytvpaint/george/grg_clip.py
211
212
213
def tv_last_image() -> int:
    """Get the last image of the clip."""
    return int(send_cmd("tv_LastImage"))

tv_load_sequence(seq_path: Path | str, offset_count: tuple[int, int] | None = None, field_order: FieldOrder | None = None, stretch: bool = False, time_stretch: bool = False, preload: bool = False) -> int

Load a sequence of images or movie in a new layer.

Parameters:

Name Type Description Default
seq_path pathlib.Path | str

the first file of the sequence to load

required
offset_count tuple[int, int] | None

the start and number of images in the sequence to load. Defaults to None.

None
field_order pytvpaint.george.grg_base.FieldOrder | None

the field order. Defaults to None.

None
stretch bool

Stretch each image to the size of the layer. Defaults to None.

False
time_stretch bool

Once loaded, the layer will have a new number of images corresponding to the project framerate. Defaults to None.

False
preload bool

Load all the images in memory, no more reference on the files. Defaults to None.

False

Raises:

Type Description
FileNotFoundError

if the sequence file doesn't exist

pytvpaint.george.exceptions.GeorgeError

if the input file is in an invalid format

Returns:

Type Description
int

the number of images of the new layer

Source code in pytvpaint/george/grg_clip.py
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
@try_cmd(exception_msg="Invalid format for sequence")
def tv_load_sequence(
    seq_path: Path | str,
    offset_count: tuple[int, int] | None = None,
    field_order: FieldOrder | None = None,
    stretch: bool = False,
    time_stretch: bool = False,
    preload: bool = False,
) -> int:
    """Load a sequence of images or movie in a new layer.

    Args:
        seq_path: the first file of the sequence to load
        offset_count: the start and number of images in the sequence to load. Defaults to None.
        field_order: the field order. Defaults to None.
        stretch: Stretch each image to the size of the layer. Defaults to None.
        time_stretch: Once loaded, the layer will have a new number of images corresponding to the project framerate. Defaults to None.
        preload: Load all the images in memory, no more reference on the files. Defaults to None.

    Raises:
        FileNotFoundError: if the sequence file doesn't exist
        GeorgeError: if the input file is in an invalid format

    Returns:
        the number of images of the new layer
    """
    seq_path = Path(seq_path)

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

    args: list[int | str] = [seq_path.as_posix()]
    if offset_count and len(offset_count) == 2:
        args.extend(offset_count)
    if field_order:
        args.append(field_order.value)

    extra_args = [
        (stretch, "stretch"),
        (time_stretch, "timestretch"),
        (preload, "preload"),
    ]
    for param, param_name in extra_args:
        if not param:
            continue
        args.append(param_name)

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

    return int(result)

tv_save_sequence(export_path: Path | str, mark_in: int | None = None, mark_out: int | None = None) -> None

Save the current clip.

Raises:

Type Description
NotADirectoryError

if the export directory doesn't exist

Source code in pytvpaint/george/grg_clip.py
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
def tv_save_sequence(
    export_path: Path | str,
    mark_in: int | None = None,
    mark_out: int | None = None,
) -> None:
    """Save the current clip.

    Raises:
        NotADirectoryError: if the export directory doesn't exist
    """
    export_path = Path(export_path).resolve()

    if not export_path.parent.exists():
        raise NotADirectoryError(
            "Can't save the sequence because parent"
            f"folder does not exist: {export_path.parent.as_posix()}"
        )

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

    if mark_in is not None and mark_out is not None:
        args.extend([mark_in, mark_out])

    send_cmd("tv_SaveSequence", *args)

tv_bookmarks_enum(position: int) -> int

Get the frame (in the clip) corresponding to the bookmark at the given position.

Raises:

Type Description
pytvpaint.george.exceptions.GeorgeError

if no bookmark found at provided position

Source code in pytvpaint/george/grg_clip.py
298
299
300
301
302
303
304
305
306
307
@try_cmd(exception_msg="No bookmark at provided position")
def tv_bookmarks_enum(position: int) -> int:
    """Get the frame (in the clip) corresponding to the bookmark at the given position.

    Raises:
        GeorgeError: if no bookmark found at provided position
    """
    return int(
        send_cmd("tv_BookmarksEnum", position, error_values=[GrgErrorValue.NONE])
    )

tv_bookmark_set(frame: int) -> None

Set a bookmark at the given frame.

Source code in pytvpaint/george/grg_clip.py
310
311
312
def tv_bookmark_set(frame: int) -> None:
    """Set a bookmark at the given frame."""
    send_cmd("tv_BookmarkSet", frame)

tv_bookmark_clear(frame: int) -> None

Remove a bookmark at the given frame.

Source code in pytvpaint/george/grg_clip.py
315
316
317
def tv_bookmark_clear(frame: int) -> None:
    """Remove a bookmark at the given frame."""
    send_cmd("tv_BookmarkClear", frame)

tv_bookmark_next() -> None

Go to the next bookmarked frame.

Source code in pytvpaint/george/grg_clip.py
320
321
322
def tv_bookmark_next() -> None:
    """Go to the next bookmarked frame."""
    send_cmd("tv_BookmarkNext")

tv_bookmark_prev() -> None

Go to the previous bookmarked frame.

Source code in pytvpaint/george/grg_clip.py
325
326
327
def tv_bookmark_prev() -> None:
    """Go to the previous bookmarked frame."""
    send_cmd("tv_BookmarkPrev")

tv_clip_color_get(clip_id: int) -> int

Get the clip color.

Source code in pytvpaint/george/grg_clip.py
330
331
332
def tv_clip_color_get(clip_id: int) -> int:
    """Get the clip color."""
    return int(send_cmd("tv_ClipColor", clip_id, error_values=[GrgErrorValue.EMPTY]))

tv_clip_color_set(clip_id: int, color_index: int) -> None

Set the clip color.

Source code in pytvpaint/george/grg_clip.py
335
336
337
def tv_clip_color_set(clip_id: int, color_index: int) -> None:
    """Set the clip color."""
    send_cmd("tv_ClipColor", clip_id, color_index, error_values=[GrgErrorValue.EMPTY])

tv_clip_action_get(clip_id: int) -> str

Get the action text of the clip.

Source code in pytvpaint/george/grg_clip.py
340
341
342
343
344
345
def tv_clip_action_get(clip_id: int) -> str:
    """Get the action text of the clip."""
    # We explicitly check if the clip exists because the error value is an empty string, and we can't determine if the
    # action text is empty or the clip_id is invalid...
    tv_clip_name_get(clip_id)
    return send_cmd("tv_ClipAction", clip_id)

tv_clip_action_set(clip_id: int, text: str) -> None

Set the action text of the clip.

Source code in pytvpaint/george/grg_clip.py
348
349
350
351
352
def tv_clip_action_set(clip_id: int, text: str) -> None:
    """Set the action text of the clip."""
    # See tv_clip_action_get above
    tv_clip_name_get(clip_id)
    send_cmd("tv_ClipAction", clip_id, text)

tv_clip_dialog_get(clip_id: int) -> str

Get the dialog text of the clip.

Source code in pytvpaint/george/grg_clip.py
355
356
357
358
359
def tv_clip_dialog_get(clip_id: int) -> str:
    """Get the dialog text of the clip."""
    # See tv_clip_action_get above
    tv_clip_name_get(clip_id)
    return send_cmd("tv_ClipDialog", clip_id)

tv_clip_dialog_set(clip_id: int, dialog: str) -> None

Set the dialog text of the clip.

Source code in pytvpaint/george/grg_clip.py
362
363
364
365
366
def tv_clip_dialog_set(clip_id: int, dialog: str) -> None:
    """Set the dialog text of the clip."""
    # See tv_clip_action_get above
    tv_clip_name_get(clip_id)
    send_cmd("tv_ClipDialog", clip_id, dialog)

tv_clip_note_get(clip_id: int) -> str

Get the note text of the clip.

Source code in pytvpaint/george/grg_clip.py
369
370
371
372
373
def tv_clip_note_get(clip_id: int) -> str:
    """Get the note text of the clip."""
    # See tv_clip_action_get above
    tv_clip_name_get(clip_id)
    return send_cmd("tv_ClipNote", clip_id)

tv_clip_note_set(clip_id: int, note: str) -> None

Set the note text of the clip.

Source code in pytvpaint/george/grg_clip.py
376
377
378
379
380
def tv_clip_note_set(clip_id: int, note: str) -> None:
    """Set the note text of the clip."""
    # See tv_clip_action_get above
    tv_clip_name_get(clip_id)
    send_cmd("tv_ClipNote", clip_id, note)

tv_save_clip(export_path: Path | str) -> None

Save the current clip in .tvp format.

Raises:

Type Description
pytvpaint.george.exceptions.GeorgeError

if file couldn't be saved

Source code in pytvpaint/george/grg_clip.py
383
384
385
386
387
388
389
390
391
@try_cmd(exception_msg="Can't create file")
def tv_save_clip(export_path: Path | str) -> None:
    """Save the current clip in .tvp format.

    Raises:
        GeorgeError: if file couldn't be saved
    """
    export_path = Path(export_path)
    send_cmd("tv_SaveClip", export_path.as_posix())

tv_save_display(export_path: Path | str) -> None

Save the display.

Source code in pytvpaint/george/grg_clip.py
394
395
396
397
def tv_save_display(export_path: Path | str) -> None:
    """Save the display."""
    export_path = Path(export_path).resolve()
    send_cmd("tv_SaveDisplay", export_path.as_posix())

tv_clip_save_structure_json(export_path: Path | str, file_format: SaveFormat, fill_background: bool = False, folder_pattern: str | None = None, file_pattern: str | None = None, visible_layers_only: bool = True, all_images: bool = False, ignore_duplicates: bool = False, exclude_names: list[str] | None = None) -> None

Save the current clip structure in json.

Parameters:

Name Type Description Default
export_path pathlib.Path | str

the JSON export path

required
file_format pytvpaint.george.grg_base.SaveFormat

file format to use for rendering

required
fill_background bool

add a background. Defaults to None.

False
folder_pattern str | None

the folder name pattern (%li: layer index, %ln: layer name, %fi: file index (added in 11.0.8)). Defaults to None.

None
file_pattern str | None

the file name pattern (%li: layer index, %ln: layer name, %ii: image index, %in: image name, %fi: file index (added in 11.0.8)). Defaults to None.

None
visible_layers_only bool

export only visible layers. Defaults to None.

True
all_images bool

export all images. Defaults to None.

False
ignore_duplicates bool

Ignore duplicates images. Defaults to None.

False
exclude_names list[str] | None

the instances names which won't be processed/exported. Defaults to None.

None

Raises:

Type Description
ValueError

the parent folder doesn't exist

Source code in pytvpaint/george/grg_clip.py
400
401
402
403
404
405
406
407
408
409
410
411
412
413
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
441
442
443
444
445
446
447
448
def tv_clip_save_structure_json(
    export_path: Path | str,
    file_format: SaveFormat,
    fill_background: bool = False,
    folder_pattern: str | None = None,
    file_pattern: str | None = None,
    visible_layers_only: bool = True,
    all_images: bool = False,
    ignore_duplicates: bool = False,
    exclude_names: list[str] | None = None,
) -> None:
    """Save the current clip structure in json.

    Args:
        export_path: the JSON export path
        file_format: file format to use for rendering
        fill_background: add a background. Defaults to None.
        folder_pattern: the folder name pattern (%li: layer index, %ln: layer name, %fi: file index (added in 11.0.8)). Defaults to None.
        file_pattern: the file name pattern (%li: layer index, %ln: layer name, %ii: image index, %in: image name, %fi: file index (added in 11.0.8)). Defaults to None.
        visible_layers_only: export only visible layers. Defaults to None.
        all_images: export all images. Defaults to None.
        ignore_duplicates: Ignore duplicates images. Defaults to None.
        exclude_names: the instances names which won't be processed/exported. Defaults to None.

    Raises:
        ValueError: the parent folder doesn't exist
    """
    export_path = Path(export_path).resolve()

    if not export_path.parent.exists():
        raise ValueError(
            "Can't write file because the destination folder doesn't exist"
        )

    args = [export_path.as_posix(), "JSON"]

    dict_args = {
        "fileformat": file_format.value,
        "background": int(fill_background) if fill_background else None,
        "patternfolder": folder_pattern,
        "patternfile": file_pattern,
        "onlyvisiblelayers": int(visible_layers_only),
        "allimages": int(all_images),
        "ignoreduplicateimages": int(ignore_duplicates),
        "excludenames": (";".join(exclude_names) if exclude_names else None),
    }
    args.extend(args_dict_to_list(dict_args))

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

tv_clip_save_structure_psd(export_path: Path | str, mode: PSDSaveMode, image: int | None = None, mark_in: int | None = None, mark_out: int | None = None) -> None

Save the current clip as a PSD.

Parameters:

Name Type Description Default
export_path pathlib.Path | str

description

required
mode pytvpaint.george.grg_clip.PSDSaveMode

all will export all layers to a single PSD

required
image int | None

will only export the given image. Defaults to None.

None
mark_in int | None

start frame to render. Defaults to None.

None
mark_out int | None

end frame to render. Defaults to None.

None
Source code in pytvpaint/george/grg_clip.py
451
452
453
454
455
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
def tv_clip_save_structure_psd(
    export_path: Path | str,
    mode: PSDSaveMode,
    image: int | None = None,
    mark_in: int | None = None,
    mark_out: int | None = None,
) -> None:
    """Save the current clip as a PSD.

    Args:
        export_path: _description_
        mode: all will export all layers to a single PSD
        image: will only export the given image. Defaults to None.
        mark_in: start frame to render. Defaults to None.
        mark_out: end frame to render. Defaults to None.
    """
    export_path = Path(export_path)

    if not export_path.parent.exists():
        raise ValueError(
            "Can't write file because the destination folder doesn't exist"
        )

    args_dict: dict[str, str | int | None]

    if mode == PSDSaveMode.ALL:
        args_dict = {"mode": "all"}
    elif mode == PSDSaveMode.IMAGE:
        if image is None:
            raise ValueError("Image must be defined")
        args_dict = {"image": image}
    else:  # Markin
        if mark_in is None or mark_out is None:
            raise ValueError("mark_in and mark_out must be defined")
        args_dict = {"markin": mark_in, "markout": mark_out}

    args = args_dict_to_list(args_dict)

    send_cmd(
        "tv_ClipSaveStructure",
        export_path.as_posix(),
        "PSD",
        *args,
        error_values=[-1],
    )

tv_clip_save_structure_csv(export_path: Path | str, all_images: bool | None = None, exposure_label: str | None = None) -> None

Save the current clip as a CSV.

Parameters:

Name Type Description Default
export_path pathlib.Path | str

the .csv export path

required
all_images bool | None

export all images or only instances. Defaults to None.

None
exposure_label str | None

give a label when the image is an exposure. Defaults to None.

None
Source code in pytvpaint/george/grg_clip.py
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
def tv_clip_save_structure_csv(
    export_path: Path | str,
    all_images: bool | None = None,
    exposure_label: str | None = None,
) -> None:
    """Save the current clip as a CSV.

    Args:
        export_path: the .csv export path
        all_images: export all images or only instances. Defaults to None.
        exposure_label: give a label when the image is an exposure. Defaults to None.
    """
    export_path = Path(export_path)

    args = args_dict_to_list(
        {
            "allimages": int(bool(all_images)),
            "exposurelabel": exposure_label,
        }
    )

    send_cmd(
        "tv_ClipSaveStructure",
        export_path.as_posix(),
        "CSV",
        *args,
        error_values=[-1],
    )

tv_clip_save_structure_sprite(export_path: Path | str, layout: SpriteLayout | None = None, space: int | None = None) -> None

Save the current clip as sprites in one image.

Parameters:

Name Type Description Default
export_path pathlib.Path | str

the export path of the sprite image

required
layout pytvpaint.george.grg_base.SpriteLayout | None

the sprite layout. Defaults to None.

None
space int | None

the space between each sprite in the image. Defaults to None.

None
Source code in pytvpaint/george/grg_clip.py
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
def tv_clip_save_structure_sprite(
    export_path: Path | str,
    layout: SpriteLayout | None = None,
    space: int | None = None,
) -> None:
    """Save the current clip as sprites in one image.

    Args:
        export_path: the export path of the sprite image
        layout: the sprite layout. Defaults to None.
        space: the space between each sprite in the image. Defaults to None.
    """
    export_path = Path(export_path)

    args = args_dict_to_list(
        {
            "layout": layout.value if layout is not None else None,
            "space": space,
        }
    )

    send_cmd(
        "tv_ClipSaveStructure",
        export_path.as_posix(),
        "sprite",
        *args,
        error_values=[-1],
    )

tv_clip_save_structure_flix(export_path: Path | str, mark_in: int | None = None, mark_out: int | None = None, parameters_import: str | None = None, parameters_file: str | None = None, send: bool | None = None, original_file: str | Path | None = None) -> None

Save the current clip for Flix.

Parameters:

Name Type Description Default
export_path pathlib.Path | str

the .xml export path

required
mark_in int | None

the start frame to render. Defaults to None.

None
mark_out int | None

the end frame to render. Defaults to None.

None
parameters_import str | None

the attribute(s) of the global tag (waitForSource/...). Defaults to None.

None
parameters_file str | None

the attribute(s) of each (file) tag (dialogue/...). Defaults to None.

None
send bool | None

open a browser with the prefilled url. Defaults to None.

None
original_file str | pathlib.Path | None

the original reference tvpp file path. Defaults to None.

None
Source code in pytvpaint/george/grg_clip.py
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
def tv_clip_save_structure_flix(
    export_path: Path | str,
    mark_in: int | None = None,
    mark_out: int | None = None,
    parameters_import: str | None = None,
    parameters_file: str | None = None,
    send: bool | None = None,
    original_file: str | Path | None = None,
) -> None:
    """Save the current clip for Flix.

    Args:
        export_path: the .xml export path
        mark_in: the start frame to render. Defaults to None.
        mark_out: the end frame to render. Defaults to None.
        parameters_import: the attribute(s) of the global <flixImport> tag (waitForSource/...). Defaults to None.
        parameters_file: the attribute(s) of each <image> (file) tag (dialogue/...). Defaults to None.
        send: open a browser with the prefilled url. Defaults to None.
        original_file: the original reference tvpp file path. Defaults to None.
    """
    export_path = Path(export_path)

    args_dict = {
        "markin": mark_in,
        "markout": mark_out,
        "parametersimport": parameters_import,
        "parametersfile": parameters_file,
        "send": int(send) if send else None,
        "originalfile": Path(original_file).as_posix() if original_file else None,
    }

    args = args_dict_to_list(args_dict)

    send_cmd(
        "tv_ClipSaveStructure",
        export_path.as_posix(),
        "Flix",
        *args,
        error_values=[-1],
    )

tv_sound_clip_info(clip_id: int, track_index: int) -> TVPSound

Get information about a soundtrack.

Source code in pytvpaint/george/grg_clip.py
600
601
602
603
604
def tv_sound_clip_info(clip_id: int, track_index: int) -> TVPSound:
    """Get information about a soundtrack."""
    res = send_cmd("tv_SoundClipInfo", clip_id, track_index, error_values=[-1, -2, -3])
    res_parse = tv_parse_list(res, with_fields=TVPSound)
    return TVPSound(**res_parse)

tv_sound_clip_new(sound_path: Path | str) -> None

Add a new soundtrack.

Source code in pytvpaint/george/grg_clip.py
607
608
609
610
611
612
def tv_sound_clip_new(sound_path: Path | str) -> None:
    """Add a new soundtrack."""
    path = Path(sound_path)
    if not path.exists():
        raise ValueError(f"Sound file not found at : {path.as_posix()}")
    send_cmd("tv_SoundClipNew", path.as_posix(), error_values=[-1, -2, -3, -4])

tv_sound_clip_remove(track_index: int) -> None

Remove a soundtrack.

Source code in pytvpaint/george/grg_clip.py
615
616
617
def tv_sound_clip_remove(track_index: int) -> None:
    """Remove a soundtrack."""
    send_cmd("tv_SoundClipRemove", track_index, error_values=[-2])

tv_sound_clip_reload(clip_id: int, track_index: int) -> None

Reload a soundtrack from its file.

Parameters:

Name Type Description Default
clip_id int

the clip id (only works with 0 being the current clip)

required
track_index int

the sound clip track index

required
Warning

this doesn't accept a proper clip id, only 0 seem to work for the current clip

Source code in pytvpaint/george/grg_clip.py
620
621
622
623
624
625
626
627
628
629
630
def tv_sound_clip_reload(clip_id: int, track_index: int) -> None:
    """Reload a soundtrack from its file.

    Args:
        clip_id: the clip id (only works with `0` being the current clip)
        track_index: the sound clip track index

    Warning:
        this doesn't accept a proper clip id, only `0` seem to work for the current clip
    """
    send_cmd("tv_SoundClipReload", clip_id, track_index, error_values=[-1, -2, -3])

tv_sound_clip_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 a soundtracks settings.

Source code in pytvpaint/george/grg_clip.py
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
def tv_sound_clip_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 a soundtracks settings."""
    cur_options = tv_sound_clip_info(tv_clip_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_SoundClipAdjust", track_index, *args, error_values=[-2, -3])

tv_layer_image_get() -> int

Get the current frame of the current clip.

Source code in pytvpaint/george/grg_clip.py
664
665
666
def tv_layer_image_get() -> int:
    """Get the current frame of the current clip."""
    return int(send_cmd("tv_LayerGetImage"))

tv_layer_image(frame: int) -> None

Set the current frame of the current clip.

Source code in pytvpaint/george/grg_clip.py
669
670
671
def tv_layer_image(frame: int) -> None:
    """Set the current frame of the current clip."""
    send_cmd("tv_LayerImage", frame)