Contents



Learning Objectives

At the end of this lesson, you will be able to:

  1. Understand what debugging is and why it’s necessary.
  2. Identify different windows in OpenSCAD.
  3. Find and fix syntax errors in your code.


Understanding Debugging

Debugging is the process of fixing errors in your code. In this lesson, we’ll focus on syntax errors, which occur when you type something incorrectly. Syntax errors are typically straightforward to fix. Debugging can also involve correcting code that is not behaving as expected, such as code intended to cut a cube in half but instead makes the cube larger.


Different Windows in OpenSCAD

OpenSCAD has several distinct windows:

  • Editor: Where you type your code.
  • Console: Outputs from renders and previews. Contains a mix of important and less crucial text.
  • Error-Log: Displays a table of the errors in your code, generally appearing one at a time.
  • Customizer: Not necessary for this lesson.
  • Model Preview: Provides a preview of the model when rendered.

You can navigate between windows by pressing Alt+W and selecting the desired window.


Finding and Fixing Errors

Follow these steps to find and fix errors in your OpenSCAD code:

  1. Preview code (F5).
  2. Use Ctrl+Alt+E to jump to an error.
  3. Arrow through your code to understand the error, possibly missing punctuation.
  4. If needed, navigate to the error-log window (Alt+W+L) for more details.
  5. If the error remains elusive, begin at the top of the code and review each line.

Remember to ensure punctuation is being read aloud by your screen reader.


Practice Problems

Try to fix the following lines of code and then comment them out:

  1. cyliner(4,4,4)
    
  2. sphere[r=1
    
  3. tranlate[0,0,1]
    sphere(1);
    



Practice Solutions


  1. cylinder(4,4,4);
    
  2. sphere(r=1);
    
  3. translate([0,0,1])
    sphere(1);
    




Review

In this lesson you learned:

  • The concept of debugging in coding and its importance.
  • How to navigate between different windows in OpenSCAD.
  • Steps to find and fix syntax errors in your code.


Resources