Skip to content

Models - Voxel Shape Module

anvil.api.models.voxel_shape

Builder for Bedrock voxel shape files (*.shape.json).

Built like a :class:~anvil.api.models.geometry.Geometry: a :class:VoxelShape only creates root groups, and a :class:_VoxelGroup creates boxes and child groups. Groups organise the shape and can be found again by name; the file itself is a flat list of every box, in the order they were added.

Example
shape = VoxelShape("table")
shape.group("top").box(min=(0, 12, 0), max=(16, 16, 16))

legs = shape.group("legs")
legs.box(min=(0, 0, 0), max=(2, 12, 2)).box(min=(14, 0, 14), max=(16, 12, 16))

BlockGeometry(table).block_culling(shape)

Documentation reference

VoxelShape

Bases: JsonFile[_VoxelShapeFile]

A voxel shape file (<name>.shape.json) built from a tree of groups.

The file is named after name. The shape identifier is <namespace>:<identifier_name> and defaults to name.

Documentation reference

boxes property

Every box of the shape, in the order they were added.

groups property

All groups, parents always before their children.

identifier property

The file's identifier.

identifier_name property

The name in the shape identifier.

name property

The identifier's name, without its namespace.

shape_identifier property

How a block's geometry references this shape: <namespace>:<identifier_name>.

__export__()

Exports the addon object after potentially shortening its content and replacing backslashes. Logs the event and writes the object to a file.

__schema__() classmethod

The JSON Schema (draft 2020-12) of this file: the schema of its _document_type, with the file's type as title and where it is written under x-anvil-file.

Raises:

Type Description
TypeError

When the class is an abstract file base, with no document type.

group(name)

Creates a root group and returns it.

queue(directory=None)

Queues the addon object for processing and logs the event.

Parameters:

Name Type Description Default
directory str

The directory of the addon object.

None

Returns:

Name Type Description
self 'JsonFile[D]'

The instance of the current JsonFile.