File size: 4,129 Bytes
1a6f587 4eff5e1 59a4607 4eff5e1 59a4607 8284bcb 59a4607 1a6f587 59a4607 1a6f587 8284bcb 1a6f587 8284bcb 1a6f587 59a4607 8284bcb 1a6f587 59a4607 1a6f587 8284bcb 4eff5e1 59a4607 4eff5e1 59a4607 4eff5e1 59a4607 1a6f587 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
import streamlit as st
# Function to convert all units to square meters
def convert_to_sqm(length, width, unit):
if unit == "Meters (m)":
return length * width
elif unit == "Centimeters (cm)":
return (length / 100) * (width / 100)
elif unit == "Millimeters (mm)":
return (length / 1000) * (width / 1000)
# Function to calculate required C Channels/Rods based on spacing
def calculate_c_channels(area, rod_length, horizontal_spacing, vertical_spacing):
if rod_length <= 0 or horizontal_spacing <= 0 or vertical_spacing <= 0:
return None
# Calculate number of rods required in horizontal and vertical directions
horizontal_rods = area / horizontal_spacing
vertical_rods = area / vertical_spacing
# Calculate total rods required based on their length
total_rods = (horizontal_rods + vertical_rods) / rod_length
return total_rods
# Streamlit UI Configuration
st.set_page_config(page_title="Area, Gypsum Board & C Channel Calculator", layout="wide")
st.title("π Multi-Purpose Calculator")
st.markdown("Calculate area, gypsum board requirements, and C Channel/Rod usage.")
# Section 1: Area Calculation
st.subheader("πΉ Main Area Input")
unit = st.selectbox("Select the unit of measurement:", ["Meters (m)", "Centimeters (cm)", "Millimeters (mm)"])
length = st.number_input("Enter Length:", min_value=0.0, format="%.2f")
width = st.number_input("Enter Width:", min_value=0.0, format="%.2f")
# Calculate area
total_area = convert_to_sqm(length, width, unit)
# Option to subtract an excluded area
st.subheader("πΉ Excluded Area (Optional)")
exclude_length = st.number_input("Enter Length of Excluded Area:", min_value=0.0, format="%.2f", key="ex_len")
exclude_width = st.number_input("Enter Width of Excluded Area:", min_value=0.0, format="%.2f", key="ex_wid")
excluded_area = convert_to_sqm(exclude_length, exclude_width, unit)
final_area = total_area - excluded_area
st.markdown(f"### β
Total Area: `{final_area:.2f} mΒ²`")
# Section 2: Gypsum Board Calculation
st.subheader("π Gypsum Board Calculation")
gypsum_board_area = st.number_input("Enter Area of a Single Gypsum Board (mΒ²):", min_value=0.1, format="%.2f")
if st.button("Calculate Required Gypsum Boards"):
if gypsum_board_area > 0:
num_boards = final_area / gypsum_board_area
st.success(f"π You will need approximately `{num_boards:.2f}` gypsum boards.")
else:
st.error("Please enter a valid gypsum board area.")
# Section 3: Direct Area Input for Gypsum Board Calculation
st.subheader("π Enter a Custom Area for Gypsum Board Calculation")
custom_area = st.number_input("Enter Total Area in mΒ²:", min_value=0.0, format="%.2f", key="custom_area")
if st.button("Calculate Required Gypsum Boards (Based on Custom Area)"):
if gypsum_board_area > 0:
num_boards_custom = custom_area / gypsum_board_area
st.success(f"π You will need approximately `{num_boards_custom:.2f}` gypsum boards.")
else:
st.error("Please enter a valid gypsum board area.")
# Section 4: C Channel/Rod Calculation (New Function)
st.subheader("π C Channel/Rod Calculation")
c_area = st.number_input("Enter Total Area to Cover (mΒ²):", min_value=0.0, format="%.2f", key="c_area")
rod_length = st.number_input("Enter Length of One C Channel/Rod (meters):", min_value=0.1, format="%.2f", key="rod_length")
horizontal_spacing = st.number_input("Enter Horizontal Distance Between Rods (meters):", min_value=0.1, format="%.2f", key="h_spacing")
vertical_spacing = st.number_input("Enter Vertical Distance Between Rods (meters):", min_value=0.1, format="%.2f", key="v_spacing")
if st.button("Calculate Required C Channels/Rods"):
rods_required = calculate_c_channels(c_area, rod_length, horizontal_spacing, vertical_spacing)
if rods_required is not None:
st.success(f"π You will need approximately `{rods_required:.2f}` C Channels/Rods.")
else:
st.error("Please enter valid values for the C Channel/Rod calculation.")
# Footer
st.markdown("---")
st.markdown("Developed with β€οΈ using Streamlit.")
|