jithenderchoudary commited on
Commit
22a16e6
·
verified ·
1 Parent(s): 670152b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -28,7 +28,6 @@ def generate_die(length, width, thickness):
28
  return f"Error generating die: {str(e)}"
29
 
30
 
31
- # Function to visualize die in 3D
32
  def visualize_die(length, width, thickness):
33
  try:
34
  output_dir = "outputs"
@@ -43,7 +42,7 @@ def visualize_die(length, width, thickness):
43
  stl_file = os.path.join(output_dir, "progressive_die.stl")
44
  cq.exporters.exportShape(die.val(), "STL", stl_file)
45
 
46
- # Generate 3D visualization
47
  pv.global_theme.off_screen = True # Ensure off-screen rendering
48
  mesh = pv.read(stl_file)
49
  plotter = pv.Plotter(off_screen=True)
@@ -51,11 +50,14 @@ def visualize_die(length, width, thickness):
51
  screenshot = os.path.join(output_dir, "progressive_die_visualization.png")
52
  plotter.screenshot(screenshot)
53
 
 
 
 
 
54
  return screenshot
55
  except Exception as e:
56
  return f"Error visualizing die: {str(e)}"
57
 
58
-
59
  # Function for Stress Analysis (including thermal stress and fatigue strength)
60
  def stress_analysis(force, die_width, die_height, material_strength, temperature_change=50, alpha=1e-5, elastic_modulus=200000, fatigue_strength=150):
61
  try:
 
28
  return f"Error generating die: {str(e)}"
29
 
30
 
 
31
  def visualize_die(length, width, thickness):
32
  try:
33
  output_dir = "outputs"
 
42
  stl_file = os.path.join(output_dir, "progressive_die.stl")
43
  cq.exporters.exportShape(die.val(), "STL", stl_file)
44
 
45
+ # Generate 3D visualization screenshot
46
  pv.global_theme.off_screen = True # Ensure off-screen rendering
47
  mesh = pv.read(stl_file)
48
  plotter = pv.Plotter(off_screen=True)
 
50
  screenshot = os.path.join(output_dir, "progressive_die_visualization.png")
51
  plotter.screenshot(screenshot)
52
 
53
+ # Ensure the screenshot file exists
54
+ if not os.path.exists(screenshot):
55
+ raise FileNotFoundError("Screenshot file was not generated.")
56
+
57
  return screenshot
58
  except Exception as e:
59
  return f"Error visualizing die: {str(e)}"
60
 
 
61
  # Function for Stress Analysis (including thermal stress and fatigue strength)
62
  def stress_analysis(force, die_width, die_height, material_strength, temperature_change=50, alpha=1e-5, elastic_modulus=200000, fatigue_strength=150):
63
  try: