Chapter 10: Sanity Checks

Scripting is a powerful feature that can be used to modify existing models in various ways, even beyond the capabilities of the user interface. But that comes also at a certain risk: badly written scripts may corrupt or destroy the models or leave them in an inaproriate state. To support the development and testing of scripts there is a special API that allows a script to execute a number of sanity checks to ensure the overall data integrity is not affected. There is a singleton SanityChecker object in the global scope when supported by the scripting language.

Any script can use this checker to prove that all modifications done so far by the script are OK. The script may throw an exception in other cases to stop the script execution and to roll back all changes.

SanityChecker.checkModelConstraints(project, progressMonitor)

{Function} - Executes all known sanity checks on the given project accepting an optional progress monitor (long running operation).

// perform sanity check after model modification
var status = SanityChecker.checkModelConstraints(finder.project);
if (!status.isOK()) throw "this script is doing something wrong"

Stability 1 - Experimental