MaterialX.PyMaterialXFormat Module

Inheritance diagram of MaterialX.PyMaterialXFormat

Cross-platform support for document serialization and file utilities.

exception MaterialX.PyMaterialXFormat.ExceptionFileMissing

Bases: Exception

add_note()

Exception.add_note(note) – add a note to the exception

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

args
exception MaterialX.PyMaterialXFormat.ExceptionParseError

Bases: Exception

add_note()

Exception.add_note(note) – add a note to the exception

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

args
class MaterialX.PyMaterialXFormat.FilePath(*args, **kwargs)

Bases: pybind11_object

A generic file path, supporting both syntactic and file system operations.

Overloaded function.

  1. __init__(self: MaterialX.PyMaterialXFormat.FilePath) -> None

  2. __init__(self: MaterialX.PyMaterialXFormat.FilePath, arg0: str) -> None

static getCurrentPath() MaterialX.PyMaterialXFormat.FilePath

Return the current working directory of the file system.

static getModulePath() MaterialX.PyMaterialXFormat.FilePath

Return the directory containing the executable module.

addExtension(self: MaterialX.PyMaterialXFormat.FilePath, arg0: str) None

Add a file extension to the given path.

asString(self: MaterialX.PyMaterialXFormat.FilePath, format: MaterialX.PyMaterialXFormat.Format = <Format.FormatWindows: 0>) str

Return this path as a standard string with the given format.

createDirectory(self: MaterialX.PyMaterialXFormat.FilePath, recursive: bool = False) None

Create a directory on the file system at the given path.

If recursive is true, any missing parent directories will be created as well.

exists(self: MaterialX.PyMaterialXFormat.FilePath) bool

Return true if the given path exists on the file system.

getBaseName(self: MaterialX.PyMaterialXFormat.FilePath) str

Return the base name of the given path, with leading directory information removed.

getExtension(self: MaterialX.PyMaterialXFormat.FilePath) str

Return the file extension of the given path.

getFilesInDirectory(self: MaterialX.PyMaterialXFormat.FilePath, arg0: str) list[MaterialX.PyMaterialXFormat.FilePath]

Return a vector of all files in the given directory with the given extension.

If extension is empty all files are returned.

getNormalized(self: MaterialX.PyMaterialXFormat.FilePath) MaterialX.PyMaterialXFormat.FilePath

Return a normalized version of the given path, collapsing current path and parent path references so that ‘a/.

/b’ and ‘c/../d/../a/b’ become ‘a/b’.

getParentPath(self: MaterialX.PyMaterialXFormat.FilePath) MaterialX.PyMaterialXFormat.FilePath

Return the parent directory of the given path, if any.

If no parent directory is present, then the empty path is returned.

getSubDirectories(self: MaterialX.PyMaterialXFormat.FilePath) list[MaterialX.PyMaterialXFormat.FilePath]

Return a vector of all directories at or beneath the given path.

isAbsolute(self: MaterialX.PyMaterialXFormat.FilePath) bool

Return true if the given path is absolute.

isDirectory(self: MaterialX.PyMaterialXFormat.FilePath) bool

Return true if the given path is a directory on the file system.

isEmpty(self: MaterialX.PyMaterialXFormat.FilePath) bool

Return true if the given path is empty.

removeExtension(self: MaterialX.PyMaterialXFormat.FilePath) None

Remove the file extension, if any, from the given path.

size(self: MaterialX.PyMaterialXFormat.FilePath) int

Return the number of strings in the path.

class MaterialX.PyMaterialXFormat.FileSearchPath(*args, **kwargs)

Bases: pybind11_object

A sequence of file paths, which may be queried to find the first instance of a given filename on the file system.

Overloaded function.

  1. __init__(self: MaterialX.PyMaterialXFormat.FileSearchPath) -> None

  2. __init__(self: MaterialX.PyMaterialXFormat.FileSearchPath, searchPath: str, sep: str = ‘;’) -> None

append(*args, **kwargs)

Overloaded function.

  1. append(self: MaterialX.PyMaterialXFormat.FileSearchPath, arg0: MaterialX.PyMaterialXFormat.FilePath) -> None

  2. append(self: MaterialX.PyMaterialXFormat.FileSearchPath, arg0: MaterialX.PyMaterialXFormat.FileSearchPath) -> None

asString(self: MaterialX.PyMaterialXFormat.FileSearchPath, sep: str = ';') str

Convert this sequence to a string using the given separator.

clear(self: MaterialX.PyMaterialXFormat.FileSearchPath) None

Clear all paths from the sequence.

find(self: MaterialX.PyMaterialXFormat.FileSearchPath, arg0: MaterialX.PyMaterialXFormat.FilePath) MaterialX.PyMaterialXFormat.FilePath

Given an input filename, iterate through each path in this sequence, returning the first combined path found on the file system.

On success, the combined path is returned; otherwise the original filename is returned unmodified.

isEmpty(self: MaterialX.PyMaterialXFormat.FileSearchPath) bool

Return true if the search path is empty.

prepend(self: MaterialX.PyMaterialXFormat.FileSearchPath, arg0: MaterialX.PyMaterialXFormat.FilePath) None

Prepend the given path to the sequence.

size(self: MaterialX.PyMaterialXFormat.FileSearchPath) int

Return the number of paths in the sequence.

class MaterialX.PyMaterialXFormat.Format(self: MaterialX.PyMaterialXFormat.Format, value: SupportsInt)

Bases: pybind11_object

Members:

FormatWindows

FormatPosix

FormatNative

FormatNative = <Format.FormatWindows: 0>
FormatPosix = <Format.FormatPosix: 1>
FormatWindows = <Format.FormatWindows: 0>
Format.name -> str
property value
class MaterialX.PyMaterialXFormat.Type(self: MaterialX.PyMaterialXFormat.Type, value: SupportsInt)

Bases: pybind11_object

Members:

TypeRelative

TypeAbsolute

TypeNetwork

TypeAbsolute = <Type.TypeAbsolute: 1>
TypeNetwork = <Type.TypeNetwork: 2>
TypeRelative = <Type.TypeRelative: 0>
Type.name -> str
property value
class MaterialX.PyMaterialXFormat.XmlReadOptions(self: MaterialX.PyMaterialXFormat.XmlReadOptions)

Bases: pybind11_object

A set of options for controlling the behavior of XML read functions.

property parentXIncludes
property readComments
property readNewlines
property readXIncludeFunction
property upgradeVersion
class MaterialX.PyMaterialXFormat.XmlWriteOptions(self: MaterialX.PyMaterialXFormat.XmlWriteOptions)

Bases: pybind11_object

A set of options for controlling the behavior of XML write functions.

property elementPredicate
property writeXIncludeEnable
MaterialX.PyMaterialXFormat.flattenFilenames(doc: MaterialX.PyMaterialXCore.Document, searchPath: MaterialX.PyMaterialXFormat.FileSearchPath = <MaterialX.PyMaterialXFormat.FileSearchPath object at 0x00000251AFEA4CB0>, customResolver: MaterialX.PyMaterialXCore.StringResolver = None) None

Flatten all filenames in the given document, applying string resolvers at the scope of each element and removing all fileprefix attributes.

Parameters:
  • doc – The document to modify.

  • searchPath – An optional search path for relative to absolute path conversion.

  • customResolver – An optional custom resolver to apply.

MaterialX.PyMaterialXFormat.getEnvironmentPath(sep: str = ';') MaterialX.PyMaterialXFormat.FileSearchPath

Return a FileSearchPath object from search path environment variable.

MaterialX.PyMaterialXFormat.getSourceSearchPath(arg0: MaterialX.PyMaterialXCore.Document) MaterialX.PyMaterialXFormat.FileSearchPath

Return a file search path containing the parent folder of each source URI in the given document.

MaterialX.PyMaterialXFormat.getSubdirectories(arg0: collections.abc.Sequence[MaterialX.PyMaterialXFormat.FilePath], arg1: MaterialX.PyMaterialXFormat.FileSearchPath, arg2: collections.abc.Sequence[MaterialX.PyMaterialXFormat.FilePath]) None

Get all subdirectories for a given set of directories and search paths.

MaterialX.PyMaterialXFormat.loadDocuments(rootPath: MaterialX.PyMaterialXFormat.FilePath, searchPath: MaterialX.PyMaterialXFormat.FileSearchPath, skipFiles: collections.abc.Set[str], includeFiles: collections.abc.Set[str], documents: collections.abc.Sequence[MaterialX.PyMaterialXCore.Document], documentsPaths: collections.abc.Sequence[str], readOptions: MaterialX.PyMaterialXFormat.XmlReadOptions = None, errors: collections.abc.Sequence[str] = None) None

Scans for all documents under a root path and returns documents which can be loaded.

MaterialX.PyMaterialXFormat.loadLibraries(libraryFolders: collections.abc.Sequence[MaterialX.PyMaterialXFormat.FilePath], searchPath: MaterialX.PyMaterialXFormat.FileSearchPath, doc: MaterialX.PyMaterialXCore.Document, excludeFiles: collections.abc.Set[str] = set(), readOptions: MaterialX.PyMaterialXFormat.XmlReadOptions = None) set[str]

Load all MaterialX files within the given library folders into a document, using the given search path to locate the folders on the file system.

MaterialX.PyMaterialXFormat.loadLibrary(file: MaterialX.PyMaterialXFormat.FilePath, doc: MaterialX.PyMaterialXCore.Document, searchPath: MaterialX.PyMaterialXFormat.FileSearchPath = <MaterialX.PyMaterialXFormat.FileSearchPath object at 0x00000251AFEA4B30>, readOptions: MaterialX.PyMaterialXFormat.XmlReadOptions = None) None

Load a given MaterialX library into a document.

MaterialX.PyMaterialXFormat.prependXInclude(arg0: MaterialX.PyMaterialXCore.Document, arg1: MaterialX.PyMaterialXFormat.FilePath) None
MaterialX.PyMaterialXFormat.readFile(arg0: MaterialX.PyMaterialXFormat.FilePath) str

Read the given file and return a string containing its contents; if the read is not successful, then the empty string is returned.

MaterialX.PyMaterialXFormat.readFromXmlFileBase(doc: MaterialX.PyMaterialXCore.Document, filename: MaterialX.PyMaterialXFormat.FilePath, searchPath: MaterialX.PyMaterialXFormat.FileSearchPath = <MaterialX.PyMaterialXFormat.FileSearchPath object at 0x00000251AFE51830>, readOptions: MaterialX.PyMaterialXFormat.XmlReadOptions = None) None

Read a Document as XML from the given filename.

Parameters:
  • doc – The Document into which data is read.

  • filename – The filename from which data is read. This argument can be supplied either as a FilePath or a standard string.

  • searchPath – An optional sequence of file paths that will be applied in order when searching for the given file and its includes. This argument can be supplied either as a FileSearchPath, or as a standard string with paths separated by the PATH_SEPARATOR character.

  • readOptions – An optional pointer to an XmlReadOptions object. If provided, then the given options will affect the behavior of the read function. Defaults to a null pointer.

MaterialX.PyMaterialXFormat.readFromXmlString(doc: MaterialX.PyMaterialXCore.Document, str: str, searchPath: MaterialX.PyMaterialXFormat.FileSearchPath = <MaterialX.PyMaterialXFormat.FileSearchPath object at 0x00000251AFE81AF0>, readOptions: MaterialX.PyMaterialXFormat.XmlReadOptions = None) None

Read a Document as XML from the given string.

Parameters:
  • doc – The Document into which data is read.

  • str – The string from which data is read.

  • searchPath – An optional sequence of file paths that will be applied in order when searching for the given file and its includes. This argument can be supplied either as a FileSearchPath, or as a standard string with paths separated by the PATH_SEPARATOR character.

  • readOptions – An optional pointer to an XmlReadOptions object. If provided, then the given options will affect the behavior of the read function. Defaults to a null pointer.

MaterialX.PyMaterialXFormat.writeToXmlFile(doc: MaterialX.PyMaterialXCore.Document, filename: MaterialX.PyMaterialXFormat.FilePath, writeOptions: MaterialX.PyMaterialXFormat.XmlWriteOptions = None) None
MaterialX.PyMaterialXFormat.writeToXmlString(doc: MaterialX.PyMaterialXCore.Document, writeOptions: MaterialX.PyMaterialXFormat.XmlWriteOptions = None) str