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

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

InstanceNamingMode

Bases: enum.Enum

tv_instancename naming modes.

Attributes:

Name Type Description
ALL
SMART

InstanceNamingProcess

Bases: enum.Enum

tv_instancename naming process.

Attributes:

Name Type Description
EMPTY
NUMBER
TEXT

LayerType

Bases: enum.Enum

All the layer types.

Attributes:

Name Type Description
IMAGE
SEQUENCE
XSHEET
SCRIBBLES

StencilMode

Bases: enum.Enum

All the stencil modes.

Attributes:

Name Type Description
ON
OFF
NORMAL
INVERT

LayerBehavior

Bases: enum.Enum

Layer behaviors on boundaries.

Attributes:

Name Type Description
NONE
REPEAT
PINGPONG
HOLD

LayerTransparency

Bases: enum.Enum

Layer transparency values.

Attributes:

Name Type Description
ON
OFF
MINUS_1
NONE

InsertDirection

Bases: enum.Enum

Instance insert direction.

Attributes:

Name Type Description
BEFORE
AFTER

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

Clip layer color values.

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.

tv_layer_current_id() -> int

Get the id of the current layer.

Source code in pytvpaint/george/grg_layer.py
198
199
200
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
203
204
205
206
207
208
209
210
211
@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
214
215
216
217
218
219
220
221
222
223
224
@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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
@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) -> None

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

Raises:

Type Description
pytvpaint.george.exceptions.GeorgeError

if layer could not be moved

Source code in pytvpaint/george/grg_layer.py
243
244
245
246
247
248
249
250
@try_cmd(exception_msg="Couldn't move current layer to position")
def tv_layer_move(position: int) -> None:
    """Move the current layer to a new position in the layer stack.

    Raises:
        GeorgeError: if layer could not be moved
    """
    send_cmd("tv_LayerMove", position)

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
253
254
255
256
257
258
259
260
261
262
263
@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
266
267
268
269
270
271
272
273
274
@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
277
278
279
280
281
282
283
284
@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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
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

Always get the selection range, even on a non anim/ctg layer

False

Returns:

Name Type Description
frame int

the start frame of the selection

count int

the number of frames in the selection

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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
def tv_layer_select_info(full: bool = False) -> tuple[int, int]:
    """Get Selected frames in a layer.

    Args:
        full:  Always get the selection range, even on a non anim/ctg layer

    Returns:
        frame: the start frame of the selection
        count: the number of frames in the selection

    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) -> int

Create a new image layer with the given name.

Source code in pytvpaint/george/grg_layer.py
330
331
332
def tv_layer_create(name: str) -> int:
    """Create a new image layer with the given name."""
    return int(send_cmd("tv_LayerCreate", name, handle_string=False))

tv_layer_duplicate(name: str) -> int

Duplicate the current layer and make it the current one.

Source code in pytvpaint/george/grg_layer.py
335
336
337
def tv_layer_duplicate(name: str) -> int:
    """Duplicate the current layer and make it the current one."""
    return int(send_cmd("tv_LayerDuplicate", name, handle_string=False))

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

Rename a layer.

Raises:

Type Description
pytvpaint.george.exceptions.NoObjectWithIdError

if given an invalid layer id

Source code in pytvpaint/george/grg_layer.py
340
341
342
343
344
345
346
347
348
349
350
@try_cmd(
    raise_exc=NoObjectWithIdError,
    exception_msg="Invalid layer id",
)
def tv_layer_rename(layer_id: int, name: str) -> None:
    """Rename a layer.

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

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
353
354
355
356
357
358
359
360
361
362
363
@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_density_get() -> int

Get the current layer density (opacity).

Source code in pytvpaint/george/grg_layer.py
366
367
368
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
371
372
373
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
376
377
378
379
380
381
382
383
384
385
386
387
@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
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
@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
408
409
410
411
412
413
414
415
416
417
418
419
@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
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
@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
440
441
442
443
444
445
446
447
448
449
450
@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
453
454
455
456
457
458
459
460
461
462
463
@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
466
467
468
469
470
471
472
473
474
475
476
477
@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
480
481
482
483
484
485
486
487
488
489
490
@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
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
@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
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
@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
    """
    if mode == StencilMode.OFF:
        args = ["off"]
    elif mode == StencilMode.ON:
        args = ["on"]
    else:
        args = ["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
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
@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
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
@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
571
572
573
574
575
576
577
578
579
580
581
582
@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
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
@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
606
607
608
609
610
611
612
613
614
615
616
617
618
619
@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
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
@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
640
641
642
643
644
645
646
647
648
649
650
651
@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
654
655
656
657
658
659
660
661
662
663
664
@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
667
668
669
670
671
672
673
674
675
676
677
678
@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
681
682
683
684
685
686
687
688
689
690
691
@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
694
695
696
697
698
699
700
701
702
703
704
705
@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
708
709
710
711
712
713
714
715
716
717
718
@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
721
722
723
724
725
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.

Source code in pytvpaint/george/grg_layer.py
728
729
730
def tv_preserve_set(state: LayerTransparency) -> None:
    """Set the preserve transparency state of the current layer."""
    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
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
@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
    """
    return int(send_cmd("tv_LayerMarkGet", layer_id, frame))

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
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
@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
771
772
773
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
776
777
778
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
781
782
783
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
786
787
788
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
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
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
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
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
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
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
869
870
871
872
873
874
875
876
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
879
880
881
882
883
884
885
886
887
888
889
@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
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
@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],
    )
    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

Note

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

Source code in pytvpaint/george/grg_layer.py
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
@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

    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:
        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
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
@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],
    )
    return int(res)

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
965
966
967
968
969
970
971
972
973
974
975
976
977
978
@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
981
982
983
984
985
986
987
988
989
990
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
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
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
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
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
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
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
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
@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(
        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
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
@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
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
@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
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
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
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
@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
1147
1148
1149
1150
1151
1152
1153
1154
@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
1157
1158
1159
1160
1161
1162
1163
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
1166
1167
1168
1169
1170
1171
1172
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
1175
1176
1177
1178
1179
1180
1181
1182
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
1185
1186
1187
1188
1189
1190
1191
1192
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
1195
1196
1197
1198
1199
1200
1201
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.

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
1204
1205
1206
1207
1208
1209
1210
1211
1212
@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.

    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
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
@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
1235
1236
1237
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))