UsmanGoraya commited on
Commit
d1d5c91
·
verified ·
1 Parent(s): 3fce19e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -3,13 +3,17 @@ import ezdxf
3
  import pandas as pd
4
  import os
5
 
6
- def extract_entities(file):
7
  import ezdxf
8
- import io
9
 
10
- # Convert the uploaded file to a byte stream
11
- file_stream = io.BytesIO(file.read())
12
- doc = ezdxf.read(file_stream)
 
 
 
 
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