Abdullah-Basar's picture
Update app.py
74f1990 verified
import streamlit as st
# Title and Description
st.title("🏠 Room Brick Masonry Estimator")
st.write("""
This app estimates the number of bricks and the amount of mortar required for constructing a room.
Input the dimensions of the room, gate, window, and bricks, and the app will calculate the required quantities.
""")
# Sidebar Instructions
st.sidebar.title("Instructions")
st.sidebar.write("""
1. Enter the dimensions of the room (height, length, and width in meters, wall width in inches).
2. Enter the dimensions of the gate and window (in meters).
3. Enter the dimensions of a single brick (in inches).
4. Click the **Estimate Requirements** button to calculate the number of bricks and mortar volume.
5. Reset inputs using the **Clear Inputs** button.
""")
# Input Dimensions of Room
st.subheader("Room Dimensions")
room_height = st.number_input("Room Height (meters):", min_value=0.1, step=0.1, format="%.2f")
room_length = st.number_input("Room Length (meters):", min_value=0.1, step=0.1, format="%.2f")
room_width = st.number_input("Room Width (meters):", min_value=0.1, step=0.1, format="%.2f")
wall_thickness_in = st.number_input("Wall Thickness (inches):", min_value=1.0, step=0.1, format="%.1f")
# Input Dimensions of Gate
st.subheader("Gate Dimensions")
gate_height = st.number_input("Gate Height (meters):", min_value=0.1, step=0.1, format="%.2f")
gate_width = st.number_input("Gate Width (meters):", min_value=0.1, step=0.1, format="%.2f")
# Input Dimensions of Window
st.subheader("Window Dimensions")
window_height = st.number_input("Window Height (meters):", min_value=0.1, step=0.1, format="%.2f")
window_width = st.number_input("Window Width (meters):", min_value=0.1, step=0.1, format="%.2f")
# Input Dimensions of Brick
st.subheader("Brick Dimensions")
brick_height_in = st.number_input("Brick Height (inches):", min_value=1.0, step=0.1, format="%.1f")
brick_length_in = st.number_input("Brick Length (inches):", min_value=1.0, step=0.1, format="%.1f")
brick_width_in = st.number_input("Brick Width (inches):", min_value=1.0, step=0.1, format="%.1f")
# Estimate Button
if st.button("Estimate Requirements"):
if room_height <= 0 or room_length <= 0 or room_width <= 0:
st.error("Room dimensions must be greater than zero!")
elif gate_height <= 0 or gate_width <= 0:
st.error("Gate dimensions must be greater than zero!")
elif window_height <= 0 or window_width <= 0:
st.error("Window dimensions must be greater than zero!")
elif brick_height_in <= 0 or brick_length_in <= 0 or brick_width_in <= 0:
st.error("Brick dimensions must be greater than zero!")
else:
# Convert inputs
wall_thickness_m = wall_thickness_in * 0.0254 # Convert inches to meters
brick_height_m = brick_height_in * 0.0254
brick_length_m = brick_length_in * 0.0254
brick_width_m = brick_width_in * 0.0254
# Calculate volumes
room_wall_volume = 2 * (room_height * room_length * wall_thickness_m) + 2 * (room_height * room_width * wall_thickness_m)
gate_volume = gate_height * gate_width * wall_thickness_m
window_volume = window_height * window_width * wall_thickness_m
net_wall_volume = room_wall_volume - (gate_volume + window_volume)
brick_volume = brick_height_m * brick_length_m * brick_width_m
# Calculate results
if brick_volume > 0:
num_bricks = net_wall_volume / brick_volume
mortar_volume = net_wall_volume * 0.2 # Assume 20% of wall volume is mortar
# Display Results
st.subheader("Results")
st.write(f"**Net Wall Volume:** {net_wall_volume:.2f} cubic meters")
st.write(f"**Number of Bricks Required:** {int(num_bricks)} bricks")
st.write(f"**Mortar Volume Required:** {mortar_volume:.2f} cubic meters")
else:
st.error("Brick dimensions must form a valid volume!")
# Reset Inputs Button
if st.button("Clear Inputs"):
st.experimental_rerun()
# Footer
st.write("---")
st.markdown("πŸ’‘ **Developed by Abdullah**")