Skip to content

Commit

Permalink
Update mxvalidate for data library referencing (AcademySoftwareFounda…
Browse files Browse the repository at this point in the history
…tion#2075)

This changelist updates the mxvalidate.py script to take advantage of data library referencing. i.e. `Document::setDataLibrary`.
  • Loading branch information
jstone-lucasfilm authored Oct 17, 2024
1 parent 12cf234 commit 9f9a57a
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions python/Scripts/mxvalidate.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,31 @@ def main():
parser.add_argument(dest="inputFilename", help="Filename of the input document.")
opts = parser.parse_args()

doc = mx.createDocument()
try:
mx.readFromXmlFile(doc, opts.inputFilename)
except mx.ExceptionFileMissing as err:
print(err)
sys.exit(0)

# Load standard libraries if requested.
if opts.stdlib:
stdlib = mx.createDocument()
try:
mx.loadLibraries(mx.getDefaultDataLibraryFolders(), mx.getDefaultDataSearchPath(), stdlib)
except Exception as err:
print(err)
sys.exit(0)
doc.importLibrary(stdlib)

(valid, message) = doc.validate()
# Read and validate the source document.
doc = mx.createDocument()
try:
mx.readFromXmlFile(doc, opts.inputFilename)
doc.setDataLibrary(stdlib)
except mx.ExceptionFileMissing as err:
print(err)
sys.exit(0)
valid, message = doc.validate()
if (valid):
print("%s is a valid MaterialX document in v%s" % (opts.inputFilename, mx.getVersionString()))
else:
print("%s is not a valid MaterialX document in v%s" % (opts.inputFilename, mx.getVersionString()))
print(message)

# Generate verbose output if requested.
if opts.verbose:
nodegraphs = doc.getNodeGraphs()
materials = doc.getMaterialNodes()
Expand Down

0 comments on commit 9f9a57a

Please sign in to comment.