Spaces:
No application file
No application file
Delete app.py
Browse files
app.py
DELETED
|
@@ -1,59 +0,0 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
from ansys.mapdl.core import launch_mapdl
|
| 3 |
-
|
| 4 |
-
# Function to generate die design using ANSYS MAPDL
|
| 5 |
-
def generate_die_ANSYS(length, width, thickness, die_shape):
|
| 6 |
-
try:
|
| 7 |
-
if length <= 0 or width <= 0 or thickness <= 0:
|
| 8 |
-
return "Dimensions must be greater than zero."
|
| 9 |
-
|
| 10 |
-
# Launch ANSYS MAPDL session (without interactive argument)
|
| 11 |
-
mapdl = launch_mapdl() # Start MAPDL session
|
| 12 |
-
mapdl.clear() # Clear any previous settings
|
| 13 |
-
|
| 14 |
-
# Preprocessing
|
| 15 |
-
mapdl.prep7()
|
| 16 |
-
|
| 17 |
-
# Die shape logic
|
| 18 |
-
if die_shape == "Rectangle":
|
| 19 |
-
mapdl.block(0, length, 0, width, 0, thickness) # Create a rectangular block
|
| 20 |
-
elif die_shape == "Circle":
|
| 21 |
-
mapdl.cylind(0, 0, width / 2, 0, thickness) # Create a cylindrical block
|
| 22 |
-
|
| 23 |
-
# Save the geometry as a STEP file
|
| 24 |
-
filename = f"generated_die_{die_shape}_{length}x{width}x{thickness}.step"
|
| 25 |
-
mapdl.save_as(filename) # Save the design as STEP file
|
| 26 |
-
mapdl.exit() # Exit the MAPDL session
|
| 27 |
-
|
| 28 |
-
# Return success message with the file path
|
| 29 |
-
return filename
|
| 30 |
-
|
| 31 |
-
except Exception as e:
|
| 32 |
-
return f"Error generating die design: {str(e)}"
|
| 33 |
-
|
| 34 |
-
# Streamlit UI components
|
| 35 |
-
def main():
|
| 36 |
-
st.title("Progressive Die Design Tool with ANSYS")
|
| 37 |
-
st.markdown("Enter the dimensions and shape for the progressive die below:")
|
| 38 |
-
|
| 39 |
-
# Input fields for length, width, thickness, and die shape
|
| 40 |
-
length = st.number_input("Length (mm)", min_value=1, value=100)
|
| 41 |
-
width = st.number_input("Width (mm)", min_value=1, value=50)
|
| 42 |
-
thickness = st.number_input("Thickness (mm)", min_value=1, value=10)
|
| 43 |
-
die_shape = st.selectbox("Die Shape", ["Rectangle", "Circle"])
|
| 44 |
-
|
| 45 |
-
# Button to generate the die
|
| 46 |
-
if st.button("Generate Die"):
|
| 47 |
-
result = generate_die_ANSYS(length, width, thickness, die_shape)
|
| 48 |
-
|
| 49 |
-
# Display result
|
| 50 |
-
if "Error" in result:
|
| 51 |
-
st.error(result)
|
| 52 |
-
else:
|
| 53 |
-
st.success(f"Die design saved successfully as {result}. You can download the file.")
|
| 54 |
-
# Provide the download link
|
| 55 |
-
with open(result, "rb") as file:
|
| 56 |
-
st.download_button(label="Download STEP file", data=file, file_name=result)
|
| 57 |
-
|
| 58 |
-
if __name__ == "__main__":
|
| 59 |
-
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|