When a cut doesn’t perform as expected or throws error messages, it can be tricky to identify the issue. Here are some tips and tools you can use to debug your code.

Isolate the Problem

Sometimes, it’s helpful to “comment out” portions of code that aren’t essential to locate the issue. The return statement can also be useful, as it immediately stops program execution at that location — provided it’s not within a function.

Logging

Use the console.log() function to display the values of variables, etc. Check your web browser’s “developer tools” (or a similar name) to view these logs.

Show the Points

A very helpful function is show(point, color). It displays a point in the specified color in the design window. Points can be seen “through” the stone, so those inside or at the back of the stone will still be visible. Rotate the view slightly to check the points’ locations.

// Show meetpoint "3" with a light blue dot (aqua):
show(meet("3"), Color.Aqua)


// Set a variable to the point between two meetpoints.
let b = between(meet("2"), meet("1"), 0.5)

// Now highlight that point in yellow:
show(b, Color.Yellow)  

Test Cut

You can replace the cut() command with test(), keeping the parameters the same. This will show the cutting plane for the first index that would be cut — a handy way to check before executing the actual cut.