Skip to content

api

Marvelous Designer API package.

This package provides the API interface for Marvelous Designer integration.

MarvelousDesignerHost

Bases: HostBase, IWorkfileHost, ILoadHost, IPublishHost

Host class for Marvelous Designer integration with AYON pipeline.

This class provides the main interface between AYON and Marvelous Designer, implementing workfile operations, loading, and publishing functionality.

Attributes:

Name Type Description
name str

The host name identifier.

_has_been_setup bool

Flag indicating if the host has been

callbacks list

List of registered callbacks.

shelves list

List of UI shelves.

Source code in client/ayon_marvelousdesigner/api/pipeline.py
 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
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
class MarvelousDesignerHost(HostBase, IWorkfileHost, ILoadHost, IPublishHost):
    """Host class for Marvelous Designer integration with AYON pipeline.

    This class provides the main interface between AYON and Marvelous Designer,
    implementing workfile operations, loading, and publishing functionality.

    Attributes:
        name (str): The host name identifier.
        _has_been_setup (bool): Flag indicating if the host has been
        initialized.
        callbacks (list): List of registered callbacks.
        shelves (list): List of UI shelves.
    """
    name = "marvelousdesigner"

    def __init__(self):
        """Initialize the Marvelous Designer host with default settings."""
        super().__init__()
        self._has_been_setup = False
        self.callbacks = []
        self.shelves = []

    @staticmethod
    def show_tools_dialog() -> None:
        """Show tools dialog with actions leading to show other tools."""
        show_tools_dialog()

    def install(self) -> None:
        """Install and register the MD host with Ayon pipeline."""
        pyblish.api.register_host("marvelousdesigner")

        pyblish.api.register_plugin_path(str(PUBLISH_PATH))
        register_loader_plugin_path(str(LOAD_PATH))
        register_creator_plugin_path(str(CREATE_PATH))

        self._has_been_setup = True

    def workfile_has_unsaved_changes(self) -> bool:  # noqa: PLR6301
        """Check if the current workfile has unsaved changes.

        Returns:
            bool: True if there are unsaved changes, False otherwise.
        """
        # API not supported for the check
        return utility_api.CheckZPRJForUnsavedChanges()

    def get_workfile_extensions(self) -> list[str]:  # noqa: PLR6301
        """Get the list of supported workfile extensions.

        Returns:
            list[str]: List of supported workfile extensions.
        """
        return [".zprj"]

    def save_workfile(self, dst_path: str | None = None) -> str | None:  # noqa: PLR6301
        """Save the current workfile to the specified destination path.

        Args:
            dst_path (str | None, optional): Destination path to save
                the workfile. Defaults to None.

        Returns:
            str | None: The path where the workfile was saved, or None
            if saving failed.
        """
        save_workfile(dst_path)
        return dst_path

    def open_workfile(self, filepath: str) -> None:  # noqa: PLR6301
        """Open a workfile from the specified file path."""
        open_workfile(filepath)

    def get_current_workfile(self) -> str:  # noqa: PLR6301
        """Get the current workfile path from the host.

        Returns:
            str: The current workfile path.
        """
        return utility_api.GetProjectFilePath()

    def get_containers(self) -> list:  # noqa: PLR6301
        """Get the list of containers in the current scene.

        Returns:
            list: List of container metadata dictionaries.
        """
        return ls()

    def update_context_data(self, data: dict, changes: dict) -> None:  # noqa : PLR6301
        """Update the context data in the current file metadata."""
        # Note: 'changes' parameter is part of the interface but not used in MD
        _ = changes  # Explicitly ignore the unused parameter
        set_metadata(AYON_CONTEXT_DATA, data)

    def get_context_data(self) -> dict:  # noqa: PLR6301
        """Get the context data from the current file metadata.

        Returns:
            dict: Context data dictionary.
        """
        metadata = get_ayon_metadata() or {}
        return metadata.get(AYON_CONTEXT_DATA, {})

__init__()

Initialize the Marvelous Designer host with default settings.

Source code in client/ayon_marvelousdesigner/api/pipeline.py
58
59
60
61
62
63
def __init__(self):
    """Initialize the Marvelous Designer host with default settings."""
    super().__init__()
    self._has_been_setup = False
    self.callbacks = []
    self.shelves = []

get_containers()

Get the list of containers in the current scene.

Returns:

Name Type Description
list list

List of container metadata dictionaries.

Source code in client/ayon_marvelousdesigner/api/pipeline.py
123
124
125
126
127
128
129
def get_containers(self) -> list:  # noqa: PLR6301
    """Get the list of containers in the current scene.

    Returns:
        list: List of container metadata dictionaries.
    """
    return ls()

get_context_data()

Get the context data from the current file metadata.

Returns:

Name Type Description
dict dict

Context data dictionary.

Source code in client/ayon_marvelousdesigner/api/pipeline.py
137
138
139
140
141
142
143
144
def get_context_data(self) -> dict:  # noqa: PLR6301
    """Get the context data from the current file metadata.

    Returns:
        dict: Context data dictionary.
    """
    metadata = get_ayon_metadata() or {}
    return metadata.get(AYON_CONTEXT_DATA, {})

get_current_workfile()

Get the current workfile path from the host.

Returns:

Name Type Description
str str

The current workfile path.

Source code in client/ayon_marvelousdesigner/api/pipeline.py
115
116
117
118
119
120
121
def get_current_workfile(self) -> str:  # noqa: PLR6301
    """Get the current workfile path from the host.

    Returns:
        str: The current workfile path.
    """
    return utility_api.GetProjectFilePath()

get_workfile_extensions()

Get the list of supported workfile extensions.

Returns:

Type Description
list[str]

list[str]: List of supported workfile extensions.

Source code in client/ayon_marvelousdesigner/api/pipeline.py
89
90
91
92
93
94
95
def get_workfile_extensions(self) -> list[str]:  # noqa: PLR6301
    """Get the list of supported workfile extensions.

    Returns:
        list[str]: List of supported workfile extensions.
    """
    return [".zprj"]

install()

Install and register the MD host with Ayon pipeline.

Source code in client/ayon_marvelousdesigner/api/pipeline.py
70
71
72
73
74
75
76
77
78
def install(self) -> None:
    """Install and register the MD host with Ayon pipeline."""
    pyblish.api.register_host("marvelousdesigner")

    pyblish.api.register_plugin_path(str(PUBLISH_PATH))
    register_loader_plugin_path(str(LOAD_PATH))
    register_creator_plugin_path(str(CREATE_PATH))

    self._has_been_setup = True

open_workfile(filepath)

Open a workfile from the specified file path.

Source code in client/ayon_marvelousdesigner/api/pipeline.py
111
112
113
def open_workfile(self, filepath: str) -> None:  # noqa: PLR6301
    """Open a workfile from the specified file path."""
    open_workfile(filepath)

save_workfile(dst_path=None)

Save the current workfile to the specified destination path.

Parameters:

Name Type Description Default
dst_path str | None

Destination path to save the workfile. Defaults to None.

None

Returns:

Type Description
str | None

str | None: The path where the workfile was saved, or None

str | None

if saving failed.

Source code in client/ayon_marvelousdesigner/api/pipeline.py
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
def save_workfile(self, dst_path: str | None = None) -> str | None:  # noqa: PLR6301
    """Save the current workfile to the specified destination path.

    Args:
        dst_path (str | None, optional): Destination path to save
            the workfile. Defaults to None.

    Returns:
        str | None: The path where the workfile was saved, or None
        if saving failed.
    """
    save_workfile(dst_path)
    return dst_path

show_tools_dialog() staticmethod

Show tools dialog with actions leading to show other tools.

Source code in client/ayon_marvelousdesigner/api/pipeline.py
65
66
67
68
@staticmethod
def show_tools_dialog() -> None:
    """Show tools dialog with actions leading to show other tools."""
    show_tools_dialog()

update_context_data(data, changes)

Update the context data in the current file metadata.

Source code in client/ayon_marvelousdesigner/api/pipeline.py
131
132
133
134
135
def update_context_data(self, data: dict, changes: dict) -> None:  # noqa : PLR6301
    """Update the context data in the current file metadata."""
    # Note: 'changes' parameter is part of the interface but not used in MD
    _ = changes  # Explicitly ignore the unused parameter
    set_metadata(AYON_CONTEXT_DATA, data)

workfile_has_unsaved_changes()

Check if the current workfile has unsaved changes.

Returns:

Name Type Description
bool bool

True if there are unsaved changes, False otherwise.

Source code in client/ayon_marvelousdesigner/api/pipeline.py
80
81
82
83
84
85
86
87
def workfile_has_unsaved_changes(self) -> bool:  # noqa: PLR6301
    """Check if the current workfile has unsaved changes.

    Returns:
        bool: True if there are unsaved changes, False otherwise.
    """
    # API not supported for the check
    return utility_api.CheckZPRJForUnsavedChanges()