Update utils.py
Browse files
utils.py
CHANGED
|
@@ -18,28 +18,24 @@ def calculate_reduced_dimensions(width, height, unit, selection, object_item_val
|
|
| 18 |
reduction_width = object_item_value[selection][item_type]['width']
|
| 19 |
reduction_height = object_item_value[selection][item_type]['height']
|
| 20 |
|
|
|
|
|
|
|
|
|
|
| 21 |
# Calculate the reduced dimensions based on the width and height
|
| 22 |
-
reduced_width = (width - reduction_width) /
|
| 23 |
-
reduced_height = height - reduction_height
|
| 24 |
return reduced_width, reduced_height
|
| 25 |
|
| 26 |
# Functions for door and window area/frame calculation
|
| 27 |
def calculate_area_and_frame(width, height, unit, item_type="Door"):
|
| 28 |
# Convert width and height to meters for area and frame calculation
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
|
|
|
|
|
|
| 32 |
frame_thickness = {'Door': 0.1, 'Window': 0.05}
|
| 33 |
-
frame_area = 2 * (
|
| 34 |
-
|
| 35 |
-
# Convert area to square feet if necessary
|
| 36 |
-
if unit == "Feet":
|
| 37 |
-
area = area * 10.7639 # Convert square meters to square feet
|
| 38 |
-
frame_area = frame_area * 10.7639 # Convert frame area to square feet
|
| 39 |
-
# If the unit is inches, convert to square feet
|
| 40 |
-
elif unit == "Inches":
|
| 41 |
-
area = (area * 0.092903) * 10.7639 # Convert inches squared to square feet
|
| 42 |
-
frame_area = (frame_area * 0.092903) * 10.7639 # Convert frame area to square feet
|
| 43 |
|
| 44 |
return area, frame_area
|
| 45 |
|
|
|
|
| 18 |
reduction_width = object_item_value[selection][item_type]['width']
|
| 19 |
reduction_height = object_item_value[selection][item_type]['height']
|
| 20 |
|
| 21 |
+
divider_h = object_item_value['divider'][item_type]['height']
|
| 22 |
+
divider_w = object_item_value['divider'][item_type]['width']
|
| 23 |
+
|
| 24 |
# Calculate the reduced dimensions based on the width and height
|
| 25 |
+
reduced_width = (width - reduction_width) / divider_w
|
| 26 |
+
reduced_height = (height - reduction_height) / divider_h
|
| 27 |
return reduced_width, reduced_height
|
| 28 |
|
| 29 |
# Functions for door and window area/frame calculation
|
| 30 |
def calculate_area_and_frame(width, height, unit, item_type="Door"):
|
| 31 |
# Convert width and height to meters for area and frame calculation
|
| 32 |
+
if unit == 'Inches':
|
| 33 |
+
width = convert_inches_to_feet(width)
|
| 34 |
+
height = convert_inches_to_feet(height)
|
| 35 |
+
|
| 36 |
+
area = int(width * height)
|
| 37 |
frame_thickness = {'Door': 0.1, 'Window': 0.05}
|
| 38 |
+
frame_area = 2 * (width + height) * frame_thickness.get(item_type, 0.1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
return area, frame_area
|
| 41 |
|