Skip to content

extract_vrayproxy

ExtractVRayProxy

Bases: MayaExtractorPlugin

Extract the content of the instance to a vrmesh file

Things to pay attention to

- If animation is toggled, are the frames correct

Source code in client/ayon_maya/plugins/publish/extract_vrayproxy.py
 8
 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
68
69
70
class ExtractVRayProxy(plugin.MayaExtractorPlugin):
    """Extract the content of the instance to a vrmesh file

    Things to pay attention to:
        - If animation is toggled, are the frames correct
        -
    """

    label = "VRay Proxy (.vrmesh)"
    families = ["vrayproxy.vrmesh"]

    def process(self, instance):

        staging_dir = self.staging_dir(instance)
        file_name = "{}.vrmesh".format(instance.name)
        file_path = os.path.join(staging_dir, file_name)

        anim_on = instance.data["animation"]
        if not anim_on:
            # Remove animation information because it is not required for
            # non-animated products
            keys = ["frameStart", "frameEnd",
                    "handleStart", "handleEnd",
                    "frameStartHandle", "frameEndHandle"]
            for key in keys:
                instance.data.pop(key, None)

            start_frame = 1
            end_frame = 1
        else:
            start_frame = instance.data["frameStartHandle"]
            end_frame = instance.data["frameEndHandle"]

        vertex_colors = instance.data.get("vertexColors", False)

        # Write out vrmesh file
        self.log.debug("Writing: '%s'" % file_path)
        with maintained_selection():
            cmds.select(instance.data["setMembers"], noExpand=True)
            cmds.vrayCreateProxy(exportType=1,
                                 dir=staging_dir,
                                 fname=file_name,
                                 animOn=anim_on,
                                 animType=3,
                                 startFrame=start_frame,
                                 endFrame=end_frame,
                                 vertexColorsOn=vertex_colors,
                                 ignoreHiddenObjects=True,
                                 createProxyNode=False)

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

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

        self.log.debug("Extracted instance '%s' to: %s"
                       % (instance.name, staging_dir))