Skip to content

Scene

Scene

A Maya scene file (.mb or .ma).

Attributes

connections

connections: list[Connection]

connectAttr statements, in file order.

file_info

file_info: dict[str, str]

fileInfo entries.

nested_references

nested_references: list[Reference]

References made by referenced files, as recorded in this file.

nodes

nodes: list[Node]

Nodes the file creates or edits, in file order.

path

path: Path | None

File the scene was parsed from or last saved to.

plugins

plugins: list[Plugin]

Required plugins (requires), with the node types used from them.

references

references: list[Reference]

References made by this file (depth 1).

version

version: str

Maya version that saved the file (2022, 2018ff09 for Maya 2019).

Methods:

dependencies

dependencies(
    extra: ExtraAttributes | None = None,
) -> list[Dependency]

Every file path the scene stores: references at every depth, file attributes, then file attributes set on referenced nodes.

See file_attributes for extra; for reference edits its attribute names apply to every node type, since the edited node's type is not stored in this file.

file_attributes

file_attributes(
    extra: ExtraAttributes | None = None,
) -> list[Attribute]

Stored string values of the attributes that hold file paths.

extra adds attributes per node type, as stored short names (for example {"transform": ["icon_path"]}); subtypes inherit them.

node

node(name: str) -> Node

The node named name: a unique short name, or a DAG path.

reference_edits

reference_edits() -> list[tuple[Attribute, ReferenceEdits]]

The edits each reference node records, with the attribute holding them.

remap_paths

remap_paths(
    remap: Callable[[str], str | None],
    extra: ExtraAttributes | None = None,
) -> int

Replace every stored file path p with remap(p); return how many changed.

Covers everything dependencies lists. remap returns the new path, or None (or p) to keep it; it sees paths exactly as stored, with no normalisation. See dependencies for extra.

replace_strings

replace_strings(replace: Callable[[str], str]) -> int

Put the names and strings the file stores through replace, like a text replace over the whole file; return how many changed. .mb only.

Covered: node names and parents, the nodes named by connections, relationships, instances and reference edits, the values set by reference edits, string attribute values (paths, notes, expression and script MEL), references (path, namespace, reference node, cached options), fileInfo, and the externalContentTable (CRCs recomputed). Attribute names, node types, plugins and default nodes are left alone, everywhere: a match in an attribute name changes nothing.

Names stay consistent when replace changes a name the same way wherever it appears: on its own, in a DAG path (|grp|name), after a namespace (ns:name).

save

save(path: str | Path) -> None

Save to a new file; refuses to overwrite one (FileExistsError).

The write is atomic: bytes go to a temporary sibling file which then replaces the target. The format stays the one the scene was parsed from.

save_in_place

save_in_place() -> None

Overwrite the file this scene was parsed from or last saved to.