diff --git a/src/services/verification_service.py b/src/services/verification_service.py index 10771d7..f33ed49 100644 --- a/src/services/verification_service.py +++ b/src/services/verification_service.py @@ -157,9 +157,18 @@ class GeometryVerificationService: if stderr_text: logger.warning(f"验证脚本 stderr: {stderr_text[:500]}") - # 检查是否有 FreeCAD 权限错误 - if 'Cannot read STEP file' in stderr_text or 'Cannot read STEP file' in stdout_text: - logger.warning("FreeCAD 无法读取文件(可能是 snap 沙盒限制),使用 PythonOCC 验证") + # 检查是否有 FreeCAD 错误 + has_error = ( + 'Cannot read STEP file' in stderr_text or + 'Cannot read STEP file' in stdout_text or + 'Exception while processing file' in stderr_text or + 'Exception while processing file' in stdout_text or + '所有导入方法都失败' in stdout_text or + process.returncode != 0 + ) + + if has_error: + logger.warning("FreeCAD 验证失败,使用 PythonOCC 验证") return self._verify_with_pythonocc_only(stp_path_str) if process.returncode == 0: