Py.Cafe

martin.kusy/

streamlit_progress

selector

DocsPricing
  • app.py
  • diameter_data.json
  • requirements.txt
app.py
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
import streamlit as st
import json  # πŸ‘ˆ Add this if it's not already there

# --- Load Diameter Data from JSON ---
with open("diameter_data.json", "r") as f:
    diameter_data = json.load(f)


# --- Profile Types ---
profiles = {
    "Round Tube": "πŸ”΅ Round Tube",
    "Square Tube": "πŸŸ₯ Square Tube",
    "Rectangular Tube": "🟨 Rectangular Tube",
    "Flat Bar": "🟫 Flat Bar",
    "Angle Bar": "πŸ“ Angle Bar (L-profile)",
    "Channel Bar": "🧱 Channel Bar (U-profile)",
    "Beam": "πŸ— I-Beam / H-Beam",
    "Sheet / Plate": "πŸ“„ Sheet / Plate",
    "Wire / Rod": "🧡 Wire / Rod"
}

# diameter_data = {
#    "Series 1": {
#        10.2: {
#            1.0: {"weight": 0.23},
#            1.2: {"weight": 0.28},
#            1.6: {"weight": 0.36},
#            2.0: {"weight": 0.44}
#        },
#    }
#}
#       "Series 2": {
#        6.0: {
#            1.0: {"weight": 0.125}
#        },
#       8.0: {
#          1.0: {"weight": 0.175}
#       },

# --- Tolerance Class Logic 10216-5---
def get_tolerance_options_10216(delivery_10216, od, thickness):
    options = []
    note = ""

    od = float(diameter)
    thickness_val = float(thickness)
    
    if delivery_10216 == "HFD":
        if 30 <= od <= 219.1:
            if thickness_val <= 4:
                options = ["D2/T1", "D2/T2"]
                note = "D2/T1 or D2/T2 *"
            elif thickness_val <= 8:
                options = ["D2/T2"]
                note = "D2/T2 *"
        elif 219.1 < od <= 610:
            if 0.05 * od < thickness_val <= 0.09 * od:
                options = ["D1/T1"]
                note = "D1/T1"
            elif thickness_val > 0.09 * od:
                options = ["D1/T2"]
                note = "D1/T2"

    elif delivery_10216 in ["CFD", "CFA", "CFG", "CFP"]:
        if od <= 219.1 and thickness_val <= 8:
            options = ["D3/T3", "D4/T4"]
            note = "Optional requirement No. 20 according EN10216-5: Tolerance class D4/T4 for tubes ordered cold finished"

    return options, note,

# --- UI ---
st.title("πŸ”© Stainless Steel Profile Selector")

# Level 1: Profile Selection
profile = st.selectbox("Select Profile Type:", [""] + list(profiles.values()))

# Level 2: Standard Selection
if profile == "πŸ”΅ Round Tube":
    standard = st.selectbox("Select Tube Standard:", ["", "EN 10216-5", "EN 10217-7", "EN 10296-2"])

    # Level 3.1: Delivery Condition
    if standard == "EN 10216-5":
        delivery_10216 = st.selectbox("Select Delivery Condition:", ["", "HFD", "CFD", "CFA", "CFG", "CFP"])

        # Level 3.2: Diameter Logic
        if delivery_10216:
            od_logic = st.selectbox("Select Outer Diameter Logic:", ["", "EN ISO 1127", "Free diameter"])

            # Level 4: Series Selection
            if od_logic == "EN ISO 1127":
                series = st.selectbox("Select Diameter Series:", ["", "Series 1", "Series 2", "Series 3"])

                # Level 5: Diameter Selection
                if series:
                    diameters = list(diameter_data[series].keys())
                    diameter = st.selectbox("Select Outer Diameter (mm):", [""] + diameters)

                    # Level 6: Wall Thickness Selection
                    if diameter:
                        thicknesses = list(diameter_data[series][diameter].keys())
                        thickness = st.selectbox("Select Wall Thickness (mm):", [""] + thicknesses)

                        # Level 7: Tolerance Class Selection
                        if thickness:
                            tolerance_options, note = get_tolerance_options_10216(delivery_10216, diameter, thickness)

                            if len(tolerance_options) == 1:
                                tolerance = tolerance_options[0]
                            elif len(tolerance_options) > 1:
                                tolerance = st.selectbox("Select Tolerance Class:", [""] + tolerance_options)
                            else:
                                tolerance = "Not defined"

                            # Final Summary
                            st.markdown("### βœ… Selection Summary")
                            st.write(f"**Profile Type:** {profile}")
                            st.write(f"**Standard:** {standard}")
                            st.write(f"**Delivery Condition:** {delivery_10216}")
                            st.write(f"**Diameter Logic:** {od_logic}")
                            st.write(f"**Series:** {series}")
                            st.write(f"**Outer Diameter:** {diameter} mm")
                            st.write(f"**Wall Thickness:** {thickness} mm")
                            st.write(f"**Tolerance Class:** {tolerance}")
                            # st.write(f"**Wall Diameter minimum:** {od_min} mm")
                            if note:
                                st.info(f"πŸ“Œ {note}")

    elif standard == "EN 10217-7": 
        delivery_10217 = st.selectbox("Select Delivery Conditions:", ["", "W0", "W1", "W1A", "W1R", "W2", "W2A", "W2R", "WCA", "WCR", "WG", "WP"])

        # Level 3.2: Diameter Logic
        if delivery_10217:
            od_logic = st.selectbox("Select Outer Diameter Logic:", ["", "EN ISO 1127", "Free diameter"])

            # Level 4: Series Selection
            if od_logic == "EN ISO 1127":
                series = st.selectbox("Select Diameter Series:", ["", "Series 1", "Series 2", "Series 3"])

                # Level 5: Diameter Selection
                if series:
                    diameters = list(diameter_data[series].keys())
                    diameter = st.selectbox("Select Outer Diameter (mm):", [""] + diameters)

                    # Level 6: Wall Thickness Selection
                    if diameter:
                        thicknesses = list(diameter_data[series][diameter].keys())
                        thickness = st.selectbox("Select Wall Thickness (mm):", [""] + thicknesses)

                        # Level 7: Tolerance Class Selection
                        if thickness:
                            tolerance_options, note = get_tolerance_options(delivery_10217, diameter, thickness)

                            if len(tolerance_options) == 1:
                                tolerance = tolerance_options[0]
                            elif len(tolerance_options) > 1:
                                tolerance = st.selectbox("Select Tolerance Class:", [""] + tolerance_options)
                            else:
                                tolerance = "Not defined"

                            # Final Summary
                            st.markdown("### βœ… Selection Summary")
                            st.write(f"**Profile Type:** {profile}")
                            st.write(f"**Standard:** {standard}")
                            st.write(f"**Delivery Condition:** {delivery_10217}")
                            st.write(f"**Diameter Logic:** {od_logic}")
                            st.write(f"**Series:** {series}")
                            st.write(f"**Outer Diameter:** {diameter} mm")
                            st.write(f"**Wall Thickness:** {thickness} mm")
                            st.write(f"**Tolerance Class:** {tolerance}")
                            if note:
                                st.info(f"πŸ“Œ {note}")