File size: 4,124 Bytes
f8e1a0b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
92
93
94
import streamlit as st
import math

# 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 excluded circular area
def calculate_circular_area(diameter, unit):
    radius = diameter / 2
    if unit == "Meters (m)":
        return math.pi * (radius ** 2)
    elif unit == "Centimeters (cm)":
        return math.pi * ((radius / 100) ** 2)
    elif unit == "Millimeters (mm)":
        return math.pi * ((radius / 1000) ** 2)

# 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
    
    horizontal_rods = area / horizontal_spacing
    vertical_rods = area / vertical_spacing

    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")

total_area = convert_to_sqm(length, width, unit)

# Option to subtract an excluded rectangular area
st.subheader("πŸ”Ή Excluded Rectangular 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_rect_area = convert_to_sqm(exclude_length, exclude_width, unit)

# Option to subtract an excluded circular area
st.subheader("πŸ”Ή Excluded Circular Area (Optional)")
diameter = st.number_input("Enter Diameter of Circular Excluded Area:", min_value=0.0, format="%.2f", key="circle_dia")
excluded_circ_area = calculate_circular_area(diameter, unit)

# Calculate final area
final_area = total_area - (excluded_rect_area + excluded_circ_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: C Channel/Rod Calculation
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.")