Added validator to verify that the instance is not empty

This commit is contained in:
Simone Barbieri 2023-11-06 10:30:13 +00:00
parent 8f4d490af2
commit 7b9c6c3b99
5 changed files with 62 additions and 14 deletions

View file

@ -0,0 +1,18 @@
import bpy
import pyblish.api
class ValidateInstanceEmpty(pyblish.api.InstancePlugin):
"""Validator to verify that the instance is not empty"""
order = pyblish.api.ValidatorOrder - 0.01
hosts = ["blender"]
families = ["blendScene"]
label = "Validate Instance is not Empty"
optional = False
def process(self, instance):
collection = bpy.data.collections[instance.name]
if not (collection.objects or collection.children):
raise RuntimeError(f"Instance {instance.name} is empty.")

View file

@ -71,6 +71,11 @@
"optional": false,
"active": true
},
"ValidateInstanceEmpty": {
"enabled": true,
"optional": false,
"active": true
},
"ExtractBlend": {
"enabled": true,
"optional": true,

View file

@ -79,6 +79,22 @@
}
]
},
{
"type": "collapsible-wrap",
"label": "BlendScene",
"children": [
{
"type": "schema_template",
"name": "template_publish_plugin",
"template_data": [
{
"key": "ValidateInstanceEmpty",
"label": "Validate Instance is not Empty"
}
]
}
]
},
{
"type": "collapsible-wrap",
"label": "Render",

View file

@ -61,26 +61,16 @@ class PublishPuginsModel(BaseSettingsModel):
ValidateCameraZeroKeyframe: ValidatePluginModel = Field(
default_factory=ValidatePluginModel,
title="Validate Camera Zero Keyframe",
section="Validators"
section="General Validators"
)
ValidateFileSaved: ValidateFileSavedModel = Field(
default_factory=ValidateFileSavedModel,
title="Validate File Saved",
section="Validators"
)
ValidateRenderCameraIsSet: ValidatePluginModel = Field(
default_factory=ValidatePluginModel,
title="Validate Render Camera Is Set",
section="Validators"
)
ValidateDeadlinePublish: ValidatePluginModel = Field(
default_factory=ValidatePluginModel,
title="Validate Render Output for Deadline",
section="Validators"
)
ValidateMeshHasUvs: ValidatePluginModel = Field(
default_factory=ValidatePluginModel,
title="Validate Mesh Has Uvs"
title="Validate Mesh Has Uvs",
section="Model Validators"
)
ValidateMeshNoNegativeScale: ValidatePluginModel = Field(
default_factory=ValidatePluginModel,
@ -94,6 +84,20 @@ class PublishPuginsModel(BaseSettingsModel):
default_factory=ValidatePluginModel,
title="Validate No Colons In Name"
)
ValidateInstanceEmpty: ValidatePluginModel = Field(
default_factory=ValidatePluginModel,
title="Validate Instance is not Empty",
section="BlendScene Validators"
)
ValidateRenderCameraIsSet: ValidatePluginModel = Field(
default_factory=ValidatePluginModel,
title="Validate Render Camera Is Set",
section="Render Validators"
)
ValidateDeadlinePublish: ValidatePluginModel = Field(
default_factory=ValidatePluginModel,
title="Validate Render Output for Deadline",
)
ExtractBlend: ExtractBlendModel = Field(
default_factory=ExtractBlendModel,
title="Extract Blend",
@ -179,6 +183,11 @@ DEFAULT_BLENDER_PUBLISH_SETTINGS = {
"optional": False,
"active": True
},
"ValidateInstanceEmpty": {
"enabled": True,
"optional": False,
"active": True
},
"ExtractBlend": {
"enabled": True,
"optional": True,

View file

@ -1 +1 @@
__version__ = "0.1.3"
__version__ = "0.1.5"