cadquery.cqgi.ScriptExecutionError

Diagnostic signature

ScriptExecutionError

A `ScriptExecutionError` is raised by the CadQuery Gateway Interface (CQGI) when a script provided for execution contains invalid Python syntax, preventing it from being parsed.

What it means

This diagnostic indicates that a script passed to the CadQuery Gateway Interface (CQGI) cannot be compiled into an Abstract Syntax Tree (AST) because it violates Python syntax rules. Before CQGI executes a model, it parses the script's source code to discover defined parameters and prepare the execution environment. If the standard Python parser encounters malformed code during this preparatory phase, CQGI immediately halts and wraps the parsing failure in a `ScriptExecutionError`. The exception contains the specific line number and error message, allowing interactive environments like CQ-editor to visually highlight the exact location of the syntax failure for the user.

Why it happens

The error is explicitly triggered within `cadquery.cqgi.parse()` when it calls Python's built-in `ast.parse()` on the provided script string, and the parser throws a `SyntaxError`. This is most frequently caused by standard programming typos in the CadQuery script, such as missing parentheses (especially common when chaining CadQuery methods like `Workplane().box().faces()`), missing colons in control blocks, unclosed string literals, or invalid indentation. CQGI catches the `SyntaxError` and raises a `ScriptExecutionError` to ensure IDEs receive a uniform exception containing the `line` and `message` properties.

Minimal reproduction

import cadquery.cqgi as cqgi

# A script missing a closing parenthesis on the cadquery method chain
script_source = """
import cadquery as cq
result = cq.Workplane("XY").box(10, 10, 10
"""

# Attempting to parse the invalid script raises ScriptExecutionError
model = cqgi.parse(script_source)

How to fix it

Locate and correct the Python syntax error at the line indicated by the diagnostic, ensuring proper closure of all CadQuery method chains.

```python
import cadquery.cqgi as cqgi

# The missing closing parenthesis has been added
script_source = """
import cadquery as cq
result = cq.Workplane("XY").box(10, 10, 10)
"""

# The script is successfully parsed into a CQModel
model = cqgi.parse(script_source)

```

Step 1

Step 2

Step 3

Step 4

Upstream references

The CadQuery Gateway Interface API - ScriptExecutionError

Source code for cadquery.cqgi