Update app.py
Browse files
app.py
CHANGED
|
@@ -9,13 +9,18 @@ def convert_to_sqm(length, width, unit):
|
|
| 9 |
elif unit == "Millimeters (mm)":
|
| 10 |
return (length / 1000) * (width / 1000)
|
| 11 |
|
| 12 |
-
# Function to calculate required C Channels/Rods
|
| 13 |
-
def calculate_c_channels(area, rod_length,
|
| 14 |
-
if rod_length <= 0 or
|
| 15 |
return None
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
# Streamlit UI Configuration
|
| 21 |
st.set_page_config(page_title="Area, Gypsum Board & C Channel Calculator", layout="wide")
|
|
@@ -65,16 +70,16 @@ if st.button("Calculate Required Gypsum Boards (Based on Custom Area)"):
|
|
| 65 |
else:
|
| 66 |
st.error("Please enter a valid gypsum board area.")
|
| 67 |
|
| 68 |
-
# Section 4: C Channel/Rod Calculation
|
| 69 |
st.subheader("🛠 C Channel/Rod Calculation")
|
| 70 |
|
| 71 |
c_area = st.number_input("Enter Total Area to Cover (m²):", min_value=0.0, format="%.2f", key="c_area")
|
| 72 |
rod_length = st.number_input("Enter Length of One C Channel/Rod (meters):", min_value=0.1, format="%.2f", key="rod_length")
|
| 73 |
-
|
| 74 |
-
|
| 75 |
|
| 76 |
if st.button("Calculate Required C Channels/Rods"):
|
| 77 |
-
rods_required = calculate_c_channels(c_area, rod_length,
|
| 78 |
if rods_required is not None:
|
| 79 |
st.success(f"📌 You will need approximately `{rods_required:.2f}` C Channels/Rods.")
|
| 80 |
else:
|
|
|
|
| 9 |
elif unit == "Millimeters (mm)":
|
| 10 |
return (length / 1000) * (width / 1000)
|
| 11 |
|
| 12 |
+
# Function to calculate required C Channels/Rods based on spacing
|
| 13 |
+
def calculate_c_channels(area, rod_length, horizontal_spacing, vertical_spacing):
|
| 14 |
+
if rod_length <= 0 or horizontal_spacing <= 0 or vertical_spacing <= 0:
|
| 15 |
return None
|
| 16 |
+
|
| 17 |
+
# Calculate number of rods required in horizontal and vertical directions
|
| 18 |
+
horizontal_rods = area / horizontal_spacing
|
| 19 |
+
vertical_rods = area / vertical_spacing
|
| 20 |
+
|
| 21 |
+
# Calculate total rods required based on their length
|
| 22 |
+
total_rods = (horizontal_rods + vertical_rods) / rod_length
|
| 23 |
+
return total_rods
|
| 24 |
|
| 25 |
# Streamlit UI Configuration
|
| 26 |
st.set_page_config(page_title="Area, Gypsum Board & C Channel Calculator", layout="wide")
|
|
|
|
| 70 |
else:
|
| 71 |
st.error("Please enter a valid gypsum board area.")
|
| 72 |
|
| 73 |
+
# Section 4: C Channel/Rod Calculation (New Function)
|
| 74 |
st.subheader("🛠 C Channel/Rod Calculation")
|
| 75 |
|
| 76 |
c_area = st.number_input("Enter Total Area to Cover (m²):", min_value=0.0, format="%.2f", key="c_area")
|
| 77 |
rod_length = st.number_input("Enter Length of One C Channel/Rod (meters):", min_value=0.1, format="%.2f", key="rod_length")
|
| 78 |
+
horizontal_spacing = st.number_input("Enter Horizontal Distance Between Rods (meters):", min_value=0.1, format="%.2f", key="h_spacing")
|
| 79 |
+
vertical_spacing = st.number_input("Enter Vertical Distance Between Rods (meters):", min_value=0.1, format="%.2f", key="v_spacing")
|
| 80 |
|
| 81 |
if st.button("Calculate Required C Channels/Rods"):
|
| 82 |
+
rods_required = calculate_c_channels(c_area, rod_length, horizontal_spacing, vertical_spacing)
|
| 83 |
if rods_required is not None:
|
| 84 |
st.success(f"📌 You will need approximately `{rods_required:.2f}` C Channels/Rods.")
|
| 85 |
else:
|