Skip to content

extract_unreal_staticmesh

Create Unreal Static Mesh data to be extracted as FBX.

ExtractUnrealStaticMesh

Bases: MayaExtractorPlugin

Extract Unreal Static Mesh as FBX from Maya.

Source code in client/ayon_maya/plugins/publish/extract_unreal_staticmesh.py
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
class ExtractUnrealStaticMesh(plugin.MayaExtractorPlugin):
    """Extract Unreal Static Mesh as FBX from Maya. """

    order = pyblish.api.ExtractorOrder - 0.1
    label = "Extract Unreal Static Mesh"
    families = ["staticMesh"]

    def process(self, instance):
        members = instance.data.get("geometryMembers", [])
        if instance.data.get("collisionMembers"):
            members = members + instance.data.get("collisionMembers")

        fbx_exporter = fbx.FBXExtractor(log=self.log)

        # Define output path
        staging_dir = self.staging_dir(instance)
        filename = "{0}.fbx".format(instance.name)
        path = os.path.join(staging_dir, filename)

        # The export requires forward slashes because we need
        # to format it into a string in a mel expression
        path = path.replace('\\', '/')

        self.log.debug("Extracting FBX to: {0}".format(path))
        self.log.debug("Members: {0}".format(members))
        self.log.debug("Instance: {0}".format(instance[:]))

        fbx_exporter.set_options_from_instance(instance)

        with maintained_selection():
            with parent_nodes(members):
                self.log.debug("Un-parenting: {}".format(members))
                fbx_exporter.export(members, path)

        if "representations" not in instance.data:
            instance.data["representations"] = []

        representation = {
            'name': 'fbx',
            'ext': 'fbx',
            'files': filename,
            "stagingDir": staging_dir,
        }
        instance.data["representations"].append(representation)

        self.log.debug("Extract FBX successful to: {0}".format(path))