cam.strategy#

BlenderCAM ‘strategy.py’ © 2012 Vilem Novak

Strategy functionality of BlenderCAM - e.g. Cutout, Parallel, Spiral, Waterline The functions here are called with operators defined in ‘ops.py’

Attributes#

Functions#

cutout(o)

Perform a cutout operation based on the provided parameters.

curve(o)

Process and convert curve objects into mesh chunks.

proj_curve(s, o)

Project a curve onto another curve object.

pocket(o)

Perform pocketing operation based on the provided parameters.

drill(o)

Perform a drilling operation on the specified objects.

medial_axis(o)

Generate the medial axis for a given operation.

getLayers(operation, startdepth, enddepth)

Returns a list of layers bounded by start depth and end depth.

chunksToMesh(chunks, o)

Convert sampled chunks into a mesh path for a given optimization object.

checkminz(o)

Check the minimum value based on the specified condition.

Module Contents#

SHAPELY = True[source]#
async cutout(o)[source]#

Perform a cutout operation based on the provided parameters.

This function calculates the necessary cutter offset based on the cutter type and its parameters. It processes a list of objects to determine how to cut them based on their geometry and the specified cutting type. The function handles different cutter types such as ‘VCARVE’, ‘CYLCONE’, ‘BALLCONE’, and ‘BALLNOSE’, applying specific calculations for each. It also manages the layering and movement strategies for the cutting operation, including options for lead-ins, ramps, and bridges.

Parameters:

o (object) – An object containing parameters for the cutout operation, including cutter type, diameter, depth, and other settings.

Returns:

This function does not return a value but performs operations

on the provided object.

Return type:

None

async curve(o)[source]#

Process and convert curve objects into mesh chunks.

This function takes an operation object and processes the curves contained within it. It first checks if all objects are curves; if not, it raises an exception. The function then converts the curves into chunks, sorts them, and refines them. If layers are to be used, it applies layer information to the chunks, adjusting their Z-offsets accordingly. Finally, it converts the processed chunks into a mesh.

Parameters:

o (Operation) – An object containing operation parameters, including a list of objects, flags for layer usage, and movement constraints.

Returns:

This function does not return a value; it performs operations on the

input.

Return type:

None

Raises:

CamException – If not all objects in the operation are curves.

async proj_curve(s, o)[source]#

Project a curve onto another curve object.

This function takes a source object and a target object, both of which are expected to be curve objects. It projects the points of the source curve onto the target curve, adjusting the start and end points based on specified extensions. The resulting projected points are stored in the source object’s path samples.

Parameters:
  • s (object) – The source object containing the curve to be projected.

  • o (object) – An object containing references to the curve objects involved in the projection.

Returns:

This function does not return a value; it modifies the

source object’s path samples in place.

Return type:

None

Raises:

CamException – If the target curve is not of type ‘CURVE’.

async pocket(o)[source]#

Perform pocketing operation based on the provided parameters.

This function executes a pocketing operation using the specified parameters from the object o. It calculates the cutter offset based on the cutter type and depth, processes curves, and generates the necessary chunks for the pocketing operation. The function also handles various movement types and optimizations, including helix entry and retract movements.

Parameters:

o (object) – An object containing parameters for the pocketing

Returns:

The function modifies the scene and generates geometry based on the pocketing operation.

Return type:

None

async drill(o)[source]#

Perform a drilling operation on the specified objects.

This function iterates through the objects in the provided context, activating each object and applying transformations. It duplicates the objects and processes them based on their type (CURVE or MESH). For CURVE objects, it calculates the bounding box and center points of the splines and bezier points, and generates chunks based on the specified drill type. For MESH objects, it generates chunks from the vertices. The function also manages layers and chunk depths for the drilling operation.

Parameters:

o (object) – An object containing properties and methods required for the drilling operation, including a list of objects to drill, drill type, and depth parameters.

Returns:

This function does not return a value but performs operations

that modify the state of the Blender context.

Return type:

None

async medial_axis(o)[source]#

Generate the medial axis for a given operation.

This function computes the medial axis of the specified operation, which involves processing various cutter types and their parameters. It starts by removing any existing medial mesh, then calculates the maximum depth based on the cutter type and its properties. The function refines curves and computes the Voronoi diagram for the points derived from the operation’s silhouette. It filters points and edges based on their positions relative to the computed shapes, and generates a mesh representation of the medial axis. Finally, it handles layers and optionally adds a pocket operation if specified.

Parameters:

o (Operation) – An object containing parameters for the operation, including cutter type, dimensions, and other relevant properties.

Returns:

A dictionary indicating the completion status of the operation.

Return type:

dict

Raises:

CamException – If an unsupported cutter type is provided or if the input curve is not closed.

getLayers(operation, startdepth, enddepth)[source]#

Returns a list of layers bounded by start depth and end depth.

This function calculates the layers between the specified start and end depths based on the step down value defined in the operation. If the operation is set to use layers, it computes the number of layers by dividing the difference between start and end depths by the step down value. The function raises an exception if the start depth is lower than the end depth.

Parameters:
  • operation (object) – An object that contains the properties use_layers, stepdown, and maxz which are used to determine how layers are generated.

  • startdepth (float) – The starting depth for layer calculation.

  • enddepth (float) – The ending depth for layer calculation.

Returns:

A list of layers, where each layer is represented as a list

containing the start and end depths of that layer.

Return type:

list

Raises:

CamException – If the start depth is lower than the end depth.

chunksToMesh(chunks, o)[source]#

Convert sampled chunks into a mesh path for a given optimization object.

This function takes a list of sampled chunks and converts them into a mesh path based on the specified optimization parameters. It handles different machine axes configurations and applies optimizations as needed. The resulting mesh is created in the Blender context, and the function also manages the lifting and dropping of the cutter based on the chunk positions.

Parameters:
  • chunks (list) – A list of chunk objects to be converted into a mesh.

  • o (object) – An object containing optimization parameters and settings.

Returns:

The function creates a mesh in the Blender context but does not return a

value.

Return type:

None

checkminz(o)[source]#

Check the minimum value based on the specified condition.

This function evaluates the ‘minz_from’ attribute of the input object ‘o’. If ‘minz_from’ is set to ‘MATERIAL’, it returns the value of ‘min.z’. Otherwise, it returns the value of ‘minz’.

Parameters:

o (object) – An object that has attributes ‘minz_from’, ‘min’, and ‘minz’.

Returns:

The minimum value, which can be either ‘o.min.z’ or ‘o.minz’ depending

on the condition.