Skip to content
Gaspar edited this page Jan 20, 2024 · 7 revisions

Class Brush

Represents a brush defined by a list of faces. A brush is a convex polyhedron defined by the intersection of half-spaces.

Attributes

Attribute Type Description Note
id int The unique identifier for the brush
faces list[Face] The faces that compose the brush
face_counter int Counter for assigning unique IDs to faces
_vertices list[Point] Cached list of vertices for the brush To get value use vertices property instead
_origin Optional[Point] Cached centroid of the brush To get value use origin property instead

Methods:

__init__(self, faces: Union[List[Face], None]=None)

Constructor method for the Brush class.

b = Brush()
# faces = [face1, face2, face3, face4...]
b = Brush(faces)

add_face(self, *args: Union[Face, list[Face]])

Add face(es) to the brush.

# Add faces individually
b.add_face(face1)
b.add_face(face2)
# Add all faces at once
b.add_face(face1, face2)

bounding_box_origin(self)

Return the origin of the bounding box enclosing the brush.

bbox_center = b.bounding_box_origin()

centroid(self)

Return the origin (centroid) of the brush.

brush_origin = b.centroid()

copy(self)

Create a deep copy of the brush.

b_copy = b.copy()

has_texture(self, name: str, exact: bool = True)

Check if any brush face has a specific texture.

if b.has_texture('AAATRIGGER', exact=True)
   # ...

move_by(self, x: float, y: float, z: float)

Move the brush by specified offsets.

b.move_by(10,10,10)

move_to(self, x: float, y: float, z: float, centroid=True, bbox=False)

Move the brush to a specific coordinate.

b.move_to(256,256,0, centroid=True, bbox=False)

replace_texture(self, old: str, new: str)

Replace a texture on faces that have the specified texture.

b.replace_texture('black', 'null')

rotate_x(self, angle: float, center: Point = Point(0,0,0))

Rotate the brush around the X-axis.

b.rotate_x(45)

rotate_y(self, angle: float, center: Point = Point(0,0,0))

Rotate the brush around the Y-axis.

b.rotate_y(45)

rotate_z(self, angle: float, center: Point = Point(0,0,0))

Rotate the brush around the Z-axis.

b.rotate_z(45)

rotate_xyz(self, phi, theta, psi)

Rotate the brush around the XYZ axes.

b.rotate_xyz(45,45,45)

rotate_around_axis(self, angle: float, axis: Vector3)

Rotate the brush around a specified axis.

b.rotate_around_axis(45, Vector3(1,1,1))

set_texture(self, new_texture: str)

Set a new texture for all faces in the brush.

b.set_texture('null')

_get_vertices(self)

Return the vertices of the brush.


__repr__(self)

Return a string representation of the brush.


__iter__(self)

Return an iterator over the faces of the brush.

for face in b:
  # ...

Properties:


vertices

Get a list of vertices of the brush.

brush_verts = b.vertices

origin

Get the origin (centroid) of the brush.

brush_origin = b.origin

edges

Get a list of edges of the brush.

brush_edges = b.edges

Next: Class Face