The Check class enables you to access model checking in PRIMER. More...
The PRIMER JavaScript API provides many class constants, properties and methods. For Arup to
be able to extend and enhance the API in the future any constant, property or method names beginning with a lowercase
or uppercase letter are reserved.
If you need to add your own properties or methods to one of the existing classes then to avoid any potential future conflict you
should ensure that the name begins with either an underscore (_) or a dollar sign ($) or the name is prefixed with your
own unique identifier.
For example if company 'ABC' need to add a property called 'example' then to avoid any potential future conflict use one of:
| Name | Description |
| Check.ERROR | Dashboard check gave error(s) |
| Check.OK | Dashboard check status OK |
| Check.UNKNOWN | Dashboard check status unknown (not run) |
| Check.WARNING | Dashboard check gave warning(s) |
Detailed DescriptionThe Check class is used add checks to PRIMER using JavaScript. Two different types of checks can be added:
For individual checks PRIMER will look in these directories for a script with the name 'class_name.js'. For example if you wanted to write a script that will be run for every part in a model the script should be called 'Part.js'. For custom checks PRIMER will look in these directories for a script called 'custom.js'. This obviously means that there can only be one custom script in each directory. These filenames are case sensitive. Individual scripts will be called with 3 arguments: arguments[0] = Name of the script arguments[1] = model object arguments[2] = Item object Individual scripts can add warnings or errors by using the Warning() or Error() methods of the appropriate class. For example for a Part the script can call the methods Part.Error() and Part.Warning(). The script should not call the Error() and Warning() methods of other classes. As a simple example of an individual check, suppose you wanted it to be an error if any shell parts in your model did not use type 16 shells. Add a script called 'Part.js' in the directory 'OA_INSTALL/primer_library/scripts/checks' (or one of the other directories) containing: |
// arguments[0] is name of script
var m = arguments[1]; // arguments[1] is model pointer
var p = arguments[2]; // arguments[2] is part pointer
if (p.exists && p.secid)
{
var s = Section.GetFromID(m, p.secid);
if (s.exists && s.type == Section.SHELL && s.elform != 16)
p.Error("Shell part elform not 16", "Fictional company policy is to use elform 16 for shell parts");
}
Custom scripts will be called with 2 arguments:
arguments[0] = Name of the script
arguments[1] = model object
Custom scripts can add warnings or errors by using the static Check.Error() and
Check.Warning() methods. The script should not call the Error() and Warning() methods of other classes.
As a simple example of a custom check, suppose a dummy uses node 1000 for the H-point and this should be at coordinates (1000, -500, 100) within tolerance of 0.1
for an analysis . You do not want to run a check for every node in the model (i.e. an individual check). You just want to check that node
1000 is at the correct coordinates. To do this you could create a script called 'custom.js' in the directory 'OA_INSTALL/primer_library/scripts/checks' (or one of the other directories) containing:
// arguments[0] is name of script
var m = arguments[1]; // arguments[1] is model pointer
var n = Node.GetFromID(m, 1000);
if (!n)
Check.Error("No H-point node", "Model does not contain node for dummy H-point");
if (!n.exists)
Check.Error("H-point node not defined", "Dummy H-point node is referred to but not defined");
var dx = n.x - 1000;
var dy = n.y - (-500);
var dy = n.z - 100;
var d = Math.sqrt(dx*dx + dy*dy + dz*dz);
if (d > 0.1)
Check.Error("H-point not at correct position", "Dummy H-point is "+d+"mm away from target position");
See the documentation below for more details.
The comment to add.
ReturnsNo return value |
ExampleTo add a comment: Check.AddDashboardComment("This is a comment");
|
Text which will be displayed on the dashboard panel and the summary files.
Colour of the model health text. The default colour is Black.
Colour of the model health button. The default colour is dark grey.
ReturnsNo return value |
ExampleTo add computed health as "Model Health 85.1%" and the text colour to red and the button colour to green Check.AddDashboardHealth("Model Health 85.1%",Check.RED,Check.GREEN);
|
Error(message[string], details (optional)[string]) [static]DescriptionAdds a custom error. This function should only be called from a custom JavaScript check script. See the details in the Check class for how to do this. |
The error message to give
An optional detailed error message
ReturnsNo return value |
ExampleTo add an error message "My custom error": Check.Error('My custom error');
|
No arguments
ReturnsArray of dashboard objects Return typeArray |
If this flag is set to true then keyout is aborted else keyout proceeds as usual.
ReturnsNo return value |
ExampleTo abort a keyout, set the following line in keyout_hook.js: Check.KeyoutHook(true);
|
The first message to add.
The second message to add.
ReturnsNo return value |
SetDashboardStatus(status[constant]) [static]DescriptionSets the status of a user dashboard check.
|
The status. Can be Check.OK, Check.WARNING, Check.ERROR or Check.UNKNOWN.
ReturnsNo return value |
ExampleTo set the status to OK (green): Check.SetDashboardStatus(Check.OK);
|
Warning(message[string], details (optional)[string]) [static]DescriptionAdds a custom warning. This function should only be called from a custom JavaScript check script. See the details in the Check class for how to do this. |
The warning message to give
An optional detailed warning message
ReturnsNo return value |
ExampleTo add a warning message "My custom warning": Check.Warning('My custom warning');
|