Plush

Mesh#

plupy · Type index

Module: plupy · obtained from plupy.data.meshes[...], .new(name, primitive=...), .import_file(path)

A mesh datablock. Its model file can be checked against, or replaced by, another GLB without changing its ID.

Meshes returned by plupy.data.meshes or plupy.data.of_type("mesh") have two model-file methods. Both take a path to a .glb (absolute, or relative to the script's working directory, the project root).

class Mesh(DataBlock)

Inherits DataBlock: its members are documented there.

Usage and examples

Members: check_model · replace_model

check_model#

check_model(path: str) -> dict

Compare a GLB with this mesh's dependents (animation clips, bone paths in sockets/masks/components). Writes nothing.

Returns a dict: compatible, source, problems, notes, dependents.

Compares the file with everything that uses the mesh and writes nothing. Result keys: compatible (bool), source (the mesh's current source path), problems (clips an animation binding uses, and bone paths that sockets, masks or component properties name, that the file lacks), notes (the material is kept, several sections share one material, a very large file) and dependents ("type: name" strings).

replace_model#

replace_model(path: str, *, force: bool=False) -> dict

Point this mesh at another GLB, keeping its ID so bindings, masks, sockets and objects follow.

Raises PlupyError when the new model lacks clips or bones the dependents use, unless force=True. A file inside the project is used in place; any other file is copied to Assets/Models. Returns the same dict as check_model, with the resulting source.

Points the mesh at the file, keeping its ID so bindings, masks, sockets and objects follow. A file inside the project is used in place; another file is copied to Assets/Models. Raises PlupyError listing the problems, and changes nothing, unless force=True. Returns the check_model dict with source set to the new source path. Part of the current edit's Undo step.

mesh = plupy.data.meshes["Enemy mesh"]
report = mesh.check_model("Assets/Models/new_character.glb")
if report["compatible"]:
    mesh.replace_model("Assets/Models/new_character.glb")

DataBlock · PlupyError · edit

Source#