box module

class amulet.api.selection.Selection(boxes=None)[source]

Bases: object

Holding class for multiple SubSelectionBoxes which allows for non-rectangular and non-contiguous selections

add_box(other, do_merge_check=True)[source]

Adds a SubSelectionBox to the selection box. If other is next to another SubSelectionBox in the selection, matches in any 2 dimensions, and do_merge_check is True, then the 2 boxes will be combined into 1 box.

Parameters:
  • other (SubSelectionBox) – The box to add
  • do_merge_check (bool) – Boolean flag to merge boxes if able
intersection(other)[source]

Get a new Selection that represents the area contained within self and other

Return type:Selection
intersects(other)[source]

Check if self and other intersect

Return type:bool
is_contiguous

Does the Selection represent one connected region (True) or multiple separated regions (False)

Return type:bool
is_rectangular

Checks if the Selection is a rectangle

Return type:bool
Returns:True is the selection is a rectangle, False otherwise
subboxes

Returns an iterator of the SubSelectionBoxes in the Selection

Return type:Iterator[SubSelectionBox]
Returns:An iterator of the SubSelectionBoxes
class amulet.api.selection.SubSelectionBox(min_point, max_point)[source]

Bases: object

A SubSelectionBox is a box that can represent the entirety of a Selection or just a subsection of one. This allows for non-rectangular and non-contiguous selections.

The both the minimum and maximum coordinate points are inclusive.

intersection(other)[source]

Get a SubSelectionBox that represents the region contained within self and other. Box may be a zero width box. Use self.intersects to check that it actually intersects.

Return type:SubSelectionBox
intersects(other)[source]

Method to check whether this instance of SubSelectionBox intersects another SubSelectionBox

Parameters:other (SubSelectionBox) – The other SubSelectionBox to check for intersection
Return type:bool
Returns:True if the two SubSelectionBoxes intersect, False otherwise
max

The maximum point of the box

Return type:Tuple[int, int, int]
max_x

The maximum x coordinate

Return type:int
max_y

The maximum y coordinate

Return type:int
max_z

The maximum z coordinate

Return type:int
min

The minimum point of the box

Return type:Tuple[int, int, int]
min_x

The minimum x coordinate

Return type:int
min_y

The minimum y coordinate

Return type:int
min_z

The minimum z coordinate

Return type:int
shape

The shape of the box

Return type:Tuple[int, int, int]
size_x

The length of the box in the x axis

Return type:int
size_y

The length of the box in the y axis

Return type:int
size_z

The length of the box in the z axis

Return type:int
slice

Converts the SubSelectionBoxes minimum/maximum coordinates into slice arguments

Return type:Tuple[slice, slice, slice]
Returns:The SubSelectionBoxes coordinates as slices in (x,y,z) order