Chapter 7: Issues API

In Ansys medini analyze, error, warning, and info messages concerning projects in the workspace are called issues. By calling functions on the Issues global object, you can access issues for all projects or for a specific project. You can also add and remove issues.

getAllIssues()

{Function} - Returns a list of all current issues found in the workspace.

var allIssues = Issues.getAllIssues();
console.log("There are {0} issues in the workspace, {1} of them are errors", 
	allIssues.size(),
	allIssues.toArray().filter((i) => i.severity == 4).length);

Stability 1 - Experimental

forProject()

{Function} - Returns a ProjectIssues object to handle all current issues found in a specified project in the workspace. The object includes functions to list, add, and remove issues for the specified project.

var ProjectIssues = Issues.forProject(finder.project);
var issues = ProjectIssues.getIssues();
if (!issues.isEmpty()) {
	ProjectIssues.removeIssues(issues);
	ProjectIssues.addIssue(2, finder.project, 
		"There were {1} issues before which the script removed", 
		"No resolution", [ issues.size() ]);	
} else {
	ProjectIssues.addIssue(1, finder.project, 
		"The script did not find any issue", 
		"No resolution", [ ]);	
}

Note that addIssue and removeIssue also accept an array (or any collection) of issues. In addition, you can use setParent to easily create subitems in your script.

var i3 = new Issue(1, finder.project, "Parent", "None", []);
var i4 = new Issue(2, finder.project, "Child", "None", []).setParent(i3).setElementId("foo").setLocation("bar").setConstraintId("06");
ProjectIssues.addIssues([i3, i4]);

Stability 1 - Experimental