add top node validator

This commit is contained in:
Ondrej Samohel 2022-03-25 10:52:54 +01:00
parent 8f77e92d6f
commit 76bc7799f1
No known key found for this signature in database
GPG key ID: 02376E18990A97C6
3 changed files with 53 additions and 2 deletions

View file

@ -22,8 +22,9 @@ class ExtractUnrealStaticMesh(openpype.api.Extractor):
families = ["staticMesh"]
def process(self, instance):
geo = instance.data.get("geometryMembers", [])
members = geo + instance.data.get("collisionMembers", [])
members = instance.data.get("geometryMembers", [])
if instance.data.get("collisionMembers"):
members = members + instance.data.get("collisionMembers")
fbx_exporter = fbx.FBXExtractor(log=self.log)

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<root>
<error id="main">
<title>Skeletal Mesh Top Node</title>
<description>## Skeletal meshes needs common root
Skeletal meshes and their joints must be under one common root.
### How to repair?
Make sure all geometry and joints resides under same root.
</description>
</error>
</root>

View file

@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
import pyblish.api
import openpype.api
from openpype.pipeline import PublishXmlValidationError
from maya import cmds
class ValidateSkeletalMeshHierarchy(pyblish.api.InstancePlugin):
"""Adheres to the content of 'model' family
- Must have one top group. (configurable)
- Must only contain: transforms, meshes and groups
"""
order = openpype.api.ValidateContentsOrder
hosts = ["maya"]
families = ["skeletalMesh"]
label = "Skeletal Mesh Top Node"
def process(self, instance):
geo = instance.data.get("geometry")
joints = instance.data.get("joints")
joints_parents = cmds.ls(joints, long=True)[0].split("|")[1:-1]
geo_parents = cmds.ls(geo, long=True)[0].split("|")[1:-1]
self.log.info(joints_parents)
self.log.info(geo_parents)
self.log.info(set(joints_parents + geo_parents))
if len(set(joints_parents + geo_parents)) != 1:
raise PublishXmlValidationError(
self,
"Multiple roots on geometry or joints."
)