The Python code executes successfully; however, post-execution issues are observed in specific analysis types. For Static Structural analysis, the plot legend changes automatically, and the result contours appear only in red or blue, deviating from the original color scale. For Electro-Thermal (ET) analysis, the result (.rst) file connection is lost after execution, requiring manual reinsertion of the result file. These issues affect result consistency and require manual intervention, reducing the effectiveness of full report automation.
-- coding: utf-8 --
import clr
clr.AddReference("System.Windows.Forms")
from System.Windows.Forms import MessageBox
deleted_comments = 0
deleted_figures = 0
def delete():
deleted_comments = 0
deleted_figures = 0
Model = ExtAPI.DataModel.Project.Model
to_delete = []
# -------------------------------------------------
# Collect comments and figures (NO deletion here)
# -------------------------------------------------
def collect_recursive(parent):
if not hasattr(parent, "Children"):
return
for child in parent.Children:
try:
obj_type = child.GetType().ToString()
if obj_type == "Ansys.ACT.Automation.Mechanical.Comment":
to_delete.append(child)
deleted_comments += 1
elif obj_type == "Ansys.ACT.Automation.Mechanical.Figure":
to_delete.append(child)
deleted_figures += 1
else:
collect_recursive(child)
except:
pass
collect_recursive(Model)
# -------------------------------------------------
# UI-equivalent atomic delete (CRITICAL)
# -------------------------------------------------
if to_delete:
ExtAPI.DataModel.Remove(to_delete)
# -------------------------------------------------
# Final message
# -------------------------------------------------
MessageBox.Show(
"Deleted {} comment(s) and {} figure(s).".format(
deleted_comments, deleted_figures
),
"Tree Clean-Up Complete"
)
delete()