Skip to content

extract_model

ExtractModel

Bases: Extractor, AYONPyblishPluginMixin

Extract PolyMesh(.fbx, .xml) in SpeedTree

Source code in client/ayon_speedtree/plugins/publish/extract_model.py
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
class ExtractModel(publish.Extractor,
                   AYONPyblishPluginMixin):
    """
    Extract PolyMesh(.fbx, .xml) in SpeedTree
    """

    order = pyblish.api.ExtractorOrder - 0.05
    label = "Extract Model"
    hosts = ["speedtree"]
    families = ["model"]

    def process(self, instance):

        stagingdir = self.staging_dir(instance)
        fbx_filename = f"{instance.name}.fbx"
        fbx_filepath = os.path.join(stagingdir, fbx_filename)
        fbx_filepath = os.path.normpath(fbx_filepath)

        xml_filename = f"{instance.name}.xml"
        xml_filepath = os.path.join(stagingdir, xml_filename)
        xml_filepath = os.path.normpath(xml_filepath)

        with save_scene("Ayon Publisher"):
            current_file = instance.context.data["currentFile"]
            export_model(current_file, fbx_filepath, xml_filepath)

        if "representations" not in instance.data:
            instance.data["representations"] = []
        fbx_representation = {
        "name": "fbx",
        "ext": "fbx",
        "files": fbx_filename,
        "stagingDir": stagingdir,
        }
        xml_representation = {
        "name": "xml",
        "ext": "xml",
        "files": xml_filename,
        "stagingDir": stagingdir,
        }
        instance.data["representations"].extend(
            [fbx_representation, xml_representation]
        )
        self.log.info(
            "Extracted instance '%s' to: %s" % (instance.name, fbx_filepath)
        )
        self.log.info(
            "Extracted instance '%s' to: %s" % (instance.name, xml_filepath)
        )