Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,13 +3,17 @@ import ezdxf
|
|
| 3 |
import pandas as pd
|
| 4 |
import os
|
| 5 |
|
| 6 |
-
def extract_entities(
|
| 7 |
import ezdxf
|
| 8 |
-
import
|
| 9 |
|
| 10 |
-
#
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
msp = doc.modelspace()
|
| 14 |
|
| 15 |
plan_data = {"rooms": [], "doors": [], "windows": []}
|
|
@@ -33,6 +37,7 @@ def extract_entities(file):
|
|
| 33 |
|
| 34 |
return plan_data, section_data
|
| 35 |
|
|
|
|
| 36 |
def calculate_quantities(plan_data, section_data):
|
| 37 |
results = []
|
| 38 |
|
|
|
|
| 3 |
import pandas as pd
|
| 4 |
import os
|
| 5 |
|
| 6 |
+
def extract_entities(uploaded_file):
|
| 7 |
import ezdxf
|
| 8 |
+
import tempfile
|
| 9 |
|
| 10 |
+
# Save the uploaded file to a temporary file
|
| 11 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".dxf") as tmp:
|
| 12 |
+
tmp.write(uploaded_file.read())
|
| 13 |
+
tmp_path = tmp.name
|
| 14 |
+
|
| 15 |
+
# Read using ezdxf.readfile (expects a path, and handles binary too)
|
| 16 |
+
doc = ezdxf.readfile(tmp_path)
|
| 17 |
msp = doc.modelspace()
|
| 18 |
|
| 19 |
plan_data = {"rooms": [], "doors": [], "windows": []}
|
|
|
|
| 37 |
|
| 38 |
return plan_data, section_data
|
| 39 |
|
| 40 |
+
|
| 41 |
def calculate_quantities(plan_data, section_data):
|
| 42 |
results = []
|
| 43 |
|