Skip to content

create_shot_clip

CreateShotClip

Bases: FlameEditorialCreator

Publishable clip

Source code in client/ayon_flame/plugins/create/create_shot_clip.py
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 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
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 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
 909
 910
 911
 912
 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
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 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
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
class CreateShotClip(plugin.FlameEditorialCreator):
    """Publishable clip"""

    identifier = "io.ayon.creators.flame.clip"
    label = "Create Publishable Clip"
    product_type = "editorial"
    product_base_type = "editorial"
    icon = "film"
    defaults = ["Main"]

    detailed_description = """
Publishing clips/plate, audio for new shots to project
or updating already created from Flame. Publishing will create
OTIO file.
"""

    create_allow_thumbnail = False

    shot_instances = {}

    # Pre-create attribute keys that can be hidden/shown via settings
    overridable_attributes = {
        "hierarchy",
        "useShotName",
        "clipRename",
        "clipName",
        "segmentIndex",
        "countFrom",
        "countSteps",
        "folder",
        "episode",
        "sequence",
        "track",
        "shot",
        "export_audio",
        "sourceResolution",
        "vSyncOn",
        "vSyncTrack",
        "workfileFrameStart",
        "handleStart",
        "handleEnd",
        "includeHandles",
        "retimedHandles",
        "retimedFramerange",
    }

    def apply_settings(cls, project_settings):
        super().apply_settings(project_settings)
        # Disable if not in timeline context.
        cls.enabled = (lib.CTX.context == "FlameMenuTimeline")

    def get_pre_create_attr_defs(self):

        def header_label(text):
            return f"<br><b>{text}</b>"

        tokens_help = """\nUsable tokens:
    {_clip_}: name of used clip
    {_track_}: name of parent track layer
    {_sequence_}: name of parent sequence (timeline)"""

        current_sequence = lib.get_current_sequence(lib.CTX.selection)
        if current_sequence is not None:
            gui_tracks = [
                {"value": tr_name, "label": f"Track: {tr_name}"}
                for tr_name in get_video_track_names(current_sequence)
            ]
        else:
            gui_tracks = []

        # Project settings might be applied to this creator via
        # the inherited `Creator.apply_settings`
        presets = self.presets

        attr_defs = [
            BoolDef("use_selection",
                    label="Use only selected clip(s).",
                    tooltip=(
                        "When enabled it restricts create process "
                        "to selected clips."
                    ),
                    default=True),

            # renameHierarchy
            UILabelDef(
                label=header_label("Shot Hierarchy And Rename Settings")
            ),
            TextDef(
                "hierarchy",
                label="Shot Parent Hierarchy",
                tooltip="Parents folder for shot root folder, "
                        "Template filled with *Hierarchy Data* section",
                default=presets.get("hierarchy", "{folder}/{sequence}"),
            ),
            BoolDef(
                "useShotName",
                label="Use shot name",
                tooltip="Use name form Shot name clip attribute.",
                default=presets.get("useShotName", True),
            ),
            BoolDef(
                "clipRename",
                label="Rename clips",
                tooltip="Renaming selected clips on fly",
                default=presets.get("clipRename", False),
            ),
            TextDef(
                "clipName",
                label="Clip Name Template",
                tooltip="template for creating shot names, used for "
                        "renaming (use rename: on)",
                default=presets.get("clipName", "{sequence}{shot}"),
            ),
            BoolDef(
                "segmentIndex",
                label="Segment Index",
                tooltip="Take number from segment index",
                default=presets.get("segmentIndex", True),
            ),
            NumberDef(
                "countFrom",
                label="Count sequence from",
                tooltip="Set where the sequence number starts from",
                default=presets.get("countFrom", 10),
            ),
            NumberDef(
                "countSteps",
                label="Stepping number",
                tooltip="What number is adding every new step",
                default=presets.get("countSteps", 10),
            ),

            # hierarchyData
            UILabelDef(
                label=header_label("Shot Template Keywords")
            ),
            TextDef(
                "folder",
                label="{folder}",
                tooltip="Name of folder used for root of generated shots.\n"
                        f"{tokens_help}",
                default=presets.get("folder", "shots"),
            ),
            TextDef(
                "episode",
                label="{episode}",
                tooltip=f"Name of episode.\n{tokens_help}",
                default=presets.get("episode", "ep01"),
            ),
            TextDef(
                "sequence",
                label="{sequence}",
                tooltip=f"Name of sequence of shots.\n{tokens_help}",
                default=presets.get("sequence", "sq01"),
            ),
            TextDef(
                "track",
                label="{track}",
                tooltip=f"Name of timeline track.\n{tokens_help}",
                default=presets.get("track", "{_track_}"),
            ),
            TextDef(
                "shot",
                label="{shot}",
                tooltip="Name of shot. '#' is converted to padded number."
                        f"\n{tokens_help}",
                default=presets.get("shot", "sh###"),
            ),

            # verticalSync
            UILabelDef(
                label=header_label("Vertical Synchronization Of Attributes")
            ),
            BoolDef(
                "vSyncOn",
                label="Enable Vertical Sync",
                tooltip="Switch on if you want clips above "
                        "each other to share its attributes",
                default=presets.get("vSyncOn", True),
            ),
            EnumDef(
                "vSyncTrack",
                label="Hero track",
                tooltip="Select driving track name which should "
                        "be mastering all others",
                items=gui_tracks or ["<nothing to select>"],
            ),

            # publishSettings
            UILabelDef(
                label=header_label("Publish Settings")
            ),
            EnumDef(
                "clipVariant",
                label="Product Variant",
                tooltip="Chose variant which will be then used for "
                        "product name, if <track_name> "
                        "is selected, name of track layer will be used",
                items=['<track_name>', 'main', 'bg', 'fg', 'bg', 'animatic'],
            ),
            EnumDef(
                "productType",
                label="Product Type",
                tooltip="How the product will be used",
                items=['plate', 'take'],
            ),
            EnumDef(
                "reviewableSource",
                label="Reviewable Source",
                tooltip="Select source for reviewable files.",
                items=[
                    {"value": None, "label": "< none >"},
                    {"value": "clip_media", "label": "[ Clip's media ]"},
                ]
                + gui_tracks,
            ),
            BoolDef(
                "export_audio",
                label="Include audio",
                tooltip="Process subsets with corresponding audio",
                default=presets.get("export_audio", False),
            ),
            BoolDef(
                "sourceResolution",
                label="Source resolution",
                tooltip="Is resolution taken from timeline or source?",
                default=presets.get("sourceResolution", False),
            ),

            # shotAttr
            UILabelDef(
                label=header_label("Shot Attributes"),
            ),
            NumberDef(
                "workfileFrameStart",
                label="Workfiles Start Frame",
                tooltip="Set workfile starting frame number",
                default=presets.get("workfileFrameStart", 1001),
            ),
            NumberDef(
                "handleStart",
                label="Handle start (head)",
                tooltip="Handle at start of clip",
                default=presets.get("handleStart", 0),
            ),
            NumberDef(
                "handleEnd",
                label="Handle end (tail)",
                tooltip="Handle at end of clip",
                default=presets.get("handleEnd", 0),
            ),
            BoolDef(
                "includeHandles",
                label="Include handles",
                tooltip="Should the handles be included?",
                default=presets.get("includeHandles", True),
            ),
            BoolDef(
                "retimedHandles",
                label="Retimed handles",
                tooltip="Should the handles be retimed?",
                default=presets.get("retimedHandles", True),
            ),
            BoolDef(
                "retimedFramerange",
                label="Retimed framerange",
                tooltip="Should the framerange be retimed?",
                default=presets.get("retimedFramerange", True),
            ),
        ]

        disabled_attributes = self._get_disabled_attributes()
        return [
            attr_def for attr_def in attr_defs

            # include only if enabled as overridable in settings when
            # the attribute is overridable
            if attr_def.key not in disabled_attributes
        ]

    def _get_disabled_attributes(self) -> set[str]:
        """Return pre-create attribute definition keys that are not exposed
        for editing to the user."""
        # Filter out those that are not enabled based on the filter state
        enabled_overrides: set[str] = set(self.presets["overrides"])
        if "vSyncOn" in enabled_overrides or self.presets.get("vSyncOn"):
            enabled_overrides.add("vSyncTrack")

        return {
            attr for attr in self.overridable_attributes
            if attr not in enabled_overrides
        }

    def create(self, product_name, instance_data, pre_create_data):
        # Ensure to include the default values for excluded attributes that
        # are marked not overridable in settings into the pre_create_data
        for attr in self._get_disabled_attributes():
            if attr in self.presets:
                pre_create_data[attr] = self.presets[attr]

        super().create(
            product_name,
            instance_data,
            pre_create_data)

        if len(self.selected) < 1:
            return

        self.log.info(self.selected)
        self.log.debug(f"Selected: {self.selected}")

        audio_clips = [
            audio_track.selected_segments
            for audio_track in self.sequence.audio_tracks
        ]

        if not any(audio_clips) and pre_create_data.get("export_audio"):
            raise CreatorError(
                "You must have audio in your active "
                "timeline in order to export audio."
            )

        instance_data.update(pre_create_data)
        instance_data["task"] = None

        # sort selected trackItems by
        v_sync_track = pre_create_data.get("vSyncTrack", "")

        # sort selected trackItems by
        sorted_selected_segments = []
        unsorted_selected_segments = []
        for _segment in self.selected:
            if _segment.parent.name.get_value() in v_sync_track:
                sorted_selected_segments.append(_segment)
            else:
                unsorted_selected_segments.append(_segment)

        sorted_selected_segments.extend(unsorted_selected_segments)

        # detect enabled creators for review, plate and audio
        shot_creator_id = "io.ayon.creators.flame.shot"
        plate_creator_id = "io.ayon.creators.flame.plate"
        audio_creator_id = "io.ayon.creators.flame.audio"
        all_creators = {
            shot_creator_id: True,
            plate_creator_id: True,
            audio_creator_id: True,
        }
        instances = []

        for idx, segment in enumerate(sorted_selected_segments):

            clip_index = str(uuid.uuid4())
            segment_instance_data = deepcopy(instance_data)
            segment_instance_data["clip_index"] = clip_index

            # convert track item to timeline media pool item
            publish_clip = ayfapi.PublishableClip(
                segment,
                log=self.log,
                pre_create_data=pre_create_data,
                data=segment_instance_data,
                product_type=self.product_type,
                rename_index=idx,
            )

            segment = publish_clip.convert()
            if segment is None:
                # Ignore input clips that do not convert into a track item
                # from `PublishableClip.convert`
                continue

            segment_instance_data.update(publish_clip.marker_data)
            self.log.info(
                "Processing track item data: {} (index: {})".format(
                    segment, idx)
            )

            # Delete any existing instances previously generated for the clip.
            prev_tag_data = lib.get_segment_data_marker(segment)
            if prev_tag_data:
                for creator_id, inst_data in prev_tag_data.get(
                        _CONTENT_ID, {}).items():
                    creator = self.create_context.creators[creator_id]
                    prev_instance = self.create_context.instances_by_id.get(
                        inst_data["instance_id"]
                    )
                    if prev_instance is not None:
                        creator.remove_instances([prev_instance])

            # Create new product(s) instances.
            clip_instances = {}
            # disable shot creator if heroTrack is not enabled
            all_creators[shot_creator_id] = segment_instance_data.get(
                "heroTrack", False)
            # disable audio creator if audio is not enabled
            all_creators[audio_creator_id] = (
                segment_instance_data.get("heroTrack", False) and
                pre_create_data.get("export_audio", False)
            )

            enabled_creators = tuple(
                cre for cre, enabled in all_creators.items() if enabled)
            clip_instances = {}
            shot_folder_path = segment_instance_data["folderPath"]
            shot_instances = self.shot_instances.setdefault(
                shot_folder_path, {})

            for creator_id in enabled_creators:
                creator = self.create_context.creators[creator_id]
                sub_instance_data = deepcopy(segment_instance_data)
                creator_attributes = sub_instance_data.setdefault(
                    "creator_attributes", {}
                )
                shot_folder_path = sub_instance_data["folderPath"]

                # Shot creation
                if creator_id == shot_creator_id:
                    segment_data = lib.get_segment_attributes(segment)
                    self.log.debug(f"segment_data: '{segment_data}'")
                    record_in = segment_data["record_in"]
                    record_out = segment_data["record_out"]
                    segment_duration = segment_data.get("record_duration")
                    if segment_duration is None:
                        segment_duration = record_out - record_in + 1
                    workfileFrameStart = sub_instance_data[
                        "workfileFrameStart"]
                    sub_instance_data.update(
                        {
                            "variant": "main",
                            "productType": "shot",
                            "productBaseType": "shot",
                            "productName": "shotMain",
                            "creator_attributes": {
                                "workfileFrameStart": workfileFrameStart,
                                "handleStart": sub_instance_data[
                                    "handleStart"],
                                "handleEnd": sub_instance_data["handleEnd"],
                                "frameStart": workfileFrameStart,
                                "frameEnd": (
                                    workfileFrameStart + segment_duration),
                                "clipIn": int(record_in),
                                "clipOut": int(record_out),
                                "clipDuration": segment_duration,
                                "sourceIn": int(segment_data["source_in"]),
                                "sourceOut": int(segment_data["source_out"]),
                                "includeHandles": pre_create_data[
                                    "includeHandles"],
                                "retimedHandles": pre_create_data[
                                    "retimedHandles"],
                                "retimedFramerange": pre_create_data[
                                    "retimedFramerange"
                                ],
                                "useSourceResolution": sub_instance_data[
                                    "sourceResolution"],
                            },
                            "label": f"{shot_folder_path} shot",
                        }
                    )

                # Plate,
                # insert parent instance data to allow
                # metadata recollection as publish time.
                elif creator_id == plate_creator_id:
                    parenting_data = shot_instances[shot_creator_id]
                    sub_instance_data.update(
                        {
                            "parent_instance_id": parenting_data[
                                "instance_id"],
                            "label": (
                                f"{sub_instance_data['folderPath']} "
                                f"{sub_instance_data['productName']}"
                            ),
                        }
                    )
                    creator_attributes["parentInstance"] = parenting_data[
                        "label"]
                    if sub_instance_data.get("reviewableSource"):
                        creator_attributes.update(
                            {
                                "review": True,
                                "reviewableSource": sub_instance_data[
                                    "reviewableSource"
                                ],
                            }
                        )

                # Audio
                # insert parent instance data
                elif creator_id == audio_creator_id:
                    sub_instance_data["variant"] = "main"
                    sub_instance_data["productType"] = "audio"
                    sub_instance_data["productBaseType"] = "audio"
                    sub_instance_data["productName"] = "audioMain"

                    parenting_data = shot_instances[shot_creator_id]
                    sub_instance_data.update(
                        {
                            "parent_instance_id": parenting_data[
                                "instance_id"],
                            "label": (
                                f"{sub_instance_data['folderPath']} "
                                f"{sub_instance_data['productName']}"
                            )
                        }
                    )
                    creator_attributes["parentInstance"] = parenting_data[
                        "label"]

                    if sub_instance_data.get("reviewableSource"):
                        creator_attributes["review"] = True

                instance = creator.create(sub_instance_data, None)
                instance.transient_data["segment_item"] = segment

                instance_data_to_store = instance.data_to_store()
                shot_instances[creator_id] = instance_data_to_store
                clip_instances[creator_id] = instance_data_to_store

            pipeline.imprint(
                segment,
                data={
                    _CONTENT_ID: clip_instances,
                    "clip_index": clip_index,
                }
            )
            instances.append(instance)

        self.shot_instances = {}
        ayfapi.PublishableClip.restore_all_caches()

        return instances

    def _create_and_add_instance(
            self, data, creator_id, segment, instances):
        """
        Args:
            data (dict): The data to re-recreate the instance from.
            creator_id (str): The creator id to use.
            segment (obj): The associated segment item.
            instances (list): Result instance container.

        Returns:
            CreatedInstance: The newly created instance.
        """
        creator = self.create_context.creators[creator_id]
        instance = creator.create(data, None)
        instance.transient_data["segment_item"] = segment
        instances.append(instance)
        return instance

    def _collect_legacy_instance(self, segment, marker_data):
        """ Create some instances from legacy marker data.

        Args:
            segment (object): The segment associated to the marker.
            marker_data (dict): The marker data.

        Returns:
            list. All of the created legacy instances.
        """
        instance_data = marker_data
        instance_data["task"] = None

        clip_index = str(uuid.uuid4())
        instance_data["clip_index"] = clip_index
        clip_instances = {}

        # Create parent shot instance.
        sub_instance_data = instance_data.copy()
        segment_data = lib.get_segment_attributes(segment)
        segment_duration = int(segment_data["record_duration"])
        workfileFrameStart = sub_instance_data["workfileFrameStart"]
        sub_instance_data.update({
            "creator_attributes": {
                "workfileFrameStart": workfileFrameStart,
                "handleStart": sub_instance_data["handleStart"],
                "handleEnd": sub_instance_data["handleEnd"],
                "frameStart": workfileFrameStart,
                "frameEnd": (
                    workfileFrameStart + segment_duration),
                "clipIn": int(segment_data["record_in"]),
                "clipOut": int(segment_data["record_out"]),
                "clipDuration": segment_duration,
                "sourceIn": int(segment_data["source_in"]),
                "sourceOut": int(segment_data["source_out"]),
                "includeHandles": sub_instance_data["includeHandles"],
                "retimedHandles": sub_instance_data["retimedHandles"],
                "retimedFramerange": sub_instance_data["retimedFramerange"],
                "useSourceResolution": sub_instance_data["sourceResolution"],
            },
            "label": (
                f"{sub_instance_data['folderPath']} shot"
            ),
        })

        shot_creator_id = "io.ayon.creators.flame.shot"
        creator = self.create_context.creators[shot_creator_id]
        instance = creator.create(sub_instance_data, None)
        instance.transient_data["segment_item"] = segment
        clip_instances[shot_creator_id] = instance.data_to_store()
        parenting_data = instance

        # Create plate/audio instance
        sub_creators = ["io.ayon.creators.flame.plate"]
        if instance_data["audio"]:
            sub_creators.append(
                "io.ayon.creators.flame.audio"
            )

        for sub_creator_id in sub_creators:
            sub_instance_data = deepcopy(instance_data)
            creator = self.create_context.creators[sub_creator_id]
            sub_instance_data.update({
                "parent_instance_id": parenting_data["instance_id"],
                "label": (
                    f"{sub_instance_data['folderPath']} "
                    f"{creator.product_type}"
                ),
                "creator_attributes": {
                    "parentInstance": parenting_data["label"],
                }
            })

            # add reviewable source to plate if shot has it
            if sub_instance_data.get("reviewableSource") != "< none >":
                sub_instance_data["creator_attributes"].update({
                    "reviewableSource": sub_instance_data[
                        "reviewTrack"],
                    "review": True,
                })

            instance = creator.create(sub_instance_data, None)
            instance.transient_data["segment_item"] = segment
            clip_instances[sub_creator_id] = instance.data_to_store()

        # Adjust clip tag to match new publisher
        pipeline.imprint(
            segment,
            data={
                _CONTENT_ID: clip_instances,
                "clip_index": clip_index,
            }
        )
        return clip_instances.values()

    def collect_instances(self):
        """Collect all created instances from current timeline."""
        # get selection only of sequence clip segments
        create_settings = self.project_settings[
            "flame"]["create"]["CollectShotClip"]
        restrict_to_selection = create_settings[
            "collectSelectedInstance"]

        selection = lib.CTX.selection or []
        current_sequence = lib.get_current_sequence(selection)

        # only get selected segments if user selected any
        # and settings are enabled
        segments = lib.get_sequence_segments(
            current_sequence, selected=restrict_to_selection
        )

        if not segments:
            # get all segments if user didn't select any
            segments = lib.get_sequence_segments(current_sequence)

        for segment in segments:
            instances = []

            # attempt to get AYON tag data
            marker_data = lib.get_segment_data_marker(segment)
            if not marker_data:
                continue

            # Legacy instances handling
            if _CONTENT_ID not in marker_data:
                instances.extend(
                    self._collect_legacy_instance(segment, marker_data)
                )
                continue

            for creator_id, data in marker_data[_CONTENT_ID].items():
                self._create_and_add_instance(
                    data, creator_id, segment, instances)

        return instances

    def update_instances(self, update_list):
        """Never called, update is handled via _FlameInstanceCreator."""
        pass

    def remove_instances(self, instances):
        """Never called, update is handled via _FlameInstanceCreator."""
        pass

collect_instances()

Collect all created instances from current timeline.

Source code in client/ayon_flame/plugins/create/create_shot_clip.py
 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
1011
1012
1013
1014
1015
1016
1017
1018
1019
def collect_instances(self):
    """Collect all created instances from current timeline."""
    # get selection only of sequence clip segments
    create_settings = self.project_settings[
        "flame"]["create"]["CollectShotClip"]
    restrict_to_selection = create_settings[
        "collectSelectedInstance"]

    selection = lib.CTX.selection or []
    current_sequence = lib.get_current_sequence(selection)

    # only get selected segments if user selected any
    # and settings are enabled
    segments = lib.get_sequence_segments(
        current_sequence, selected=restrict_to_selection
    )

    if not segments:
        # get all segments if user didn't select any
        segments = lib.get_sequence_segments(current_sequence)

    for segment in segments:
        instances = []

        # attempt to get AYON tag data
        marker_data = lib.get_segment_data_marker(segment)
        if not marker_data:
            continue

        # Legacy instances handling
        if _CONTENT_ID not in marker_data:
            instances.extend(
                self._collect_legacy_instance(segment, marker_data)
            )
            continue

        for creator_id, data in marker_data[_CONTENT_ID].items():
            self._create_and_add_instance(
                data, creator_id, segment, instances)

    return instances

remove_instances(instances)

Never called, update is handled via _FlameInstanceCreator.

Source code in client/ayon_flame/plugins/create/create_shot_clip.py
1025
1026
1027
def remove_instances(self, instances):
    """Never called, update is handled via _FlameInstanceCreator."""
    pass

update_instances(update_list)

Never called, update is handled via _FlameInstanceCreator.

Source code in client/ayon_flame/plugins/create/create_shot_clip.py
1021
1022
1023
def update_instances(self, update_list):
    """Never called, update is handled via _FlameInstanceCreator."""
    pass

EditorialAudioInstanceCreator

Bases: _FlameInstanceClipCreatorBase

Audio product type creator class

Source code in client/ayon_flame/plugins/create/create_shot_clip.py
325
326
327
328
329
330
class EditorialAudioInstanceCreator(_FlameInstanceClipCreatorBase):
    """Audio product type creator class"""
    identifier = "io.ayon.creators.flame.audio"
    product_type = "audio"
    product_base_type = "audio"
    label = "Editorial Audio"

EditorialPlateInstanceCreator

Bases: _FlameInstanceClipCreatorBase

Plate product type creator class

Source code in client/ayon_flame/plugins/create/create_shot_clip.py
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
class EditorialPlateInstanceCreator(_FlameInstanceClipCreatorBase):
    """Plate product type creator class"""
    identifier = "io.ayon.creators.flame.plate"
    product_type = "plate"
    product_base_type = "plate"
    label = "Editorial Plate"

    def create(self, instance_data, _):
        """Return a new CreateInstance for new shot from Resolve.

        Args:
            instance_data (dict): global data from original instance

        Return:
            CreatedInstance: The created instance object for the new shot.
        """
        return super().create(instance_data, None)

create(instance_data, _)

Return a new CreateInstance for new shot from Resolve.

Parameters:

Name Type Description Default
instance_data dict

global data from original instance

required
Return

CreatedInstance: The created instance object for the new shot.

Source code in client/ayon_flame/plugins/create/create_shot_clip.py
313
314
315
316
317
318
319
320
321
322
def create(self, instance_data, _):
    """Return a new CreateInstance for new shot from Resolve.

    Args:
        instance_data (dict): global data from original instance

    Return:
        CreatedInstance: The created instance object for the new shot.
    """
    return super().create(instance_data, None)

FlameShotInstanceCreator

Bases: _FlameInstanceCreator

Shot product type creator class

Source code in client/ayon_flame/plugins/create/create_shot_clip.py
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
class FlameShotInstanceCreator(_FlameInstanceCreator):
    """Shot product type creator class"""
    identifier = "io.ayon.creators.flame.shot"
    product_type = "shot"
    product_base_type = "shot"
    label = "Editorial Shot"

    def get_instance_attr_defs(self):
        instance_attributes = list(CLIP_ATTR_DEFS)
        instance_attributes.append(
            BoolDef(
                "useSourceResolution",
                label="Set shot resolution from plate",
                tooltip="Is resolution taken from timeline or source?",
                default=False,
            )
        )
        return instance_attributes

get_video_track_names(sequence)

Get video track names.

Parameters:

Name Type Description Default
sequence object

The sequence object.

required

Returns:

Type Description

list. The track names.

Source code in client/ayon_flame/plugins/create/create_shot_clip.py
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
def get_video_track_names(sequence):
    """ Get video track names.

    Args:
        sequence (object): The sequence object.

    Returns:
        list. The track names.
    """
    track_names = []
    for ver in sequence.versions:
        for track in ver.tracks:
            track_names.append(track.name.get_value())

    return track_names