mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
validate loaded plugins tweaks in 3dsmax
This commit is contained in:
parent
66c120ee7d
commit
803fb61649
6 changed files with 117 additions and 51 deletions
69
openpype/hosts/max/plugins/publish/validate_loaded_plugin.py
Normal file
69
openpype/hosts/max/plugins/publish/validate_loaded_plugin.py
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""Validator for USD plugin."""
|
||||
from pyblish.api import InstancePlugin, ValidatorOrder
|
||||
from pymxs import runtime as rt
|
||||
|
||||
from openpype.pipeline.publish import (
|
||||
RepairAction,
|
||||
OptionalPyblishPluginMixin,
|
||||
PublishValidationError
|
||||
)
|
||||
from openpype.hosts.max.api.lib import get_plugins
|
||||
|
||||
|
||||
class ValidateLoadedPlugin(OptionalPyblishPluginMixin,
|
||||
InstancePlugin):
|
||||
"""Validates if the specific plugin is loaded in 3ds max.
|
||||
User can add the plugins they want to check through"""
|
||||
|
||||
order = ValidatorOrder
|
||||
hosts = ["max"]
|
||||
label = "Validate Loaded Plugin"
|
||||
optional = True
|
||||
actions = [RepairAction]
|
||||
|
||||
def get_invalid(self, instance):
|
||||
"""Plugin entry point."""
|
||||
invalid = []
|
||||
# display all DLL loaded plugins in Max
|
||||
plugin_info = get_plugins()
|
||||
project_settings = instance.context.data[
|
||||
"project_settings"]["max"]["publish"]
|
||||
target_plugins = project_settings[
|
||||
"ValidateLoadedPlugin"]["plugins_for_check"]
|
||||
for plugin in target_plugins:
|
||||
if plugin.lower() not in plugin_info:
|
||||
invalid.append(
|
||||
f"Plugin {plugin} not exists in 3dsMax Plugin List.")
|
||||
for i, _ in enumerate(plugin_info):
|
||||
if plugin.lower() == rt.pluginManager.pluginDllName(i):
|
||||
if not rt.pluginManager.isPluginDllLoaded(i):
|
||||
invalid.append(
|
||||
f"Plugin {plugin} not loaded.")
|
||||
return invalid
|
||||
|
||||
def process(self, instance):
|
||||
invalid_plugins = self.get_invalid(instance)
|
||||
if invalid_plugins:
|
||||
bullet_point_invalid_statement = "\n".join(
|
||||
"- {}".format(invalid) for invalid in invalid_plugins
|
||||
)
|
||||
report = (
|
||||
"Required plugins fails to load.\n\n"
|
||||
f"{bullet_point_invalid_statement}\n\n"
|
||||
"You can use repair action to load the plugin."
|
||||
)
|
||||
raise PublishValidationError(report, title="Required Plugins unloaded")
|
||||
|
||||
@classmethod
|
||||
def repair(cls, instance):
|
||||
plugin_info = get_plugins()
|
||||
project_settings = instance.context.data[
|
||||
"project_settings"]["max"]["publish"]
|
||||
target_plugins = project_settings[
|
||||
"ValidateLoadedPlugin"]["plugins_for_check"]
|
||||
for plugin in target_plugins:
|
||||
for i, _ in enumerate(plugin_info):
|
||||
if plugin == rt.pluginManager.pluginDllName(i):
|
||||
if not rt.pluginManager.isPluginDllLoaded(i):
|
||||
rt.pluginManager.loadPluginDll(i)
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""Validator for USD plugin."""
|
||||
from pyblish.api import InstancePlugin, ValidatorOrder
|
||||
from pymxs import runtime as rt
|
||||
|
||||
from openpype.pipeline import (
|
||||
OptionalPyblishPluginMixin,
|
||||
PublishValidationError
|
||||
)
|
||||
|
||||
|
||||
def get_plugins() -> list:
|
||||
"""Get plugin list from 3ds max."""
|
||||
manager = rt.PluginManager
|
||||
count = manager.pluginDllCount
|
||||
plugin_info_list = []
|
||||
for p in range(1, count + 1):
|
||||
plugin_info = manager.pluginDllName(p)
|
||||
plugin_info_list.append(plugin_info)
|
||||
|
||||
return plugin_info_list
|
||||
|
||||
|
||||
class ValidateUSDPlugin(OptionalPyblishPluginMixin,
|
||||
InstancePlugin):
|
||||
"""Validates if USD plugin is installed or loaded in 3ds max."""
|
||||
|
||||
order = ValidatorOrder - 0.01
|
||||
families = ["model"]
|
||||
hosts = ["max"]
|
||||
label = "Validate USD Plugin loaded"
|
||||
optional = True
|
||||
|
||||
def process(self, instance):
|
||||
"""Plugin entry point."""
|
||||
|
||||
for sc in ValidateUSDPlugin.__subclasses__():
|
||||
self.log.info(sc)
|
||||
|
||||
if not self.is_active(instance.data):
|
||||
return
|
||||
|
||||
plugin_info = get_plugins()
|
||||
usd_import = "usdimport.dli"
|
||||
if usd_import not in plugin_info:
|
||||
raise PublishValidationError(f"USD Plugin {usd_import} not found")
|
||||
usd_export = "usdexport.dle"
|
||||
if usd_export not in plugin_info:
|
||||
raise PublishValidationError(f"USD Plugin {usd_export} not found")
|
||||
|
|
@ -36,6 +36,11 @@
|
|||
"enabled": true,
|
||||
"optional": true,
|
||||
"active": true
|
||||
},
|
||||
"ValidateLoadedPlugin": {
|
||||
"enabled": false,
|
||||
"optional": true,
|
||||
"plugins_for_check": []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,31 @@
|
|||
"label": "Active"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "dict",
|
||||
"collapsible": true,
|
||||
"key": "ValidateLoadedPlugin",
|
||||
"label": "Validate Loaded Plugin",
|
||||
"checkbox_key": "enabled",
|
||||
"children": [
|
||||
{
|
||||
"type": "boolean",
|
||||
"key": "enabled",
|
||||
"label": "Enabled"
|
||||
},
|
||||
{
|
||||
"type": "boolean",
|
||||
"key": "optional",
|
||||
"label": "Optional"
|
||||
},
|
||||
{
|
||||
"type": "list",
|
||||
"key": "plugins_for_check",
|
||||
"label": "Plugins Needed For Check",
|
||||
"object_type": "text"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,14 @@ from pydantic import Field
|
|||
from ayon_server.settings import BaseSettingsModel
|
||||
|
||||
|
||||
class ValidateLoadedPluginModel(BaseSettingsModel):
|
||||
enabled: bool = Field(title="ValidateLoadedPlugin")
|
||||
optional: bool = Field(title="Optional")
|
||||
plugins_for_check: list[str] = Field(
|
||||
default_factory=list, title="Plugins Needed For Check"
|
||||
)
|
||||
|
||||
|
||||
class BasicValidateModel(BaseSettingsModel):
|
||||
enabled: bool = Field(title="Enabled")
|
||||
optional: bool = Field(title="Optional")
|
||||
|
|
@ -15,12 +23,20 @@ class PublishersModel(BaseSettingsModel):
|
|||
title="Validate Frame Range",
|
||||
section="Validators"
|
||||
)
|
||||
|
||||
ValidateLoadedPlugin: ValidateLoadedPluginModel = Field(
|
||||
default_factory=ValidateLoadedPluginModel,
|
||||
title="Validate Loaded Plugin"
|
||||
)
|
||||
|
||||
DEFAULT_PUBLISH_SETTINGS = {
|
||||
"ValidateFrameRange": {
|
||||
"enabled": True,
|
||||
"optional": True,
|
||||
"active": True
|
||||
},
|
||||
"ValidateLoadedPlugin": {
|
||||
"enabled": False,
|
||||
"optional": True,
|
||||
"plugins_for_check": []
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
__version__ = "0.1.0"
|
||||
__version__ = "0.1.1"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue