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