cam.slice#

BlenderCAM ‘slice.py’ © 2021 Alain Pelletier

Very simple slicing for 3D meshes, useful for plywood cutting. Completely rewritten April 2021.

Classes#

SliceObjectsSettings

Stores All Data for Machines

Functions#

slicing2d(ob, height)

Slice a 3D object at a specified height and convert it to a curve.

slicing3d(ob, start, end)

Slice a 3D object along specified planes.

sliceObject(ob)

Slice a 3D object into layers based on a specified thickness.

Module Contents#

slicing2d(ob, height)[source]#

Slice a 3D object at a specified height and convert it to a curve.

This function applies transformations to the given object, switches to edit mode, selects all vertices, and performs a bisect operation to slice the object at the specified height. After slicing, it resets the object’s location and applies transformations again before converting the object to a curve. If the conversion fails (for instance, if the mesh was empty), the function deletes the mesh and returns False. Otherwise, it returns True.

Parameters:
  • ob (bpy.types.Object) – The Blender object to be sliced and converted.

  • height (float) – The height at which to slice the object.

Returns:

True if the conversion to curve was successful, False otherwise.

Return type:

bool

slicing3d(ob, start, end)[source]#

Slice a 3D object along specified planes.

This function applies transformations to a given object and slices it in the Z-axis between two specified values, start and end. It first ensures that the object is in edit mode and selects all vertices before performing the slicing operations using the bisect method. After slicing, it resets the object’s location and applies the transformations to maintain the changes.

Parameters:
  • ob (Object) – The 3D object to be sliced.

  • start (float) – The starting Z-coordinate for the slice.

  • end (float) – The ending Z-coordinate for the slice.

Returns:

True if the slicing operation was successful.

Return type:

bool

sliceObject(ob)[source]#

Slice a 3D object into layers based on a specified thickness.

This function takes a 3D object and slices it into multiple layers according to the specified thickness. It creates a new collection for the slices and optionally creates text labels for each slice if the indexes parameter is set. The slicing can be done in either 2D or 3D based on the user’s selection. The function also handles the positioning of the slices based on the object’s bounding box.

Parameters:

ob (bpy.types.Object) – The 3D object to be sliced.

class SliceObjectsSettings[source]#

Bases: bpy.types.PropertyGroup

Stores All Data for Machines

slice_distance: FloatProperty(name='Slicing Distance', description='Slices distance in z, should be most often thickness of plywood sheet.', min=0.001, max=10, default=0.005, precision=constants.PRECISION, unit='LENGTH')[source]#
slice_above0: BoolProperty(name='Slice Above 0', description='only slice model above 0', default=False)[source]#
slice_3d: BoolProperty(name='3D Slice', description='For 3D carving', default=False)[source]#
indexes: BoolProperty(name='Add Indexes', description='Adds index text of layer + index', default=True)[source]#