cam.slice#

Fabex ‘slice.py’ © 2021 Alain Pelletier

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

Functions#

slicing_2d(ob, height)

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

slicing_3d(ob, start, end)

Slice a 3D object along specified planes.

Module Contents#

slicing_2d(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

slicing_3d(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