UsmanGoraya commited on
Commit
4b93d29
·
verified ·
1 Parent(s): 67d2cba

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -6,6 +6,7 @@ import matplotlib.pyplot as plt
6
  from fpdf import FPDF
7
  import matplotlib.patches as patches
8
  import tempfile
 
9
 
10
  # Constants for estimation
11
  BRICK_VOLUME_CFT = (9 / 12) * (4.5 / 12) * (3 / 12) # Brick Volume in Cubic Feet
@@ -53,15 +54,15 @@ def extract_geometry(file_bytes):
53
  continue
54
 
55
  elif entity.dxftype() == "LWPOLYLINE":
56
- # Check if it's a closed polyline representing a room
57
- if entity.closed and len(entity) == 4:
58
  points = entity.get_points()
59
  x_vals = [p[0] for p in points]
60
  y_vals = [p[1] for p in points]
61
- length = abs(max(x_vals) - min(x_vals)) / 12 # Convert to feet
62
- width = abs(max(y_vals) - min(y_vals)) / 12 # Convert to feet
63
- if length > 2 and width > 2:
64
- rooms.append((length, width, 10)) # Add room with length, width, and height (default 10 ft)
65
  room_shapes.append((min(x_vals), min(y_vals), max(x_vals), max(y_vals)))
66
 
67
  elif entity.dxftype() == "LINE":
 
6
  from fpdf import FPDF
7
  import matplotlib.patches as patches
8
  import tempfile
9
+ import math
10
 
11
  # Constants for estimation
12
  BRICK_VOLUME_CFT = (9 / 12) * (4.5 / 12) * (3 / 12) # Brick Volume in Cubic Feet
 
54
  continue
55
 
56
  elif entity.dxftype() == "LWPOLYLINE":
57
+ # Check if it's a closed polyline representing a wall
58
+ if entity.closed:
59
  points = entity.get_points()
60
  x_vals = [p[0] for p in points]
61
  y_vals = [p[1] for p in points]
62
+ width = abs(max(x_vals) - min(x_vals)) / 12 # Convert to feet
63
+ height = abs(max(y_vals) - min(y_vals)) / 12 # Convert to feet
64
+ if width > 2 and height > 2: # Make sure it's a room-like area
65
+ rooms.append((width, height, 10)) # Add room with length, width, and height (default 10 ft)
66
  room_shapes.append((min(x_vals), min(y_vals), max(x_vals), max(y_vals)))
67
 
68
  elif entity.dxftype() == "LINE":