Skip to content

load_mesh

MeshLoader

Bases: LoaderPlugin

Zbrush Model Loader.

Source code in client/ayon_zbrush/plugins/load/load_mesh.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
class MeshLoader(load.LoaderPlugin):
    """Zbrush Model Loader."""

    product_types = {"model"}
    representations = {"abc", "fbx", "obj", "ma"}
    order = -9
    icon = "code-fork"
    color = "white"

    def load(self, context, name=None, namespace=None, data=None):
        file_path = os.path.normpath(self.filepath_from_context(context))
        load_zscript = """
[IFreeze,
[VarSet, filename, "{filepath}"]
[FileNameSetNext, #filename]
[IKeyPress, 13, [IPress, Tool:Import:Import]]
]

""".format(filepath=file_path)
        execute_zscript(load_zscript)

        return containerise(
            name,
            context,
            loader=self.__class__.__name__)

    def update(self, container, context):
        repre_entity = context["representation"]
        path = get_representation_path(repre_entity)
        load_zscript = """
[IFreeze,
[VarSet, filename, "{filepath}"]
[FileNameSetNext, #filename]
[IKeyPress, 13, [IPress, Tool:Import:Import]]
]

""".format(filepath=path)
        execute_zscript(load_zscript)
        representation_id = str(repre_entity["id"])
        imprint(container, representation_id)

    def switch(self, container, context):
        self.update(container, context)

    def remove(self, container):
        # TODO: figure out how to delete imported object
        # remove the bind with the container data
        remove_subtool(container["objectName"])
        return remove_container_data(container["objectName"])