Added validator to check if file is saved

This commit is contained in:
Simone Barbieri 2023-08-23 16:55:31 +01:00
parent 0899091920
commit 028d15fc1e
3 changed files with 59 additions and 0 deletions

View file

@ -0,0 +1,20 @@
import bpy
import pyblish.api
class ValidateFileSaved(pyblish.api.InstancePlugin):
"""Validate that the workfile has been saved."""
order = pyblish.api.ValidatorOrder - 0.01
hosts = ["blender"]
label = "Validate File Saved"
optional = False
exclude_families = []
def process(self, instance):
if [ef for ef in self.exclude_families
if instance.data["family"] in ef]:
return
if bpy.data.is_dirty:
raise RuntimeError("Workfile is not saved.")

View file

@ -35,6 +35,12 @@
"optional": true,
"active": true
},
"ValidateFileSaved": {
"enabled": true,
"optional": false,
"active": true,
"exclude_families": []
},
"ValidateMeshHasUvs": {
"enabled": true,
"optional": true,

View file

@ -18,6 +18,39 @@
}
]
},
{
"type": "dict",
"collapsible": true,
"key": "ValidateFileSaved",
"label": "Validate File Saved",
"checkbox_key": "enabled",
"children": [
{
"type": "boolean",
"key": "enabled",
"label": "Enabled"
},
{
"type": "boolean",
"key": "optional",
"label": "Optional"
},
{
"type": "boolean",
"key": "active",
"label": "Active"
},
{
"type": "splitter"
},
{
"key": "exclude_families",
"label": "Exclude Families",
"type": "list",
"object_type": "text"
}
]
},
{
"type": "collapsible-wrap",
"label": "Model",