Skip to content

extract_assembly

ExtractAssembly

Bases: MayaExtractorPlugin

Produce an alembic of just point positions and normals.

Positions and normals are preserved, but nothing more, for plain and predictable point caches.

Source code in client/ayon_maya/plugins/publish/extract_assembly.py
 9
10
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
60
61
62
63
64
65
66
67
class ExtractAssembly(plugin.MayaExtractorPlugin):
    """Produce an alembic of just point positions and normals.

    Positions and normals are preserved, but nothing more,
    for plain and predictable point caches.

    """

    label = "Extract Assembly"
    families = ["assembly"]

    def process(self, instance):

        staging_dir = self.staging_dir(instance)
        hierarchy_filename = "{}.abc".format(instance.name)
        hierarchy_path = os.path.join(staging_dir, hierarchy_filename)
        json_filename = "{}.json".format(instance.name)
        json_path = os.path.join(staging_dir, json_filename)

        self.log.debug("Dumping scene data for debugging ..")
        with open(json_path, "w") as filepath:
            json.dump(instance.data["scenedata"], filepath, ensure_ascii=False)

        self.log.debug("Extracting pointcache ..")
        cmds.select(instance.data["nodesHierarchy"])

        # Run basic alembic exporter
        extract_alembic(file=hierarchy_path,
                        startFrame=1.0,
                        endFrame=1.0,
                        **{"step": 1.0,
                           "attr": ["cbId"],
                           "writeVisibility": True,
                           "writeCreases": True,
                           "uvWrite": True,
                           "selection": True})

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

        representation_abc = {
            'name': 'abc',
            'ext': 'abc',
            'files': hierarchy_filename,
            "stagingDir": staging_dir
        }
        instance.data["representations"].append(representation_abc)

        representation_json = {
            'name': 'json',
            'ext': 'json',
            'files': json_filename,
            "stagingDir": staging_dir
        }
        instance.data["representations"].append(representation_json)
        # Remove data
        instance.data.pop("scenedata", None)

        cmds.select(clear=True)