mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
resolve some comments
This commit is contained in:
parent
d54111bd75
commit
45f86749e1
10 changed files with 164 additions and 87 deletions
|
|
@ -28,8 +28,18 @@ class CreateUnrealStaticMesh(plugin.HoudiniCreator):
|
|||
# get the created rop node
|
||||
instance_node = hou.node(instance.get("instance_node"))
|
||||
|
||||
# get parms
|
||||
parms = self.get_parms(subset_name, pre_create_data)
|
||||
# prepare parms
|
||||
output_path = hou.text.expandString("$HIP/pyblish/{}.fbx".format(subset_name))
|
||||
parms = {
|
||||
"startnode": self.get_selection(),
|
||||
"sopoutput": output_path,
|
||||
# vertex cache format
|
||||
"vcformat": pre_create_data.get("vcformat"),
|
||||
"convertunits": pre_create_data.get("convertunits"),
|
||||
# set render range to use frame range start-end frame
|
||||
"trange": 1,
|
||||
"createsubnetroot": pre_create_data.get("createsubnetroot")
|
||||
}
|
||||
|
||||
# set parms
|
||||
instance_node.setParms(parms)
|
||||
|
|
@ -47,7 +57,7 @@ class CreateUnrealStaticMesh(plugin.HoudiniCreator):
|
|||
def get_pre_create_attr_defs(self):
|
||||
"""Add settings for users. """
|
||||
|
||||
attrs = super().get_pre_create_attr_defs()
|
||||
attrs = super(CreateUnrealStaticMesh, self).get_pre_create_attr_defs()
|
||||
createsubnetroot = BoolDef("createsubnetroot",
|
||||
tooltip="Create an extra root for the "
|
||||
"Export node when it's a "
|
||||
|
|
@ -86,40 +96,6 @@ class CreateUnrealStaticMesh(plugin.HoudiniCreator):
|
|||
dynamic_data["asset"] = asset_doc["name"]
|
||||
return dynamic_data
|
||||
|
||||
def get_parms(self, subset_name, pre_create_data):
|
||||
"""Get parameters values. """
|
||||
|
||||
# 1. get output path
|
||||
output_path = hou.text.expandString(
|
||||
"$HIP/pyblish/{}.fbx".format(subset_name))
|
||||
|
||||
# 2. get selection
|
||||
selection = self.get_selection()
|
||||
|
||||
# 3. get Vertex Cache Format
|
||||
vcformat = pre_create_data.get("vcformat")
|
||||
|
||||
# 4. get convert_units
|
||||
convertunits = pre_create_data.get("convertunits")
|
||||
|
||||
# 5. get Valid Frame Range
|
||||
trange = 1
|
||||
|
||||
# 6. get createsubnetroot
|
||||
createsubnetroot = pre_create_data.get("createsubnetroot")
|
||||
|
||||
# parms dictionary
|
||||
parms = {
|
||||
"startnode": selection,
|
||||
"sopoutput": output_path,
|
||||
"vcformat": vcformat,
|
||||
"convertunits": convertunits,
|
||||
"trange": trange,
|
||||
"createsubnetroot": createsubnetroot
|
||||
}
|
||||
|
||||
return parms
|
||||
|
||||
def get_selection(self):
|
||||
"""Selection Logic.
|
||||
|
||||
|
|
|
|||
|
|
@ -146,5 +146,5 @@ class FbxLoader(load.LoaderPlugin):
|
|||
# Set new position for children nodes
|
||||
parent_node.layoutChildren()
|
||||
|
||||
# Retrun all the nodes
|
||||
# Return all the nodes
|
||||
return [parent_node, file_node, attribdelete, null]
|
||||
|
|
|
|||
|
|
@ -21,40 +21,17 @@ class ExtractFBX(publish.Extractor):
|
|||
|
||||
# get rop node
|
||||
ropnode = hou.node(instance.data.get("instance_node"))
|
||||
output_node = ropnode.evalParm("sopoutput")
|
||||
|
||||
# get staging_dir and file_name
|
||||
staging_dir = os.path.normpath(os.path.dirname(output_node))
|
||||
file_name = os.path.basename(output_node)
|
||||
|
||||
# render rop
|
||||
self.log.debug("Writing FBX '%s' to '%s'",file_name, staging_dir)
|
||||
render_rop(ropnode)
|
||||
|
||||
# get required data
|
||||
file_name, staging_dir = self.get_paths_data(ropnode)
|
||||
representation = self.get_representation(instance,
|
||||
file_name,
|
||||
staging_dir)
|
||||
|
||||
# set value type for 'representations' key to list
|
||||
if "representations" not in instance.data:
|
||||
instance.data["representations"] = []
|
||||
|
||||
# update instance data
|
||||
instance.data["stagingDir"] = staging_dir
|
||||
instance.data["representations"].append(representation)
|
||||
|
||||
def get_paths_data(self, ropnode):
|
||||
# Get the filename from the filename parameter
|
||||
output = ropnode.evalParm("sopoutput")
|
||||
|
||||
staging_dir = os.path.normpath(os.path.dirname(output))
|
||||
|
||||
file_name = os.path.basename(output)
|
||||
|
||||
self.log.info("Writing FBX '%s' to '%s'" % (file_name,
|
||||
staging_dir))
|
||||
|
||||
return file_name, staging_dir
|
||||
|
||||
def get_representation(self, instance,
|
||||
file_name, staging_dir):
|
||||
|
||||
# prepare representation
|
||||
representation = {
|
||||
"name": "fbx",
|
||||
"ext": "fbx",
|
||||
|
|
@ -67,4 +44,10 @@ class ExtractFBX(publish.Extractor):
|
|||
representation["frameStart"] = instance.data["frameStart"]
|
||||
representation["frameEnd"] = instance.data["frameEnd"]
|
||||
|
||||
return representation
|
||||
# set value type for 'representations' key to list
|
||||
if "representations" not in instance.data:
|
||||
instance.data["representations"] = []
|
||||
|
||||
# update instance data
|
||||
instance.data["stagingDir"] = staging_dir
|
||||
instance.data["representations"].append(representation)
|
||||
|
|
|
|||
|
|
@ -9,12 +9,13 @@ from openpype.hosts.houdini.api.action import (
|
|||
import hou
|
||||
|
||||
|
||||
class ValidateOutputNode(pyblish.api.InstancePlugin):
|
||||
class ValidateFBXOutputNode(pyblish.api.InstancePlugin):
|
||||
"""Validate the instance Output Node.
|
||||
|
||||
This will ensure:
|
||||
- The Output Node Path is set.
|
||||
- The Output Node Path refers to an existing object.
|
||||
- The Output Node is a Sop or Obj node.
|
||||
"""
|
||||
|
||||
order = pyblish.api.ValidatorOrder
|
||||
|
|
@ -17,7 +17,7 @@ class ValidateMeshIsStatic(pyblish.api.InstancePlugin,
|
|||
OptionalPyblishPluginMixin):
|
||||
"""Validate mesh is static.
|
||||
|
||||
It checks if output node is time dependant.
|
||||
It checks if output node is time dependent.
|
||||
"""
|
||||
|
||||
families = ["staticMesh"]
|
||||
|
|
|
|||
|
|
@ -0,0 +1,94 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""Validator for correct naming of Static Meshes."""
|
||||
import pyblish.api
|
||||
from openpype.pipeline import (
|
||||
PublishValidationError,
|
||||
OptionalPyblishPluginMixin
|
||||
)
|
||||
from openpype.pipeline.publish import (
|
||||
ValidateContentsOrder,
|
||||
RepairAction,
|
||||
)
|
||||
from openpype.hosts.houdini.api.action import SelectInvalidAction
|
||||
from openpype.pipeline.create import get_subset_name
|
||||
|
||||
import hou
|
||||
|
||||
|
||||
class FixSubsetNameAction(RepairAction):
|
||||
label = "Fix Subset Name"
|
||||
|
||||
|
||||
class ValidateSubsetName(pyblish.api.InstancePlugin,
|
||||
OptionalPyblishPluginMixin):
|
||||
"""Validate Subset name.
|
||||
|
||||
"""
|
||||
|
||||
families = ["staticMesh"]
|
||||
hosts = ["houdini"]
|
||||
label = "Validate Subset Name"
|
||||
order = ValidateContentsOrder + 0.1
|
||||
actions = [FixSubsetNameAction, SelectInvalidAction]
|
||||
|
||||
optional = True
|
||||
|
||||
|
||||
def process(self, instance):
|
||||
|
||||
if not self.is_active(instance.data):
|
||||
return
|
||||
|
||||
invalid = self.get_invalid(instance)
|
||||
if invalid:
|
||||
nodes = [n.path() for n in invalid]
|
||||
raise PublishValidationError(
|
||||
"See log for details. "
|
||||
"Invalid nodes: {0}".format(nodes)
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def get_invalid(cls, instance):
|
||||
|
||||
invalid = []
|
||||
|
||||
rop_node = hou.node(instance.data["instance_node"])
|
||||
|
||||
# Check subset name
|
||||
subset_name = get_subset_name(
|
||||
family=instance.data["family"],
|
||||
variant=instance.data["variant"],
|
||||
task_name=instance.data["task"],
|
||||
asset_doc=instance.data["assetEntity"],
|
||||
dynamic_data={"asset":instance.data["asset"]}
|
||||
)
|
||||
|
||||
if instance.data.get("subset") != subset_name:
|
||||
invalid.append(rop_node)
|
||||
cls.log.error(
|
||||
"Invalid subset name on rop node '%s' should be '%s'.",
|
||||
rop_node.path(), subset_name
|
||||
)
|
||||
|
||||
return invalid
|
||||
|
||||
@classmethod
|
||||
def repair(cls, instance):
|
||||
rop_node = hou.node(instance.data["instance_node"])
|
||||
|
||||
# Check subset name
|
||||
subset_name = get_subset_name(
|
||||
family=instance.data["family"],
|
||||
variant=instance.data["variant"],
|
||||
task_name=instance.data["task"],
|
||||
asset_doc=instance.data["assetEntity"],
|
||||
dynamic_data={"asset":instance.data["asset"]}
|
||||
)
|
||||
|
||||
instance.data["subset"] = subset_name
|
||||
rop_node.parm("subset").set(subset_name)
|
||||
|
||||
cls.log.debug(
|
||||
"Subset name on rop node '%s' has been set to '%s'.",
|
||||
rop_node.path(), subset_name
|
||||
)
|
||||
|
|
@ -35,9 +35,12 @@ class ValidateUnrealStaticMeshName(pyblish.api.InstancePlugin,
|
|||
actions = [SelectInvalidAction]
|
||||
|
||||
optional = True
|
||||
collision_prefixes = []
|
||||
static_mesh_prefix = ""
|
||||
|
||||
@classmethod
|
||||
def apply_settings(cls, project_settings, system_settings):
|
||||
|
||||
settings = (
|
||||
project_settings["houdini"]["create"]["CreateUnrealStaticMesh"]
|
||||
)
|
||||
|
|
@ -51,7 +54,7 @@ class ValidateUnrealStaticMeshName(pyblish.api.InstancePlugin,
|
|||
|
||||
invalid = self.get_invalid(instance)
|
||||
if invalid:
|
||||
nodes = [n.path() for n in invalid if isinstance(n, hou.Node)]
|
||||
nodes = [n.path() for n in invalid]
|
||||
raise PublishValidationError(
|
||||
"See log for details. "
|
||||
"Invalid nodes: {0}".format(nodes)
|
||||
|
|
@ -70,7 +73,7 @@ class ValidateUnrealStaticMeshName(pyblish.api.InstancePlugin,
|
|||
)
|
||||
return
|
||||
|
||||
if not rop_node.evalParm('buildfrompath'):
|
||||
if rop_node.evalParm("buildfrompath"):
|
||||
# This validator doesn't support naming check if
|
||||
# building hierarchy from path' is used
|
||||
cls.log.info(
|
||||
|
|
@ -91,18 +94,4 @@ class ValidateUnrealStaticMeshName(pyblish.api.InstancePlugin,
|
|||
)
|
||||
break
|
||||
|
||||
# Check subset name
|
||||
subset_name = "{}_{}{}".format(
|
||||
cls.static_mesh_prefix,
|
||||
instance.data["asset"],
|
||||
instance.data.get("variant", "")
|
||||
)
|
||||
|
||||
if instance.data.get("subset") != subset_name:
|
||||
invalid.append(rop_node)
|
||||
cls.log.error(
|
||||
"Invalid subset name on rop node '%s' should be '%s'.",
|
||||
rop_node.path(), subset_name
|
||||
)
|
||||
|
||||
return invalid
|
||||
|
|
|
|||
|
|
@ -111,6 +111,16 @@
|
|||
"optional": true,
|
||||
"active": true
|
||||
},
|
||||
"ValidateSubsetName": {
|
||||
"enabled": true,
|
||||
"optional": true,
|
||||
"active": true
|
||||
},
|
||||
"ValidateMeshIsStatic": {
|
||||
"enabled": true,
|
||||
"optional": true,
|
||||
"active": true
|
||||
},
|
||||
"ValidateUnrealStaticMeshName": {
|
||||
"enabled": true,
|
||||
"optional": true,
|
||||
|
|
|
|||
|
|
@ -44,6 +44,14 @@
|
|||
"key": "ValidateContainers",
|
||||
"label": "ValidateContainers"
|
||||
},
|
||||
{
|
||||
"key": "ValidateSubsetName",
|
||||
"label": "Validate Subset Name"
|
||||
},
|
||||
{
|
||||
"key": "ValidateMeshIsStatic",
|
||||
"label": "Validate Mesh is Static"
|
||||
},
|
||||
{
|
||||
"key": "ValidateUnrealStaticMeshName",
|
||||
"label": "Validate Unreal Static Mesh Name"
|
||||
|
|
|
|||
|
|
@ -164,6 +164,12 @@ class PublishPluginsModel(BaseSettingsModel):
|
|||
ValidateContainers: ValidateContainersModel = Field(
|
||||
default_factory=ValidateContainersModel,
|
||||
title="Validate Latest Containers.")
|
||||
ValidateSubsetName: ValidateContainersModel = Field(
|
||||
default_factory=ValidateContainersModel,
|
||||
title="Validate Subset Name.")
|
||||
ValidateMeshIsStatic: ValidateContainersModel = Field(
|
||||
default_factory=ValidateContainersModel,
|
||||
title="Validate Mesh is Static.")
|
||||
ValidateUnrealStaticMeshName: ValidateContainersModel = Field(
|
||||
default_factory=ValidateContainersModel,
|
||||
title="Validate Unreal Static Mesh Name.")
|
||||
|
|
@ -187,6 +193,16 @@ DEFAULT_HOUDINI_PUBLISH_SETTINGS = {
|
|||
"optional": True,
|
||||
"active": True
|
||||
},
|
||||
"ValidateSubsetName": {
|
||||
"enabled": True,
|
||||
"optional": True,
|
||||
"active": True
|
||||
},
|
||||
"ValidateMeshIsStatic": {
|
||||
"enabled": True,
|
||||
"optional": True,
|
||||
"active": True
|
||||
},
|
||||
"ValidateUnrealStaticMeshName": {
|
||||
"enabled": True,
|
||||
"optional": True,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue