Skip to content

validate_no_fabric

Validate that workfile was saved before publishing.

ValidateNoFabric

Bases: InstancePlugin

Validate that workfile was saved.

Source code in client/ayon_marvelousdesigner/plugins/publish/validate_no_fabric.py
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
class ValidateNoFabric(pyblish.api.InstancePlugin):
    """Validate that workfile was saved."""

    order = pyblish.api.ValidatorOrder
    hosts: ClassVar = ["marvelousdesigner"]
    families: ClassVar = ["zfab"]
    label = "Validate No Fabric"
    actions: ClassVar = [RepairAction]

    def process(self, instance: pyblish.api.Instance) -> None:  # noqa: PLR6301
        """Process the instance to validate no fabric is selected.

        Args:
            instance (pyblish.api.Instance): The instance to validate.

        Raises:
            PublishValidationError: If a fabric is selected in the scene.
        """
        fabric_index = instance.data["fabricIndex"]
        fabric_name = instance.data["fabricName"]
        if fabric_api.GetFabricName(fabric_index) != fabric_name:
            msg = (
                f"Fabric '{fabric_name}' does not exist in the scene. "
                "Please reselect any fabric you want to publish "
                "and click 'Repair' action so that Ayon can reset for you."
            )
            raise PublishValidationError(
                msg
            )

    @classmethod
    def repair(cls, instance: pyblish.api.Instance) -> None:
        """Repair the instance by resetting the fabric index."""
        fabric_index = fabric_api.GetCurrentFabricIndex()
        instance.data["fabricIndex"] = fabric_index
        instance.data["fabricName"] = fabric_api.GetFabricName(fabric_index)
        cls.log.info(
            f"Reset fabric to '{instance.data['fabricName']}' "  # noqa: G004
            "in the instance data."
        )

process(instance)

Process the instance to validate no fabric is selected.

Parameters:

Name Type Description Default
instance Instance

The instance to validate.

required

Raises:

Type Description
PublishValidationError

If a fabric is selected in the scene.

Source code in client/ayon_marvelousdesigner/plugins/publish/validate_no_fabric.py
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
def process(self, instance: pyblish.api.Instance) -> None:  # noqa: PLR6301
    """Process the instance to validate no fabric is selected.

    Args:
        instance (pyblish.api.Instance): The instance to validate.

    Raises:
        PublishValidationError: If a fabric is selected in the scene.
    """
    fabric_index = instance.data["fabricIndex"]
    fabric_name = instance.data["fabricName"]
    if fabric_api.GetFabricName(fabric_index) != fabric_name:
        msg = (
            f"Fabric '{fabric_name}' does not exist in the scene. "
            "Please reselect any fabric you want to publish "
            "and click 'Repair' action so that Ayon can reset for you."
        )
        raise PublishValidationError(
            msg
        )

repair(instance) classmethod

Repair the instance by resetting the fabric index.

Source code in client/ayon_marvelousdesigner/plugins/publish/validate_no_fabric.py
40
41
42
43
44
45
46
47
48
49
@classmethod
def repair(cls, instance: pyblish.api.Instance) -> None:
    """Repair the instance by resetting the fabric index."""
    fabric_index = fabric_api.GetCurrentFabricIndex()
    instance.data["fabricIndex"] = fabric_index
    instance.data["fabricName"] = fabric_api.GetFabricName(fabric_index)
    cls.log.info(
        f"Reset fabric to '{instance.data['fabricName']}' "  # noqa: G004
        "in the instance data."
    )