Skip to content

Layer related George functions

Layer related George functions and enums.

LayerColorAction

Bases: enum.Enum

tv_layercolor actions.

Attributes:

Name Type Description
GETCOLOR
SETCOLOR
GET
SET
LOCK
UNLOCK
SHOW
HIDE
VISIBLE
SELECT
UNSELECT

GETCOLOR = 'getcolor' class-attribute instance-attribute

SETCOLOR = 'setcolor' class-attribute instance-attribute

GET = 'get' class-attribute instance-attribute

SET = 'set' class-attribute instance-attribute

LOCK = 'lock' class-attribute instance-attribute

UNLOCK = 'unlock' class-attribute instance-attribute

SHOW = 'show' class-attribute instance-attribute

HIDE = 'hide' class-attribute instance-attribute

VISIBLE = 'visible' class-attribute instance-attribute

SELECT = 'select' class-attribute instance-attribute

UNSELECT = 'unselect' class-attribute instance-attribute

LayerColorDisplayOpt

Bases: enum.Enum

tv_layercolorshow display options.

Attributes:

Name Type Description
DISPLAY

Activate the layers to show them in the display

TIMELINE

Uncollpase layers from maximum collapse (2px height) in the timeline

DISPLAY = 'display' class-attribute instance-attribute

TIMELINE = 'timeline' class-attribute instance-attribute

InstanceNamingMode

Bases: enum.Enum

tv_instancename naming modes.

Attributes:

Name Type Description
ALL
SMART

ALL = 'all' class-attribute instance-attribute

SMART = 'smart' class-attribute instance-attribute

InstanceNamingProcess

Bases: enum.Enum

tv_instancename naming process.

Attributes:

Name Type Description
EMPTY
NUMBER
TEXT

EMPTY = 'empty' class-attribute instance-attribute

NUMBER = 'number' class-attribute instance-attribute

TEXT = 'text' class-attribute instance-attribute

LayerType

Bases: enum.Enum

All the layer types.

Attributes:

Name Type Description
IMAGE
SEQUENCE
XSHEET
SCRIBBLES
FOLDER
CAMERA

IMAGE = 'image' class-attribute instance-attribute

SEQUENCE = 'sequence' class-attribute instance-attribute

XSHEET = 'xsheet' class-attribute instance-attribute

SCRIBBLES = 'scribbles' class-attribute instance-attribute

FOLDER = 'folder' class-attribute instance-attribute

CAMERA = 'camera' class-attribute instance-attribute

StencilMode

Bases: enum.Enum

All the stencil modes.

Attributes:

Name Type Description
ON
OFF
NORMAL
INVERT

ON = 'on' class-attribute instance-attribute

OFF = 'off' class-attribute instance-attribute

NORMAL = 'normal' class-attribute instance-attribute

INVERT = 'invert' class-attribute instance-attribute

LayerBehavior

Bases: enum.Enum

Layer behaviors on boundaries.

Attributes:

Name Type Description
NONE
REPEAT
PINGPONG
HOLD

NONE = 'none' class-attribute instance-attribute

REPEAT = 'repeat' class-attribute instance-attribute

PINGPONG = 'pingpong' class-attribute instance-attribute

HOLD = 'hold' class-attribute instance-attribute

LayerTransparency

Bases: enum.Enum

Layer transparency values.

Attributes:

Name Type Description
ON
OFF
MINUS_1
NONE

ON = 'on' class-attribute instance-attribute

OFF = 'off' class-attribute instance-attribute

MINUS_1 = '-1' class-attribute instance-attribute

NONE = 'none' class-attribute instance-attribute

InsertDirection

Bases: enum.Enum

Instance insert direction.

Attributes:

Name Type Description
BEFORE
AFTER

BEFORE = 'before' class-attribute instance-attribute

AFTER = 'after' class-attribute instance-attribute

TVPClipLayerColor(clip_id: int, color_index: int, color_r: int, color_g: int, color_b: int, name: str) dataclass

Clip layer color values.

clip_id: int instance-attribute

color_index: int instance-attribute

color_r: int instance-attribute

color_g: int instance-attribute

color_b: int instance-attribute

name: str instance-attribute

TVPLayer(id: int, visibility: bool, position: int, density: int, name: str, type: LayerType, first_frame: int, last_frame: int, selected: bool, editable: bool, stencil_state: StencilMode) dataclass

TVPaint layer info values.

id: int = field(metadata={'parsed': False}) class-attribute instance-attribute

visibility: bool instance-attribute

position: int instance-attribute

density: int instance-attribute

name: str instance-attribute

type: LayerType instance-attribute

first_frame: int instance-attribute

last_frame: int instance-attribute

selected: bool instance-attribute

editable: bool instance-attribute

stencil_state: StencilMode instance-attribute

tv_layer_current_id() -> int

Get the id of the current layer.

Source code in pytvpaint/george/grg_layer.py
206
207
208
def tv_layer_current_id() -> int:
    """Get the id of the current layer."""
    return int(send_cmd("tv_LayerCurrentId"))

tv_layer_get_id(position: int) -> int

Get the id of the layer at the given position.

Raises:

Type Description
pytvpaint.george.exceptions.GeorgeError

if no layer found at the provided position

Source code in pytvpaint/george/grg_layer.py
211
212
213
214
215
216
217
218
219
@try_cmd(exception_msg="No layer at provided position")
def tv_layer_get_id(position: int) -> int:
    """Get the id of the layer at the given position.

    Raises:
        GeorgeError: if no layer found at the provided position
    """
    result = send_cmd("tv_LayerGetID", position, error_values=[GrgErrorValue.NONE])
    return int(result)

tv_layer_get_pos(layer_id: int) -> int

Get the position of the given layer.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id

Source code in pytvpaint/george/grg_layer.py
222
223
224
225
226
227
228
229
230
231
232
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid layer id",
)
def tv_layer_get_pos(layer_id: int) -> int:
    """Get the position of the given layer.

    Raises:
        NoObjectWithIdError: if given an invalid layer id
    """
    return int(send_cmd("tv_LayerGetPos", layer_id, error_values=[GrgErrorValue.NONE]))

tv_layer_info(layer_id: int) -> TVPLayer

Get information of the given layer.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id

Source code in pytvpaint/george/grg_layer.py
235
236
237
238
239
240
241
242
243
244
245
246
247
248
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid layer id",
)
def tv_layer_info(layer_id: int) -> TVPLayer:
    """Get information of the given layer.

    Raises:
        NoObjectWithIdError: if given an invalid layer id
    """
    result = send_cmd("tv_LayerInfo", layer_id, error_values=[GrgErrorValue.EMPTY])
    layer = tv_parse_list(result, with_fields=TVPLayer, unused_indices=[7, 8])
    layer["id"] = layer_id
    return TVPLayer(**layer)

tv_layer_move(position: int, folder_id: int | None = None) -> None

Move the current layer to a new position in the layer stack.

Parameters:

Name Type Description Default
position int

position to move layer to

required
folder_id int | None

parent folder id

None

Raises:

Type Description
pytvpaint.george.exceptions.GeorgeError

if layer could not be moved

Source code in pytvpaint/george/grg_layer.py
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
@try_cmd(exception_msg="Couldn't move current layer to position")
def tv_layer_move(position: int, folder_id: int | None = None) -> None:
    """Move the current layer to a new position in the layer stack.

    Args:
        position: position to move layer to
        folder_id: parent folder id

    Raises:
        GeorgeError: if layer could not be moved
    """
    if folder_id is not None and is_tvp_version_below_12():
        log.warning("`folder_id` option is only available in TVPaint version 12 and above.")

    args = [position]
    if not is_tvp_version_below_12() and folder_id:
        args.append(folder_id)

    send_cmd("tv_LayerMove", *args)

tv_layer_set(layer_id: int) -> None

Make the given layer the current one.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id

Source code in pytvpaint/george/grg_layer.py
272
273
274
275
276
277
278
279
280
281
282
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid layer id",
)
def tv_layer_set(layer_id: int) -> None:
    """Make the given layer the current one.

    Raises:
        NoObjectWithIdError: if given an invalid layer id
    """
    send_cmd("tv_LayerSet", layer_id)

tv_layer_selection_get(layer_id: int) -> bool

Get the selection state of a layer.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id

Source code in pytvpaint/george/grg_layer.py
285
286
287
288
289
290
291
292
293
@try_cmd(raise_exc=NoObjectWithIdError, exception_msg="Invalid layer id")
def tv_layer_selection_get(layer_id: int) -> bool:
    """Get the selection state of a layer.

    Raises:
        NoObjectWithIdError: if given an invalid layer id
    """
    res = send_cmd("tv_LayerSelection", layer_id, error_values=[-1])
    return tv_cast_to_type(res, bool)

tv_layer_selection_set(layer_id: int, new_state: bool) -> None

Set the selection state of a layer.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id

Source code in pytvpaint/george/grg_layer.py
296
297
298
299
300
301
302
303
@try_cmd(raise_exc=NoObjectWithIdError, exception_msg="Invalid layer id")
def tv_layer_selection_set(layer_id: int, new_state: bool) -> None:
    """Set the selection state of a layer.

    Raises:
        NoObjectWithIdError: if given an invalid layer id
    """
    send_cmd("tv_LayerSelection", layer_id, int(new_state), error_values=[-1])

tv_layer_select(start_frame: int, frame_count: int) -> int

Select frames in the current layer.

Parameters:

Name Type Description Default
start_frame int

selection start

required
frame_count int

number of frames to select

required

Returns:

Name Type Description
int int

number of frames selected

Note

If the start position is before the beginning of the layer, the selection will only start at the beginning of the layer, but its length will be measured from the start position. This means that if you ask for a selection of 15 frames starting from position 0 in a layer that actually starts at position 5, only the first 10 frames in the layer will be selected. If the selection goes beyond the end of the layer, it will only include the frames between the start and end of the layer. No frames will be selected if the start position is beyond the end of the layer

Source code in pytvpaint/george/grg_layer.py
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
def tv_layer_select(start_frame: int, frame_count: int) -> int:
    """Select frames in the current layer.

    Args:
        start_frame: selection start
        frame_count: number of frames to select

    Returns:
        int: number of frames selected

    Note:
        If the start position is before the beginning of the layer, the selection will only start at the beginning of
        the layer, but its length will be measured from the start position.
        This means that if you ask for a selection of 15 frames starting from position 0 in a layer that actually
        starts at position 5, only the first 10 frames in the layer will be selected.
        If the selection goes beyond the end of the layer, it will only include the frames between the start and end of
        the layer. No frames will be selected if the start position is beyond the end of the layer
    """
    return int(send_cmd("tv_LayerSelect", start_frame, frame_count, error_values=[-1]))

tv_layer_select_info(full: bool = False) -> tuple[int, int]

Get Selected frames in a layer.

Parameters:

Name Type Description Default
full bool

returns the layers full range (from the first to the last instance), even on a non anim/ctg layer

False

Returns:

Name Type Description
frame int

the start frame of the selection. If full is set to True will return the first frame in the layer

count int

the number of frames in the selection. If full is set to True will return the number of frames in the layer

Bug

The official documentation states that this functions selects the layer frames, it does not, it simply returns the frames selected. This will also return all frames in the layer even if they are not selected if the argument full is set to True. We advise using tv_layer_select to select your frames and only using this function to get the selected frames.

Source code in pytvpaint/george/grg_layer.py
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
def tv_layer_select_info(full: bool = False) -> tuple[int, int]:
    """Get Selected frames in a layer.

    Args:
        full:  returns the layers full range (from the first to the last instance), even on a non anim/ctg layer

    Returns:
        frame: the start frame of the selection. If full is set to True will return the first frame in the layer
        count: the number of frames in the selection. If full is set to True will return the number of frames in the layer

    Bug:
        The official documentation states that this functions selects the layer frames, it does not, it simply
        returns the frames selected. This will also return all frames in the layer even if they are not selected if the
        argument `full` is set to True. We advise using `tv_layer_select` to select your frames and only using this
        function to get the selected frames.
    """
    args = ["full"] if full else []
    res = send_cmd("tv_layerSelectInfo", *args)
    frame, count = tuple(map(int, res.split(" ")))
    return frame, count

tv_layer_create(name: str, layer_type: int = 1) -> int

Create a new image layer with the given name.

Parameters:

Name Type Description Default
name str

layer name

required
layer_type int

1 for normal layer, 0 for Folder layer (only available for TVPaint 12 and above)

1

Returns:

Name Type Description
layer_id int

the id of the newly created layer.

Source code in pytvpaint/george/grg_layer.py
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
def tv_layer_create(name: str, layer_type: int = 1) -> int:
    """Create a new image layer with the given name.

    Args:
        name: layer name
        layer_type: 1 for normal layer, 0 for Folder layer (only available for TVPaint 12 and above)

    Returns:
        layer_id: the id of the newly created layer.
    """
    if layer_type != 1 and is_tvp_version_below_12():
        log.warning("`layer_type` selection is only available in TVPaint version 12 and above.")

    args = [name]
    if not is_tvp_version_below_12():
        args.append(str(layer_type))
        if not name:
            log.warning(
                "You should provide a name for the layer, "
                "otherwise tvpaint will consider that the layer type is the name."
            )

    return int(send_cmd("tv_LayerCreate", *args))

tv_layer_duplicate(name: str) -> int

Duplicate the current layer and make it the current one.

Source code in pytvpaint/george/grg_layer.py
374
375
376
def tv_layer_duplicate(name: str) -> int:
    """Duplicate the current layer and make it the current one."""
    return int(send_cmd("tv_LayerDuplicate", name))

tv_layer_rename(layer_id: int, name: str) -> str

Rename a layer.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id.

Warning

This function does not seem to work in TVPaint 12.

Returns:

Name Type Description
str str

new name

Source code in pytvpaint/george/grg_layer.py
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid layer id",
)
def tv_layer_rename(layer_id: int, name: str) -> str:
    """Rename a layer.

    Raises:
        NoObjectWithIdError: if given an invalid layer id.

    Warning:
        This function does not seem to work in TVPaint 12.

    Returns:
        str: new name
    """
    if not is_tvp_version_below_12():
        log.warning("function `tv_LayerRename` does not seem to work properly in TVPaint 12")
    return send_cmd("tv_LayerRename", layer_id, name, error_values=[-1])

tv_layer_kill(layer_id: int) -> None

Delete the layer with provided id.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id

Source code in pytvpaint/george/grg_layer.py
400
401
402
403
404
405
406
407
408
409
410
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid layer id",
)
def tv_layer_kill(layer_id: int) -> None:
    """Delete the layer with provided id.

    Raises:
        NoObjectWithIdError: if given an invalid layer id
    """
    send_cmd("tv_LayerKill", layer_id)

tv_layer_folder_delete(layer_id: int, remove_children: bool) -> None

Delete the layer with provided id.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id

NotImplemented

if used in tvpaint version inferior to 12

Source code in pytvpaint/george/grg_layer.py
413
414
415
416
417
418
419
420
421
422
423
424
425
@min_version_compatible(min_version="12")
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid layer id",
)
def tv_layer_folder_delete(layer_id: int, remove_children: bool) -> None:
    """Delete the layer with provided id.

    Raises:
        NoObjectWithIdError: if given an invalid layer id
        NotImplemented: if used in tvpaint version inferior to 12
    """
    send_cmd("tv_LayerFolderDelete", layer_id, int(not remove_children))

tv_layer_density_get() -> int

Get the current layer density (opacity).

Source code in pytvpaint/george/grg_layer.py
428
429
430
def tv_layer_density_get() -> int:
    """Get the current layer density (opacity)."""
    return int(send_cmd("tv_LayerDensity"))

tv_layer_density_set(new_density: int) -> None

Set the current layer density (opacity ranging from 0 to 100).

Source code in pytvpaint/george/grg_layer.py
433
434
435
def tv_layer_density_set(new_density: int) -> None:
    """Set the current layer density (opacity ranging from 0 to 100)."""
    send_cmd("tv_LayerDensity", new_density)

tv_layer_display_get(layer_id: int) -> bool

Get the visibility of the given layer.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id

Source code in pytvpaint/george/grg_layer.py
438
439
440
441
442
443
444
445
446
447
448
449
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid layer id",
)
def tv_layer_display_get(layer_id: int) -> bool:
    """Get the visibility of the given layer.

    Raises:
        NoObjectWithIdError: if given an invalid layer id
    """
    res = send_cmd("tv_LayerDisplay", layer_id, error_values=[0])
    return tv_cast_to_type(res.lower(), bool)

tv_layer_display_set(layer_id: int, new_state: bool, light_table: bool = False) -> None

Set the visibility of the given layer.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id

Source code in pytvpaint/george/grg_layer.py
452
453
454
455
456
457
458
459
460
461
462
463
464
465
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid layer id",
)
def tv_layer_display_set(layer_id: int, new_state: bool, light_table: bool = False) -> None:
    """Set the visibility of the given layer.

    Raises:
        NoObjectWithIdError: if given an invalid layer id
    """
    args: list[Any] = [layer_id, int(new_state)]
    if light_table:
        args.insert(1, "lighttable")
    send_cmd("tv_LayerDisplay", *args, error_values=[0])

tv_layer_lock_get(layer_id: int) -> bool

Get the lock state of the given layer.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id

Source code in pytvpaint/george/grg_layer.py
468
469
470
471
472
473
474
475
476
477
478
479
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid layer id",
)
def tv_layer_lock_get(layer_id: int) -> bool:
    """Get the lock state of the given layer.

    Raises:
        NoObjectWithIdError: if given an invalid layer id
    """
    res = send_cmd("tv_LayerLock", layer_id, error_values=[GrgErrorValue.ERROR])
    return tv_cast_to_type(res.lower(), bool)

tv_layer_lock_set(layer_id: int, new_state: bool) -> None

Set the lock state of the given layer.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id

Source code in pytvpaint/george/grg_layer.py
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid layer id",
)
def tv_layer_lock_set(layer_id: int, new_state: bool) -> None:
    """Set the lock state of the given layer.

    Raises:
        NoObjectWithIdError: if given an invalid layer id
    """
    send_cmd(
        "tv_LayerLock",
        layer_id,
        int(new_state),
        error_values=[GrgErrorValue.ERROR],
    )

tv_layer_collapse_get(layer_id: int) -> bool

Get the collapse mode of the given layer.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id

Source code in pytvpaint/george/grg_layer.py
500
501
502
503
504
505
506
507
508
509
510
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid layer id",
)
def tv_layer_collapse_get(layer_id: int) -> bool:
    """Get the collapse mode of the given layer.

    Raises:
        NoObjectWithIdError: if given an invalid layer id
    """
    return bool(int(send_cmd("tv_LayerCollapse", layer_id, error_values=[-2])))

tv_layer_collapse_set(layer_id: int, new_state: bool) -> None

Set the collapse mode of the given layer.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id

Source code in pytvpaint/george/grg_layer.py
513
514
515
516
517
518
519
520
521
522
523
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid layer id",
)
def tv_layer_collapse_set(layer_id: int, new_state: bool) -> None:
    """Set the collapse mode of the given layer.

    Raises:
        NoObjectWithIdError: if given an invalid layer id
    """
    send_cmd("tv_LayerCollapse", layer_id, int(new_state), error_values=[-2])

tv_layer_blending_mode_get(layer_id: int) -> BlendingMode

Get the blending mode of the given layer.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id

Source code in pytvpaint/george/grg_layer.py
526
527
528
529
530
531
532
533
534
535
536
537
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid layer id",
)
def tv_layer_blending_mode_get(layer_id: int) -> BlendingMode:
    """Get the blending mode of the given layer.

    Raises:
        NoObjectWithIdError: if given an invalid layer id
    """
    res = send_cmd("tv_LayerBlendingMode", layer_id)
    return tv_cast_to_type(res.lower(), BlendingMode)

tv_layer_blending_mode_set(layer_id: int, mode: BlendingMode) -> None

Set the blending mode of the given layer.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id

Source code in pytvpaint/george/grg_layer.py
540
541
542
543
544
545
546
547
548
549
550
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid layer id",
)
def tv_layer_blending_mode_set(layer_id: int, mode: BlendingMode) -> None:
    """Set the blending mode of the given layer.

    Raises:
        NoObjectWithIdError: if given an invalid layer id
    """
    send_cmd("tv_LayerBlendingMode", layer_id, mode.value)

tv_layer_stencil_get(layer_id: int) -> StencilMode

Get the stencil state and mode of the given layer.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id

Source code in pytvpaint/george/grg_layer.py
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid layer id",
)
def tv_layer_stencil_get(layer_id: int) -> StencilMode:
    """Get the stencil state and mode of the given layer.

    Raises:
        NoObjectWithIdError: if given an invalid layer id
    """
    res = send_cmd("tv_LayerStencil", layer_id)
    _, state, mode = res.split(" ")

    if state == "off":
        return StencilMode.OFF

    return tv_cast_to_type(mode, StencilMode)

tv_layer_stencil_set(layer_id: int, mode: StencilMode) -> None

Set the stencil state and mode of the given layer.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id

Source code in pytvpaint/george/grg_layer.py
572
573
574
575
576
577
578
579
580
581
582
583
584
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid layer id",
)
def tv_layer_stencil_set(layer_id: int, mode: StencilMode) -> None:
    """Set the stencil state and mode of the given layer.

    Raises:
        NoObjectWithIdError: if given an invalid layer id
    """
    args = [mode.value] if mode in [StencilMode.ON, StencilMode.OFF] else ["on", mode.value]

    send_cmd("tv_LayerStencil", layer_id, *args)

tv_layer_show_thumbnails_get(layer_id: int) -> bool

Get the show thumbnails state for a layer.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id

Source code in pytvpaint/george/grg_layer.py
587
588
589
590
591
592
593
594
595
596
597
598
599
600
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid layer id",
)
def tv_layer_show_thumbnails_get(
    layer_id: int,
) -> bool:
    """Get the show thumbnails state for a layer.

    Raises:
        NoObjectWithIdError: if given an invalid layer id
    """
    res = send_cmd("tv_LayerShowThumbnails", layer_id, error_values=[GrgErrorValue.ERROR])
    return res == "1"

tv_layer_show_thumbnails_set(layer_id: int, state: bool) -> None

Set the show thumbnail state for a layer.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id

Source code in pytvpaint/george/grg_layer.py
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid layer id",
)
def tv_layer_show_thumbnails_set(
    layer_id: int,
    state: bool,
) -> None:
    """Set the show thumbnail state for a layer.

    Raises:
        NoObjectWithIdError: if given an invalid layer id
    """
    send_cmd(
        "tv_LayerShowThumbnails",
        layer_id,
        int(state),
        error_values=[GrgErrorValue.ERROR],
    )

tv_layer_auto_break_instance_get(layer_id: int) -> bool

Get the layer auto break instance value for a layer.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id

Source code in pytvpaint/george/grg_layer.py
624
625
626
627
628
629
630
631
632
633
634
635
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid layer id",
)
def tv_layer_auto_break_instance_get(layer_id: int) -> bool:
    """Get the layer auto break instance value for a layer.

    Raises:
        NoObjectWithIdError: if given an invalid layer id
    """
    res = send_cmd("tv_LayerAutoBreakInstance", layer_id, error_values=[-1, -2, -3])
    return res == "1"

tv_layer_auto_break_instance_set(layer_id: int, state: bool) -> None

Set the layer auto break instance value for a layer.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id

Source code in pytvpaint/george/grg_layer.py
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid layer id",
)
def tv_layer_auto_break_instance_set(
    layer_id: int,
    state: bool,
) -> None:
    """Set the layer auto break instance value for a layer.

    Raises:
        NoObjectWithIdError: if given an invalid layer id
    """
    send_cmd(
        "tv_LayerAutoBreakInstance",
        layer_id,
        int(state),
        error_values=[-1, -2, -3],
    )

tv_layer_auto_create_instance_get(layer_id: int) -> bool

Get the layer auto create instance value for a layer.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id

Source code in pytvpaint/george/grg_layer.py
659
660
661
662
663
664
665
666
667
668
669
670
671
672
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid layer id",
)
def tv_layer_auto_create_instance_get(
    layer_id: int,
) -> bool:
    """Get the layer auto create instance value for a layer.

    Raises:
        NoObjectWithIdError: if given an invalid layer id
    """
    res = send_cmd("tv_LayerAutoCreateInstance", layer_id, error_values=[-1, -2, -3])
    return res == "1"

tv_layer_auto_create_instance_set(layer_id: int, state: bool) -> None

Set the layer auto create instance value for a layer.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id

Source code in pytvpaint/george/grg_layer.py
675
676
677
678
679
680
681
682
683
684
685
686
687
688
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid layer id",
)
def tv_layer_auto_create_instance_set(
    layer_id: int,
    state: bool,
) -> None:
    """Set the layer auto create instance value for a layer.

    Raises:
        NoObjectWithIdError: if given an invalid layer id
    """
    send_cmd("tv_LayerAutoCreateInstance", layer_id, int(state), error_values=[-1, -2, -3])

tv_layer_pre_behavior_get(layer_id: int) -> LayerBehavior

Get the pre-behavior value for a layer.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id

Source code in pytvpaint/george/grg_layer.py
691
692
693
694
695
696
697
698
699
700
701
702
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid layer id",
)
def tv_layer_pre_behavior_get(layer_id: int) -> LayerBehavior:
    """Get the pre-behavior value for a layer.

    Raises:
        NoObjectWithIdError: if given an invalid layer id
    """
    res = send_cmd("tv_LayerPreBehavior", layer_id)
    return tv_cast_to_type(res, LayerBehavior)

tv_layer_pre_behavior_set(layer_id: int, behavior: LayerBehavior) -> None

Set the pre-behavior value for a layer.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id

Source code in pytvpaint/george/grg_layer.py
705
706
707
708
709
710
711
712
713
714
715
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid layer id",
)
def tv_layer_pre_behavior_set(layer_id: int, behavior: LayerBehavior) -> None:
    """Set the pre-behavior value for a layer.

    Raises:
        NoObjectWithIdError: if given an invalid layer id
    """
    send_cmd("tv_LayerPreBehavior", layer_id, behavior.value)

tv_layer_post_behavior_get(layer_id: int) -> LayerBehavior

Get the post-behavior value for a layer.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id

Source code in pytvpaint/george/grg_layer.py
718
719
720
721
722
723
724
725
726
727
728
729
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid layer id",
)
def tv_layer_post_behavior_get(layer_id: int) -> LayerBehavior:
    """Get the post-behavior value for a layer.

    Raises:
        NoObjectWithIdError: if given an invalid layer id
    """
    res = send_cmd("tv_LayerPostBehavior", layer_id)
    return tv_cast_to_type(res, LayerBehavior)

tv_layer_post_behavior_set(layer_id: int, behavior: LayerBehavior) -> None

Set the post-behavior value for a layer.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id

Source code in pytvpaint/george/grg_layer.py
732
733
734
735
736
737
738
739
740
741
742
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid layer id",
)
def tv_layer_post_behavior_set(layer_id: int, behavior: LayerBehavior) -> None:
    """Set the post-behavior value for a layer.

    Raises:
        NoObjectWithIdError: if given an invalid layer id
    """
    send_cmd("tv_LayerPostBehavior", layer_id, behavior.value)

tv_layer_lock_position_get(layer_id: int) -> bool

Get the lock position state of a layer.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id

Source code in pytvpaint/george/grg_layer.py
745
746
747
748
749
750
751
752
753
754
755
756
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid layer id",
)
def tv_layer_lock_position_get(layer_id: int) -> bool:
    """Get the lock position state of a layer.

    Raises:
        NoObjectWithIdError: if given an invalid layer id
    """
    res = send_cmd("tv_LayerLockPosition", layer_id)
    return tv_cast_to_type(res, bool)

tv_layer_lock_position_set(layer_id: int, state: bool) -> None

Set the lock position state of a layer.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id

Source code in pytvpaint/george/grg_layer.py
759
760
761
762
763
764
765
766
767
768
769
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid layer id",
)
def tv_layer_lock_position_set(layer_id: int, state: bool) -> None:
    """Set the lock position state of a layer.

    Raises:
        NoObjectWithIdError: if given an invalid layer id
    """
    send_cmd("tv_LayerLockPosition", layer_id, int(state))

tv_preserve_get() -> LayerTransparency

Get the preserve transparency state of the current layer.

Source code in pytvpaint/george/grg_layer.py
772
773
774
775
776
def tv_preserve_get() -> LayerTransparency:
    """Get the preserve transparency state of the current layer."""
    res = send_cmd("tv_Preserve")
    _, state = res.split(" ")
    return tv_cast_to_type(state, LayerTransparency)

tv_preserve_set(state: LayerTransparency) -> None

Set the preserve transparency state of the current layer.

Warning

This function does not seem to work in TVPaint 12

Source code in pytvpaint/george/grg_layer.py
779
780
781
782
783
784
785
786
787
def tv_preserve_set(state: LayerTransparency) -> None:
    """Set the preserve transparency state of the current layer.

    Warning:
        This function does not seem to work in TVPaint 12
    """
    if not is_tvp_version_below_12():
        log.warning("This function does not seem to work in TVPaint 12")
    send_cmd("tv_Preserve", "alpha", state.value)

tv_layer_mark_get(layer_id: int, frame: int) -> int

Get the mark color of a layer at a frame.

Parameters:

Name Type Description Default
layer_id int

the layer id

required
frame int

the frame with a mark

required

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id

Returns:

Name Type Description
int int

the mark color index

Source code in pytvpaint/george/grg_layer.py
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid layer id",
)
def tv_layer_mark_get(layer_id: int, frame: int) -> int:
    """Get the mark color of a layer at a frame.

    Args:
        layer_id: the layer id
        frame: the frame with a mark

    Raises:
        NoObjectWithIdError: if given an invalid layer id

    Returns:
        int: the mark color index
    """
    res = send_cmd("tv_LayerMarkGet", layer_id, frame, error_values=[-1])
    if is_tvp_version_below_12():
        return int(res)

    index, _, _, _ = tv_cast_to_type(res, tuple[int, ...])
    return index

tv_layer_mark_set(layer_id: int, frame: int, color_index: int) -> None

Set the mark of the layer's frame.

Parameters:

Name Type Description Default
layer_id int

the layer id

required
frame int

the frame to set the mark (use 0 to remove it).

required
color_index int

the mark color

required

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id

Source code in pytvpaint/george/grg_layer.py
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid layer id",
)
def tv_layer_mark_set(layer_id: int, frame: int, color_index: int) -> None:
    """Set the mark of the layer's frame.

    Args:
        layer_id: the layer id
        frame: the frame to set the mark (use 0 to remove it).
        color_index: the mark color

    Raises:
        NoObjectWithIdError: if given an invalid layer id
    """
    send_cmd("tv_LayerMarkSet", layer_id, frame, color_index)

tv_layer_anim(layer_id: int) -> None

Convert the layer to an anim layer.

Source code in pytvpaint/george/grg_layer.py
833
834
835
def tv_layer_anim(layer_id: int) -> None:
    """Convert the layer to an anim layer."""
    send_cmd("tv_LayerAnim", *([layer_id] if layer_id else []))

tv_layer_copy() -> None

Copy the current image or the selected ones.

Source code in pytvpaint/george/grg_layer.py
838
839
840
def tv_layer_copy() -> None:
    """Copy the current image or the selected ones."""
    send_cmd("tv_LayerCopy")

tv_layer_cut() -> None

Cut the current image or the selected ones.

Source code in pytvpaint/george/grg_layer.py
843
844
845
def tv_layer_cut() -> None:
    """Cut the current image or the selected ones."""
    send_cmd("tv_LayerCut")

tv_layer_paste() -> None

Paste the previously copied/cut images to the current layer.

Source code in pytvpaint/george/grg_layer.py
848
849
850
def tv_layer_paste() -> None:
    """Paste the previously copied/cut images to the current layer."""
    send_cmd("tv_LayerPaste")

tv_layer_insert_image(count: int = 1, direction: InsertDirection | None = None, duplicate: bool | None = None) -> None

Add new image(s) before/after the current one and make it current.

Source code in pytvpaint/george/grg_layer.py
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
def tv_layer_insert_image(
    count: int = 1,
    direction: InsertDirection | None = None,
    duplicate: bool | None = None,
) -> None:
    """Add new image(s) before/after the current one and make it current."""
    if duplicate:
        args = [0]
    else:
        args_dict = {
            "count": count,
            "direction": direction.value if direction is not None else None,
        }
        args = args_dict_to_list(args_dict)

    send_cmd("tv_LayerInsertImage", *args)

tv_layer_merge(layer_id: int, blending_mode: BlendingMode, stamp: bool = False, erase: bool = False, keep_color_grp: bool = True, keep_img_mark: bool = True, keep_instance_name: bool = True) -> None

Merge the given layer with the current one.

Parameters:

Name Type Description Default
layer_id int

the layer id

required
blending_mode pytvpaint.george.grg_base.BlendingMode

the blending mode to use

required
stamp bool

Use stamp mode

False
erase bool

Remove the source layer

False
keep_color_grp bool

Keep the color group

True
keep_img_mark bool

Keep the image mark

True
keep_instance_name bool

Keep the instance name

True
Source code in pytvpaint/george/grg_layer.py
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
def tv_layer_merge(
    layer_id: int,
    blending_mode: BlendingMode,
    stamp: bool = False,
    erase: bool = False,
    keep_color_grp: bool = True,
    keep_img_mark: bool = True,
    keep_instance_name: bool = True,
) -> None:
    """Merge the given layer with the current one.

    Args:
        layer_id: the layer id
        blending_mode: the blending mode to use
        stamp: Use stamp mode
        erase: Remove the source layer
        keep_color_grp: Keep the color group
        keep_img_mark: Keep the image mark
        keep_instance_name: Keep the instance name
    """
    args = [
        layer_id,
        blending_mode.value,
    ]

    if stamp:
        args.append("stamp")
    if erase:
        args.append("erase")

    args_dict = {
        "keepcolorgroup": int(keep_color_grp),
        "keepimagemark": int(keep_img_mark),
        "keepinstancename": int(keep_instance_name),
    }
    args.extend(args_dict_to_list(args_dict))

    send_cmd("tv_LayerMerge", layer_id, *args)

tv_layer_merge_all(keep_color_grp: bool = True, keep_img_mark: bool = True, keep_instance_name: bool = True) -> None

Merge all layers.

Parameters:

Name Type Description Default
keep_color_grp bool

Keep the color group

True
keep_img_mark bool

Keep the image mark

True
keep_instance_name bool

Keep the instance name

True
Source code in pytvpaint/george/grg_layer.py
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
def tv_layer_merge_all(
    keep_color_grp: bool = True,
    keep_img_mark: bool = True,
    keep_instance_name: bool = True,
) -> None:
    """Merge all layers.

    Args:
        keep_color_grp: Keep the color group
        keep_img_mark: Keep the image mark
        keep_instance_name: Keep the instance name
    """
    args_dict = {
        "keepcolorgroup": int(keep_color_grp),
        "keepimagemark": int(keep_img_mark),
        "keepinstancename": int(keep_instance_name),
    }
    send_cmd("tv_LayerMergeAll", *args_dict_to_list(args_dict))

tv_layer_shift(layer_id: int, start: int) -> None

Move the layer to a new frame.

Parameters:

Name Type Description Default
layer_id int

layer id

required
start int

frame to shift layer to

required
Source code in pytvpaint/george/grg_layer.py
931
932
933
934
935
936
937
938
def tv_layer_shift(layer_id: int, start: int) -> None:
    """Move the layer to a new frame.

    Args:
        layer_id: layer id
        start: frame to shift layer to
    """
    send_cmd("tv_LayerShift", layer_id, start)

tv_layer_load_dependencies(layer_id: int) -> None

Load all dependencies of the given layer in memory.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id

Source code in pytvpaint/george/grg_layer.py
941
942
943
944
945
946
947
948
949
950
951
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid layer id",
)
def tv_layer_load_dependencies(layer_id: int) -> None:
    """Load all dependencies of the given layer in memory.

    Raises:
        NoObjectWithIdError: if given an invalid layer id
    """
    send_cmd("tv_LayerLoadDependencies", layer_id)

tv_layer_color_get_color(clip_id: int, color_index: int) -> TVPClipLayerColor

Get a specific colors information in the clips color list.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id

Source code in pytvpaint/george/grg_layer.py
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid layer id",
)
def tv_layer_color_get_color(clip_id: int, color_index: int) -> TVPClipLayerColor:
    """Get a specific colors information in the clips color list.

    Raises:
        NoObjectWithIdError: if given an invalid layer id
    """
    result = send_cmd(
        "tv_LayerColor",
        LayerColorAction.GETCOLOR.value,
        clip_id,
        color_index,
        error_values=[GrgErrorValue.ERROR, -1, -2],
    )
    parsed = tv_parse_list(result, with_fields=TVPClipLayerColor)
    return TVPClipLayerColor(**parsed)

tv_layer_color_set_color(clip_id: int, color_index: int, color: RGBColor, name: str | None = None) -> None

Set a specific colors information in the clips color list.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id

Warning

In tvpaint 12, this function will fail when the name argument is provided

Note

The color with index 0 is the "Default" color, and it can't be changed

Source code in pytvpaint/george/grg_layer.py
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid layer id",
)
def tv_layer_color_set_color(
    clip_id: int,
    color_index: int,
    color: RGBColor,
    name: str | None = None,
) -> None:
    """Set a specific colors information in the clips color list.

    Raises:
        NoObjectWithIdError: if given an invalid layer id

    Warning:
        In tvpaint 12, this function will fail when the `name` argument is provided

    Note:
        The color with index 0 is the "Default" color, and it can't be changed
    """
    args: list[Any] = [
        LayerColorAction.SETCOLOR.value,
        clip_id,
        color_index,
        color.r,
        color.g,
        color.b,
    ]

    if name:
        if not is_tvp_version_below_12():
            log.warning("In tvpaint 12, this function will fail when the `name` argument is provided")
        args.append(name)

    send_cmd("tv_LayerColor", *args, error_values=[GrgErrorValue.ERROR])

tv_layer_color_get(layer_id: int) -> int

Get the layer's color index from the clips color list.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id

Source code in pytvpaint/george/grg_layer.py
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid layer id",
)
def tv_layer_color_get(layer_id: int) -> int:
    """Get the layer's color index from the clips color list.

    Raises:
        NoObjectWithIdError: if given an invalid layer id
    """
    res = send_cmd(
        "tv_LayerColor",
        LayerColorAction.GET.value,
        layer_id,
        error_values=[-1],
    )
    if is_tvp_version_below_12():
        return int(res)

    index, _, _, _ = tv_cast_to_type(res, tuple[int, ...])
    return index

tv_layer_color_set(layer_id: int, color_index: int) -> None

Set the layer's color index from the clips color list.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id

Source code in pytvpaint/george/grg_layer.py
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
@try_cmd(raise_exc=NoObjectWithIdError)
def tv_layer_color_set(layer_id: int, color_index: int) -> None:
    """Set the layer's color index from the clips color list.

    Raises:
        NoObjectWithIdError: if given an invalid layer id
    """
    send_cmd(
        "tv_LayerColor",
        LayerColorAction.SET.value,
        layer_id,
        color_index,
        error_values=[-1],
    )

tv_layer_color_lock(color_index: int) -> int

Lock all layers that use the given color index.

Parameters:

Name Type Description Default
color_index int

the layer color index

required

Returns:

Type Description
int

the number of layers locked

Source code in pytvpaint/george/grg_layer.py
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
def tv_layer_color_lock(color_index: int) -> int:
    """Lock all layers that use the given color index.

    Args:
        color_index: the layer color index

    Returns:
        the number of layers locked
    """
    return int(send_cmd("tv_LayerColor", LayerColorAction.LOCK.value, color_index))

tv_layer_color_unlock(color_index: int) -> int

Unlock all layers that use the given color index.

Parameters:

Name Type Description Default
color_index int

the layer color index

required

Returns:

Type Description
int

the number of unlocked layers

Source code in pytvpaint/george/grg_layer.py
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
def tv_layer_color_unlock(color_index: int) -> int:
    """Unlock all layers that use the given color index.

    Args:
        color_index: the layer color index

    Returns:
        the number of unlocked layers
    """
    return int(send_cmd("tv_LayerColor", LayerColorAction.UNLOCK.value, color_index))

tv_layer_color_show(mode: LayerColorDisplayOpt, color_index: int) -> int

Show all layers that use the given color index.

Parameters:

Name Type Description Default
mode pytvpaint.george.grg_layer.LayerColorDisplayOpt

the display mode

required
color_index int

the layer color index

required

Returns:

Type Description
int

the number of unlocked layers

Source code in pytvpaint/george/grg_layer.py
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
def tv_layer_color_show(mode: LayerColorDisplayOpt, color_index: int) -> int:
    """Show all layers that use the given color index.

    Args:
        mode: the display mode
        color_index: the layer color index

    Returns:
        the number of unlocked layers
    """
    res = send_cmd(
        "tv_LayerColor",
        LayerColorAction.SHOW.value,
        mode.value,
        color_index,
        error_values=[GrgErrorValue.ERROR],
    )
    return int(res)

tv_layer_color_hide(mode: LayerColorDisplayOpt, color_index: int) -> int

Hide all layers that use the given color index.

Parameters:

Name Type Description Default
mode pytvpaint.george.grg_layer.LayerColorDisplayOpt

the display mode

required
color_index int

the layer color index

required

Returns:

Type Description
int

the number of unlocked layers

Source code in pytvpaint/george/grg_layer.py
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
def tv_layer_color_hide(mode: LayerColorDisplayOpt, color_index: int) -> int:
    """Hide all layers that use the given color index.

    Args:
        mode: the display mode
        color_index: the layer color index

    Returns:
        the number of unlocked layers
    """
    return int(
        send_cmd(
            "tv_LayerColor",
            LayerColorAction.HIDE.value,
            mode.value,
            color_index,
            error_values=[GrgErrorValue.ERROR],
        )
    )

tv_layer_color_visible(color_index: int) -> bool

Get the visibility of the color index (2px height) in the timeline.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id

Source code in pytvpaint/george/grg_layer.py
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid layer id",
)
def tv_layer_color_visible(color_index: int) -> bool:
    """Get the visibility of the color index (2px height) in the timeline.

    Raises:
        NoObjectWithIdError: if given an invalid layer id
    """
    return bool(
        int(
            send_cmd(
                "tv_LayerColor",
                LayerColorAction.VISIBLE.value,
                color_index,
                error_values=[-1],
            )
        )
    )

tv_layer_color_select(color_index: int) -> int

Select all layers that use the given color index.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id

Source code in pytvpaint/george/grg_layer.py
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid color index",
)
def tv_layer_color_select(color_index: int) -> int:
    """Select all layers that use the given color index.

    Raises:
        NoObjectWithIdError: if given an invalid layer id
    """
    return int(send_cmd("tv_LayerColor", LayerColorAction.SELECT.value, color_index))

tv_layer_color_unselect(color_index: int) -> int

Unselect all layers that use the given color index.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id

Source code in pytvpaint/george/grg_layer.py
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid color index",
)
def tv_layer_color_unselect(color_index: int) -> int:
    """Unselect all layers that use the given color index.

    Raises:
        NoObjectWithIdError: if given an invalid layer id
    """
    return int(send_cmd("tv_LayerColor", LayerColorAction.UNSELECT.value, color_index))

tv_instance_name(layer_id: int, mode: InstanceNamingMode, prefix: str | None = None, suffix: str | None = None, process: InstanceNamingProcess | None = None) -> None

Rename all instances.

Note

The suffix can only be added when using mode InstanceNamingMode.SMART

Bug

Using a wrong layer_id causes a crash

Parameters:

Name Type Description Default
layer_id int

the layer id

required
mode pytvpaint.george.grg_layer.InstanceNamingMode

the instance renaming mode

required
prefix str | None

the prefix to add to each name

None
suffix str | None

the suffix to add to each name

None
process pytvpaint.george.grg_layer.InstanceNamingProcess | None

the instance naming process

None
Source code in pytvpaint/george/grg_layer.py
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
def tv_instance_name(
    layer_id: int,
    mode: InstanceNamingMode,
    prefix: str | None = None,
    suffix: str | None = None,
    process: InstanceNamingProcess | None = None,
) -> None:
    """Rename all instances.

    Note:
        The suffix can only be added when using mode InstanceNamingMode.SMART

    Bug:
        Using a wrong layer_id causes a crash

    Args:
        layer_id: the layer id
        mode: the instance renaming mode
        prefix: the prefix to add to each name
        suffix: the suffix to add to each name
        process: the instance naming process
    """
    args_dict: dict[str, Any] = {
        "mode": mode.value,
        "prefix": prefix,
    }

    if mode == InstanceNamingMode.SMART:
        args_dict["suffix"] = suffix
        args_dict["process"] = process.value if process else None

    args = args_dict_to_list(args_dict)
    send_cmd("tv_InstanceName", layer_id, *args, error_values=[-1, -2])

tv_instance_get_name(layer_id: int, frame: int) -> str

Get the name of an instance.

Parameters:

Name Type Description Default
layer_id int

the layer id

required
frame int

the frame of the instance

required

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id or an invalid instance frame

Returns:

Type Description
str

the instance name

Source code in pytvpaint/george/grg_layer.py
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid layer id or the frame doesn't have an instance",
)
def tv_instance_get_name(layer_id: int, frame: int) -> str:
    """Get the name of an instance.

    Args:
        layer_id: the layer id
        frame: the frame of the instance

    Raises:
        NoObjectWithIdError: if given an invalid layer id or an invalid instance frame

    Returns:
        the instance name
    """
    return send_cmd("tv_InstanceGetName", layer_id, frame).strip('"')

tv_instance_set_name(layer_id: int, frame: int, name: str) -> str

Set the name of an instance.

Raises:

Type Description
pytvpaint.george.exceptions.GeorgeError

if an invalid layer id was provided or no instance was found at the given frame

Source code in pytvpaint/george/grg_layer.py
1220
1221
1222
1223
1224
1225
1226
1227
@try_cmd(exception_msg="Invalid layer id or no instance at given frame")
def tv_instance_set_name(layer_id: int, frame: int, name: str) -> str:
    """Set the name of an instance.

    Raises:
        GeorgeError: if an invalid layer id was provided or no instance was found at the given frame
    """
    return send_cmd("tv_InstanceSetName", layer_id, frame, name)

tv_exposure_next() -> int

Go to the next layer instance head.

Returns:

Type Description
int

The next instances start frame

Source code in pytvpaint/george/grg_layer.py
1230
1231
1232
1233
1234
1235
1236
def tv_exposure_next() -> int:
    """Go to the next layer instance head.

    Returns:
        The next instances start frame
    """
    return int(send_cmd("tv_ExposureNext"))

tv_exposure_break(frame: int) -> None

Break a layer instance/exposure at the given frame.

Parameters:

Name Type Description Default
frame int

the split frame

required
Source code in pytvpaint/george/grg_layer.py
1239
1240
1241
1242
1243
1244
1245
def tv_exposure_break(frame: int) -> None:
    """Break a layer instance/exposure at the given frame.

    Args:
        frame: the split frame
    """
    send_cmd("tv_ExposureBreak", frame)

tv_exposure_add(frame: int, count: int) -> None

Add new frames to an existing layer instance/exposure.

Parameters:

Name Type Description Default
frame int

the split frame

required
count int

the number of frames to add

required
Source code in pytvpaint/george/grg_layer.py
1248
1249
1250
1251
1252
1253
1254
1255
def tv_exposure_add(frame: int, count: int) -> None:
    """Add new frames to an existing layer instance/exposure.

    Args:
        frame: the split frame
        count: the number of frames to add
    """
    send_cmd("tv_ExposureAdd", frame, count)

tv_exposure_set(frame: int, count: int) -> None

Set the number frames of an existing layer instance/exposure.

Parameters:

Name Type Description Default
frame int

the split frame

required
count int

the number of frames to add

required
Source code in pytvpaint/george/grg_layer.py
1258
1259
1260
1261
1262
1263
1264
1265
def tv_exposure_set(frame: int, count: int) -> None:
    """Set the number frames of an existing layer instance/exposure.

    Args:
        frame: the split frame
        count: the number of frames to add
    """
    send_cmd("tv_ExposureSet", frame, count)

tv_exposure_prev() -> int

Go to the previous layer instance head (before the current instance).

Returns:

Type Description
int

The previous instances start frame

Source code in pytvpaint/george/grg_layer.py
1268
1269
1270
1271
1272
1273
1274
def tv_exposure_prev() -> int:
    """Go to the previous layer instance head (*before* the current instance).

    Returns:
        The previous instances start frame
    """
    return int(send_cmd("tv_ExposurePrev"))

tv_save_image(export_path: Path | str) -> None

Save the current image of the current layer.

Warning

This function outputs very low quality images, we recommend using other rendering functions.

Raises:

Type Description
pytvpaint.george.exceptions.GeorgeError

if the file couldn't be saved or an invalid format was provided

Source code in pytvpaint/george/grg_layer.py
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
@try_cmd(exception_msg="No file found or invalid format")
def tv_save_image(export_path: Path | str) -> None:
    """Save the current image of the current layer.

    Warning:
        This function outputs very low quality images, we recommend using other rendering functions.

    Raises:
        GeorgeError: if the file couldn't be saved or an invalid format was provided
    """
    export_path = Path(export_path)
    send_cmd("tv_SaveImage", export_path.as_posix())

tv_load_image(img_path: Path | str, stretch: bool = False) -> None

Load an image in the current image layer.

Raises:

Type Description
FileNotFoundError

if the input file doesn't exist

pytvpaint.george.exceptions.GeorgeError

if the provided file is in an invalid format

Source code in pytvpaint/george/grg_layer.py
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
@try_cmd(exception_msg="Invalid image format")
def tv_load_image(img_path: Path | str, stretch: bool = False) -> None:
    """Load an image in the current image layer.

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

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

    args: list[Any] = [img_path.as_posix()]
    if stretch:
        args.append("stretch")

    send_cmd("tv_LoadImage", *args)

tv_clear(fill_b_pen: bool = False) -> None

Clear (or fill with BPen) the current image (selection) of the current layer.

Source code in pytvpaint/george/grg_layer.py
1311
1312
1313
def tv_clear(fill_b_pen: bool = False) -> None:
    """Clear (or fill with BPen) the current image (selection) of the current layer."""
    send_cmd("tv_Clear", int(fill_b_pen))

tv_layer_is_ctg_source() -> list[int]

Returns list of CTG layers (ids) that use the current layer as a source.

Source code in pytvpaint/george/grg_layer.py
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
@min_version_compatible(min_version="12")
def tv_layer_is_ctg_source() -> list[int]:
    """Returns list of CTG layers (ids) that use the current layer as a source."""
    res = send_cmd("tv_LayerIsCTGSource", error_values=[GrgErrorValue.EMPTY])
    with contextlib.suppress(Exception):
        layer_ids = [int(layer_id) for layer_id in res.split()]

        if any([layer_id < 0 for layer_id in layer_ids]):
            return []
        return layer_ids

    return []

tv_ctg_layer_create(name: str, sources: list[str] | None = None) -> int

Create a new CTG layer with the given name.

Parameters:

Name Type Description Default
name str

layer name

required
sources list[str] | None

list of source layer ids

None

Returns:

Name Type Description
layer_id int

new layer id

Source code in pytvpaint/george/grg_layer.py
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
@min_version_compatible(min_version="12")
def tv_ctg_layer_create(name: str, sources: list[str] | None = None) -> int:
    """Create a new CTG layer with the given name.

    Args:
        name: layer name
        sources: list of source layer ids

    Returns:
        layer_id: new layer id
    """
    sources = sources or []
    return int(send_cmd("tv_CTGLayerCreate", name, *sources))

tv_ctg_load_structure(ctg_layer_id: int) -> None

Create a new CTG layer with the given name.

Parameters:

Name Type Description Default
ctg_layer_id int

ctg layer id

required

Raises:

Type Description
ValueError

if Invalid layer id

Source code in pytvpaint/george/grg_layer.py
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
@min_version_compatible(min_version="12")
def tv_ctg_load_structure(ctg_layer_id: int) -> None:
    """Create a new CTG layer with the given name.

    Args:
        ctg_layer_id: ctg layer id

    Raises:
        ValueError: if Invalid layer id
    """
    res = send_cmd("tv_CTGLoadStructure ", ctg_layer_id)
    with contextlib.suppress(Exception):
        if int(res) < 0:
            raise ValueError("Invalid layer id")

tv_ctg_apply_changes(ctg_layer_id: int, apply: bool) -> bool

Set Apply Changes value on CTG layer.

Parameters:

Name Type Description Default
ctg_layer_id int

ctg layer id

required
apply bool

True to apply changes, False otherwise

required

Returns:

Name Type Description
bool bool

previous value

Source code in pytvpaint/george/grg_layer.py
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
@min_version_compatible(min_version="12")
def tv_ctg_apply_changes(ctg_layer_id: int, apply: bool) -> bool:
    """Set Apply Changes value on CTG layer.

    Args:
        ctg_layer_id: ctg layer id
        apply: True to apply changes, False otherwise

    Returns:
        bool: previous value
    """
    res = send_cmd("tv_CTGApplyChanges", ctg_layer_id, "on" if apply else "off")
    return tv_cast_to_type(res, bool)

tv_ctg_squiggles_visible(ctg_layer_id: int, visible: bool) -> bool

Set squiggles visibility on CTG layer.

Parameters:

Name Type Description Default
ctg_layer_id int

ctg layer id

required
visible bool

True to make squiggles visible, False otherwise

required

Returns:

Name Type Description
bool bool

previous value

Source code in pytvpaint/george/grg_layer.py
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
@min_version_compatible(min_version="12")
def tv_ctg_squiggles_visible(ctg_layer_id: int, visible: bool) -> bool:
    """Set squiggles visibility on CTG layer.

    Args:
        ctg_layer_id: ctg layer id
        visible: True to make squiggles visible, False otherwise

    Returns:
        bool: previous value
    """
    res = send_cmd("tv_CTGSquigglesVisible", ctg_layer_id, "on" if visible else "off")
    return tv_cast_to_type(res, bool)

tv_ctg_get_source(ctg_layer_id: int) -> list[int]

Get a CTG layer's sources.

Parameters:

Name Type Description Default
ctg_layer_id int

ctg layer id

required

Returns:

Name Type Description
sources list[int]

list of sours layer Ids

Warning

this function is documented as tv_CTGGetSources but it is in fact tv_CTGGetSource without the s

Source code in pytvpaint/george/grg_layer.py
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
@min_version_compatible(min_version="12")
def tv_ctg_get_source(ctg_layer_id: int) -> list[int]:
    """Get a CTG layer's sources.

    Args:
        ctg_layer_id: ctg layer id

    Returns:
        sources: list of sours layer Ids

    Warning:
        this function is documented as `tv_CTGGetSources` but it is in fact `tv_CTGGetSource` without the `s`
    """
    res = send_cmd("tv_CTGGetSource", ctg_layer_id)
    return tv_cast_to_type(res, list[int])

tv_ctg_source_add(ctg_layer_id: int, source_ids: list[int]) -> None

Add layers as sources for the CTG layer.

Parameters:

Name Type Description Default
ctg_layer_id int

ctg layer id

required
source_ids list[int]

list of layer Ids to add as sources for the CTG layer

required

Raises:

Type Description
ValueError

if layer Id(s) already set as source

Source code in pytvpaint/george/grg_layer.py
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
@min_version_compatible(min_version="12")
def tv_ctg_source_add(ctg_layer_id: int, source_ids: list[int]) -> None:
    """Add layers as sources for the CTG layer.

    Args:
        ctg_layer_id: ctg layer id
        source_ids: list of layer Ids to add as sources for the CTG layer

    Raises:
        ValueError: if layer Id(s) already set as source
    """
    res = send_cmd("tv_CTGSource", "add", ctg_layer_id, *source_ids)
    if not res == "0":
        raise ValueError(res)

tv_ctg_source_remove(ctg_layer_id: int, source_ids: list[int]) -> None

Remove layers from sources for the CTG layer.

Parameters:

Name Type Description Default
ctg_layer_id int

ctg layer id

required
source_ids list[int]

list of layer Ids to remove as sources for the CTG layer

required
Source code in pytvpaint/george/grg_layer.py
1424
1425
1426
1427
1428
1429
1430
1431
1432
@min_version_compatible(min_version="12")
def tv_ctg_source_remove(ctg_layer_id: int, source_ids: list[int]) -> None:
    """Remove layers from sources for the CTG layer.

    Args:
        ctg_layer_id: ctg layer id
        source_ids: list of layer Ids to remove as sources for the CTG layer
    """
    send_cmd("tv_CTGSource", "remove", ctg_layer_id, *source_ids)

tv_panning(x: int, y: int, move_fill: bool = False, anti_aliasing: bool = False) -> None

Apply a panning FX to the current layer.

Parameters:

Name Type Description Default
x int

new x position of the layer (position is calculated from the top left corner of the layer frame)

required
y int

new y position of the layer (position is calculated from the top left corner of the layer frame)

required
move_fill bool

True to moved and fill all screen, False to only move images

False
anti_aliasing bool

apply antialiasing

False
Source code in pytvpaint/george/grg_layer.py
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
def tv_panning(x: int, y: int, move_fill: bool = False, anti_aliasing: bool = False) -> None:
    """Apply a panning FX to the current layer.

    Args:
        x: new x position of the layer (position is calculated from the top left corner of the layer frame)
        y: new y position of the layer (position is calculated from the top left corner of the layer frame)
        move_fill: True to moved and fill all screen, False to only move images
        anti_aliasing: apply antialiasing
    """
    send_cmd("tv_Panning ", x, y, int(move_fill), (2 if anti_aliasing else 0))