From abcf3e712c4adda06b3226452decab11b0e59235 Mon Sep 17 00:00:00 2001 From: Kolja Prothmann Date: Sat, 28 Feb 2026 00:03:13 +0100 Subject: [PATCH] added a function to convert the step file from the upload to an obj file for 3D comparison --- main.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/main.py b/main.py index bf7a54f..526d4ae 100644 --- a/main.py +++ b/main.py @@ -1,6 +1,7 @@ import os import tempfile import uuid +import subprocess from fastapi import FastAPI, UploadFile, File, HTTPException from fastapi.staticfiles import StaticFiles @@ -56,3 +57,18 @@ async def upload_file(file: UploadFile = File(...)): "content_type": file.content_type, "size_bytes": target.stat().st_size, } +@app.post("/upload/{file_id}/convert") +async def convert_obj(file_id: str): + inpath = UPLOAD_DIR / Path(file_id) + + #check for target + + outpath = UPLOAD_DIR / Path(file_id).with_suffix(".obj") + result = subprocess.run(["freecadcmd", "step_to_obj_headless.py", inpath, outpath]) + + return { + "file_id": file_id, + "inpath": inpath, + "outpath": outpath, + "status": result.__str__() + } \ No newline at end of file