jithenderchoudary commited on
Commit
6a1d50d
·
verified ·
1 Parent(s): 31bb642

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -10
app.py CHANGED
@@ -57,17 +57,40 @@ def execute_script():
57
  with open(script_file, "w") as f:
58
  f.write(apdl_script)
59
 
 
 
 
 
 
 
 
 
 
60
  # Define ANSYS execution command
61
- #ansys_command = [
62
- # "ansys", # Replace with the full path to your ANSYS executable
63
- # "-b", # Batch mode
64
- # "-i", script_file, # Input script
65
- # "-o", "output.log" # Output log
66
- ansys_command = [
67
- "C:\\Program Files\\ANSYS Inc\\v211\\ansys.exe", # Replace with actual path
68
- "-b",
69
- "-i", script_file,
70
- "-o", "output.log"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  ]
72
 
73
  ]
 
57
  with open(script_file, "w") as f:
58
  f.write(apdl_script)
59
 
60
+ def execute_script():
61
+ """Function to execute the APDL script using ANSYS."""
62
+ global apdl_script
63
+
64
+ # Save the APDL script to a file
65
+ script_file = "script.dat"
66
+ with open(script_file, "w") as f:
67
+ f.write(apdl_script)
68
+
69
  # Define ANSYS execution command
70
+ ansys_command = [
71
+ "C:\\Program Files\\ANSYS Inc\\v211\\ansys.exe", # Replace with actual path
72
+ "-b",
73
+ "-i", script_file,
74
+ "-o", "output.log"
75
+ ]
76
+
77
+ try:
78
+ # Run the ANSYS command
79
+ subprocess.run(ansys_command, check=True)
80
+
81
+ # Check if 2D and 3D images exist
82
+ if os.path.exists("2D_View.jpg") and os.path.exists("3D_View.jpg"):
83
+ return "APDL script executed successfully. 2D and 3D views generated."
84
+ else:
85
+ return "APDL script executed, but 2D/3D images are missing. Check output.log for details."
86
+
87
+ except subprocess.CalledProcessError as e:
88
+ # Return detailed error message
89
+ return f"Error executing APDL script: {str(e)}. Check output.log for details."
90
+ except FileNotFoundError:
91
+ return "ANSYS executable not found. Verify the path in ansys_command."
92
+
93
+
94
  ]
95
 
96
  ]