#!/bin/bash

# --- run_freecad_generator.sh ---
#
# A wrapper script to correctly call the FreeCAD box generator from the command line.
#
# Usage: ./run_freecad_generator.sh <output_file.FCStd>

# --- Argument Validation ---
if [ -z "$1" ]; then
    echo "Usage: $0 <output_file.FCStd>"
    echo "Error: Output file not specified."
    exit 1
fi

OUTPUT_FILE="$1"

# --- Execute FreeCAD ---
# We pass the python script to the FreeCAD executable, followed by the
# output filename as a simple positional argument.

echo "Executing FreeCAD generator script..."
FreeCADCmd.exe -c freecad_box_generator.py "$OUTPUT_FILE"

if [ $? -ne 0 ]; then
    echo ""
    echo "Error: FreeCAD script execution failed."
    exit 1
fi

echo "Script executed successfully." 