TellmeStpToGlb/main.py
root 5102bd57e8 feat: 服务化改造STP到GLB转换器
- 🚀 新增FastAPI Web服务支持
-  实现异步任务处理和并发转换
- 📊 添加实时进度追踪(0-100%)
- 🏗️ 重构为模块化架构:core/api/services/utils
- 🔧 完整的任务管理系统和状态追踪
- 📖 自动生成API文档(Swagger/ReDoc)
- 🔄 保持CLI模式100%向后兼容
- 🛡️ 增强错误处理和文件验证
- 📝 更新完整文档(README/CLAUDE.md)

技术栈: FastAPI + uvicorn + pydantic + asyncio
API端点: /health, /api/v1/convert, /api/v1/status, /api/v1/tasks

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-02 09:44:43 +08:00

38 lines
1.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
"""
stp2glb.py 一键 STP → STL → GLB
依赖pythonocc-core + trimesh
用法python main.py model.stp model.glb
"""
import sys
from core.converter import StpToGlbConverter
def main():
"""CLI主函数保持向后兼容"""
if len(sys.argv) != 3:
sys.exit("用法: python main.py input.stp output.glb")
stp_file, glb_file = sys.argv[1], sys.argv[2]
# 创建转换器实例
converter = StpToGlbConverter()
# 设置进度回调CLI模式显示简单进度
def show_progress(progress: int, message: str):
if progress % 20 == 0 or progress == 100: # 每20%显示一次
print(f"[{progress:3d}%] {message}")
converter.set_progress_callback(show_progress)
try:
# 执行转换
converter.convert(stp_file, glb_file)
print(f"✅ 完成:{glb_file}")
except Exception as e:
sys.exit(f"❌ 转换失败:{e}")
if __name__ == "__main__":
main()