The Group class gives you access to groups 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 |
| Group.ADD | Add contents to group |
| Group.REMOVE | Remove contents from group |
| Name | Type | Description |
| exists (read only) | logical | true if group exists, false if referred to but not defined. |
| include | integer | The Include file number that the group is in. |
| label | integer | Group number |
| lock | logical | Whether Group contents are locked against deletion. |
| model (read only) | integer | The Model number that the group is in. |
| numtypes (read only) | integer | Number of types in the group. |
| title | string | Group title |
Detailed DescriptionThe Group class allows you to create, modify, edit and manipulate groups. See the documentation below for more details. |
Constructornew Group(Model[Model], label[integer], title (optional)[string])DescriptionCreate a new Group object. |
Model that Group will be created in
Group number.
Title for the group
ReturnsGroup object Return typeGroup |
ExampleTo create a new group 99 in model m with title "Example": var g = new Group(m, 99, "Example");
|
Details of functionsAssociateComment(Comment[Comment])DescriptionAssociates a comment with a group. |
Comment that will be attached to the group
ReturnsNo return value |
ExampleTo associate comment c to the group g: g.AssociateComment(c);
|
Blank()DescriptionBlanks the group |
No arguments
ReturnsNo return value |
ExampleTo blank group g: g.Blank();
|
BlankAll(Model[Model], redraw (optional)[boolean]) [static]DescriptionBlanks all of the groups in the model. |
Model that all groups will be blanked in
If model should be redrawn or not. If omitted redraw is false. If you want to do several (un)blanks and only redraw after the last one then use false for all redraws apart from the last one. Alternatively you can redraw using View.Redraw().
ReturnsNo return value |
ExampleTo blank all of the groups in model m: Group.BlankAll(m);
|
BlankFlagged(Model[Model], flag[Flag], redraw (optional)[boolean]) [static]DescriptionBlanks all of the flagged groups in the model. |
Model that all the flagged groups will be blanked in
Flag set on the groups that you want to blank
If model should be redrawn or not. If omitted redraw is false. If you want to do several (un)blanks and only redraw after the last one then use false for all redraws apart from the last one. Alternatively you can redraw using View.Redraw().
ReturnsNo return value |
ExampleTo blank all of the groups in model m flagged with f: Group.BlankFlagged(m, f);
|
Blanked()DescriptionChecks if the group is blanked or not. |
No arguments
Returnstrue if blanked, false if not. Return typeBoolean |
ExampleTo check if group g is blanked: if (g.Blanked() ) do_something...
|
Browse(modal (optional)[boolean])DescriptionStarts an edit panel in Browse mode. |
If this window is modal (blocks the user from doing anything else in PRIMER until this window is dismissed). If omitted the window will be modal.
Returnsno return value |
ExampleTo Browse group g: g.Browse();
|
ClearFlag(flag[Flag])DescriptionClears a flag on the group. |
Flag to clear on the group
ReturnsNo return value |
ExampleTo clear flag f for group g: g.ClearFlag(f);
|
Copy(range (optional)[boolean])DescriptionCopies the group. The target include of the copied group can be set using Options.copy_target_include. |
If you want to keep the copied item in the range specified for the current include. Default value is false. To set current include, use Include.MakeCurrentLayer().
ReturnsGroup object Return typeGroup |
ExampleTo copy group g into group z: var z = g.Copy();
|
Create(Model[Model], modal (optional)[boolean]) [static]DescriptionStarts an interactive editing panel to create a group |
Model that the group will be created in.
If this window is modal (blocks the user from doing anything else in PRIMER until this window is dismissed). If omitted the window will be modal.
ReturnsGroup object (or null if not made). Return typeGroup |
ExampleTo start creating a group in model m: var g = Group.Create(m);
|
DetachComment(Comment[Comment])DescriptionDetaches a comment from a group. |
Comment that will be detached from the group
ReturnsNo return value |
ExampleTo detach comment c from the group g: g.DetachComment(c);
|
Edit(modal (optional)[boolean])DescriptionStarts an interactive editing panel. |
If this window is modal (blocks the user from doing anything else in PRIMER until this window is dismissed). If omitted the window will be modal.
Returnsno return value |
ExampleTo Edit group g: g.Edit();
|
Error(message[string], details (optional)[string])DescriptionAdds an error for group. For more details on checking see the Check class. |
The error message to give
An optional detailed error message
ReturnsNo return value |
ExampleTo add an error message "My custom error" for group g: g.Error("My custom error");
|
First(Model[Model]) [static]DescriptionReturns the first group in the model. |
Model to get first group in
ReturnsGroup object (or null if there are no groups in the model). Return typeGroup |
ExampleTo get the first group in model m: var g = Group.First(m);
|
FirstFreeLabel(Model[Model], layer (optional)[Include number]) [static]DescriptionReturns the first free group label in the model. Also see Group.LastFreeLabel(), Group.NextFreeLabel() and Model.FirstFreeItemLabel(). |
Model to get first free group label in
Include file (0 for the main file) to search for labels in (Equivalent to First free in layer in editing panels). If omitted the whole model will be used (Equivalent to First free in editing panels).
ReturnsGroup label. Return typeNumber |
ExampleTo get the first free group label in model m: var label = Group.FirstFreeLabel(m);
|
FlagAll(Model[Model], flag[Flag]) [static]DescriptionFlags all of the groups in the model with a defined flag. |
Model that all groups will be flagged in
Flag to set on the groups
ReturnsNo return value |
ExampleTo flag all of the groups with flag f in model m: Group.FlagAll(m, f);
|
Flagged(flag[Flag])DescriptionChecks if the group is flagged or not. |
Flag to test on the group
Returnstrue if flagged, false if not. Return typeBoolean |
ExampleTo check if group g has flag f set on it: if (g.Flagged(f) ) do_something...
|
ForEach(Model[Model], func[function], extra (optional)[any]) [static]DescriptionCalls a function for each group in the model. |
Model that all groups are in
Function to call for each group
An optional extra object/array/string etc that will appended to arguments when calling the function
ReturnsNo return value |
GetAll(Model[Model], property (optional)[string]) [static]DescriptionReturns an array of Group objects or properties for all of the groups in a model in PRIMER. If the optional property argument is not given then an array of Group objects is returned. If the property argument is given, that property value for each group is returned in the array instead of a Group object |
Model to get groups from
Name for property to get for all groups in the model
ReturnsArray of Group objects or properties Return typeArray |
GetComments()DescriptionExtracts the comments associated to a group. |
No arguments
ReturnsArray of Comment objects (or null if there are no comments associated to the node). Return typeArray |
ExampleTo get the array of comments associated to the group g: var comm_array = g.GetComments();
|
GetDataAll(type[string], index[integer])DescriptionReturns 'all' data for a given row number and type in the group. |
The type of the item
Index of 'all' row you want the data for. Note that indices start at 0, not 1.
0 <= index < Group.GetTotalAll()
ReturnsAn array containing data [Group.ADD or Group.REMOVE, BOX (if defined)]. Return typeArray |
ExampleTo get the data for the 3rd SHELL 'all' row in group g: var data = g.GetDataAll("SHELL", 2);
|
GetDataList(type[string], index[integer])DescriptionReturns 'list' data for a given row number and type in the group. |
The type of the item
Index of 'list' row you want the data for. Note that indices start at 0, not 1.
0 <= index < Group.GetTotalList()
ReturnsAn array containing data [Group.ADD or Group.REMOVE, ITEM1 (if defined), ITEM2 (if defined), ITEM3 (if defined), ITEM4 (if defined), ITEM5 (if defined), BOX (if defined)]. Return typeArray |
ExampleTo get the data for the 3rd SHELL 'list' row in group g: var data = g.GetDataList("SHELL", 2);
|
GetDataRange(type[string], index[integer])DescriptionReturns 'range' data for a given row number and type in the group. |
The type of the item
Index of 'range' row you want the data for. Note that indices start at 0, not 1.
0 <= index < Group.GetTotalRange()
ReturnsAn array containing data [Group.ADD or Group.REMOVE, START, END, BOX (if defined)]. Return typeArray |
ExampleTo get the data for the 3rd SHELL 'range' row in group g: var data = g.GetDataRange("SHELL", 2);
|
GetFlagged(Model[Model], flag[Flag], property (optional)[string]) [static]DescriptionReturns an array of Group objects for all of the flagged groups in a model in PRIMER If the optional property argument is not given then an array of Group objects is returned. If the property argument is given, then that property value for each group is returned in the array instead of a Group object |
Model to get groups from
Flag set on the groups that you want to retrieve
Name for property to get for all flagged groups in the model
ReturnsArray of Group objects or properties Return typeArray |
GetFromID(Model[Model], number[integer]) [static]DescriptionReturns the Group object for a group ID. |
Model to find the group in
number of the group you want the Group object for
ReturnsGroup object (or null if group does not exist). Return typeGroup |
ExampleTo get the Group object for group 100 in model m var g = Group.GetFromID(m, 100);
|
GetParameter(prop[string])DescriptionChecks if a Group property is a parameter or not. Note that object properties that are parameters are normally returned as the integer or float parameter values as that is virtually always what the user would want. For this function to work the JavaScript interpreter must use the parameter name instead of the value. This can be done by setting the Options.property_parameter_names option to true before calling the function and then resetting it to false afterwards.. This behaviour can also temporarily be switched by using the Group.ViewParameters() method and 'method chaining' (see the examples below). |
group property to get parameter for
ReturnsParameter object if property is a parameter, null if not. Return typeParameter |
GetTotalAll(type[string])DescriptionReturns the total number of 'all' rows for a type in a group |
The type of the item
ReturnsThe number of 'all' rows defined Return typeNumber |
ExampleTo get the total number of shell 'all' rows in group g: var nrow = g.GetTotalAll("SHELL");
|
GetTotalList(type[string])DescriptionReturns the total number of 'list' rows for a type in a group |
The type of the item
ReturnsThe number of 'list' rows defined Return typeNumber |
ExampleTo get the total number of shell 'list' rows in group g: var nrow = g.GetTotalList("SHELL");
|
GetTotalRange(type[string])DescriptionReturns the total number of 'range' rows for a type in a group |
The type of the item
ReturnsThe number of 'range' rows defined Return typeNumber |
ExampleTo get the total number of shell 'range' rows in group g: var nrow = g.GetTotalRange("SHELL");
|
GetTotals(type[string])DescriptionReturns the total number of 'all', 'list' and 'range' rows for a type in a group |
The type of the item
ReturnsArray containing number of 'all', 'list' and 'range' rows defined or null if type not in group. Return typeArray |
ExampleTo get the total number of shell 'all', 'list' and 'range' rows in group g: var totals = g.GetTotals("SHELL");
var nall = totals[0];
var nlist = totals[1];
var nrange = totals[2];
|
GetType(row[integer])DescriptionReturns the type for an entry in a group |
The entry in the group types that you want the type for. Note that entries start at 0, not 1
ReturnsThe type of the item (string) Return typeString |
ExampleTo list the types that are present in group g: for (var t=0; t<g.numtypes; t++)
{
var type = g.GetType(t);
Message(type);
}
|
Keyword()DescriptionReturns the keyword for this group. Note that a carriage return is not added. See also Group.KeywordCards() |
No arguments
Returnsstring containing the keyword. Return typeString |
ExampleTo get the keyword for goup g: var key = g.Keyword();
|
KeywordCards()DescriptionReturns the keyword cards for the Group. Note that a carriage return is not added. See also Group.Keyword() |
No arguments
Returnsstring containing the cards. Return typeString |
ExampleTo get the cards for Group g: var cards = g.KeywordCards();
|
Last(Model[Model]) [static]DescriptionReturns the last group in the model. |
Model to get last group in
ReturnsGroup object (or null if there are no groups in the model). Return typeGroup |
ExampleTo get the last group in model m: var g = Group.Last(m);
|
LastFreeLabel(Model[Model], layer (optional)[Include number]) [static]DescriptionReturns the last free group label in the model. Also see Group.FirstFreeLabel(), Group.NextFreeLabel() and see Model.LastFreeItemLabel() |
Model to get last free group label in
Include file (0 for the main file) to search for labels in (Equivalent to Highest free in layer in editing panels). If omitted the whole model will be used.
ReturnsGroup label. Return typeNumber |
ExampleTo get the last free group label in model m: var label = Group.LastFreeLabel(m);
|
Next()DescriptionReturns the next group in the model. |
No arguments
ReturnsGroup object (or null if there are no more groups in the model). Return typeGroup |
ExampleTo get the group in model m after group g: var g = g.Next();
|
NextFreeLabel(Model[Model], layer (optional)[Include number]) [static]DescriptionReturns the next free (highest+1) group label in the model. Also see Group.FirstFreeLabel(), Group.LastFreeLabel() and Model.NextFreeItemLabel() |
Model to get next free group label in
Include file (0 for the main file) to search for labels in (Equivalent to Highest+1 in layer in editing panels). If omitted the whole model will be used (Equivalent to Highest+1 in editing panels).
ReturnsGroup label. Return typeNumber |
ExampleTo get the next free group label in model m: var label = Group.NextFreeLabel(m);
|
Pick(prompt[string], limit (optional)[Model or Flag], modal (optional)[boolean], button text (optional)[string]) [static]DescriptionAllows the user to pick a group. |
Text to display as a prompt to the user
If the argument is a Model then only groups from that model can be picked. If the argument is a Flag then only groups that are flagged with limit can be selected. If omitted, or null, any groups from any model can be selected. from any model.
If picking is modal (blocks the user from doing anything else in PRIMER until this window is dismissed). If omitted the pick will be modal.
By default the window with the prompt will have a button labelled 'Cancel' which if pressed will cancel the pick and return null. If you want to change the text on the button use this argument. If omitted 'Cancel' will be used.
ReturnsGroup object (or null if not picked) Return typeGroup |
ExampleTo pick a group from model m giving the prompt 'Pick group from screen': var g = Group.Pick('Pick group from screen', m);
|
Previous()DescriptionReturns the previous group in the model. |
No arguments
ReturnsGroup object (or null if there are no more groups in the model). Return typeGroup |
ExampleTo get the group in model m before group g: var g = g.Previous();
|
RemoveDataAll(type[string], index[integer])DescriptionRemoves 'all' data for a given row number and type in the group. |
The type of the item
Index of 'all' row you want to Remove. Note that indices start at 0, not 1.
0 <= index < Group.GetTotalAll()
ReturnsNo return value |
ExampleTo remove the data for the 3rd SHELL 'all' row in group g: g.RemoveDataAll("SHELL", 2);
|
RemoveDataList(type[string], index[integer])DescriptionRemoves 'list' data for a given row number and type in the group. |
The type of the item
Index of 'list' row you want to Remove. Note that indices start at 0, not 1.
0 <= index < Group.GetTotalList()
ReturnsNo return value |
ExampleTo remove the data for the 3rd SHELL 'list' row in group g: g.RemoveDataList("SHELL", 2);
|
RemoveDataRange(type[string], index[integer])DescriptionRemoves 'range' data for a given row number and type in the group. |
The type of the item
Index of 'range' row you want to Remove. Note that indices start at 0, not 1.
0 <= index < Group.GetTotalRange()
ReturnsNo return value |
ExampleTo remove the data for the 3rd SHELL 'range' row in group g: g.RemoveDataRange("SHELL", 2);
|
RenumberAll(Model[Model], start[integer]) [static]DescriptionRenumbers all of the groups in the model. |
Model that all groups will be renumbered in
Start point for renumbering
ReturnsNo return value |
ExampleTo renumber all of the groups in model m, from 1000000: Group.RenumberAll(m, 1000000);
|
RenumberFlagged(Model[Model], flag[Flag], start[integer]) [static]DescriptionRenumbers all of the flagged groups in the model. |
Model that all the flagged groups will be renumbered in
Flag set on the groups that you want to renumber
Start point for renumbering
ReturnsNo return value |
ExampleTo renumber all of the groups in model m flagged with f, from 1000000: Group.RenumberFlagged(m, f, 1000000);
|
Select(flag[Flag], prompt[string], limit (optional)[Model or Flag], modal (optional)[boolean]) [static]DescriptionAllows the user to select groups using standard PRIMER object menus. |
Flag to use when selecting groups
Text to display as a prompt to the user
If the argument is a Model then only groups from that model can be selected. If the argument is a Flag then only groups that are flagged with limit can be selected (limit should be different to flag). If omitted, or null, any groups can be selected. from any model.
If selection is modal (blocks the user from doing anything else in PRIMER until this window is dismissed). If omitted the selection will be modal.
ReturnsNumber of groups selected or null if menu cancelled Return typeNumber |
SetDataAll(type[string], index[integer], data[Array of data])DescriptionSets 'all' data for a given row number and type in the group. |
The type of the item
Index of 'all' row you want the data for. Note that indices start at 0, not 1.
0 <= index <= Group.GetTotalAll()
An array containing data [Group.ADD or Group.REMOVE, BOX (if defined)].
ReturnsNo return value |
ExampleTo set the data for the 3rd SHELL 'all' row in group g to 'add box 10': var data = [Group.ADD, 10];
g.SetDataAll("SHELL", 2, data);
|
SetDataList(type[string], index[integer], data[Array of data])DescriptionSets 'list' data for a given row number and type in the group. |
The type of the item
Index of 'list' row you want the data for. Note that indices start at 0, not 1.
0 <= index <= Group.GetTotalList()
An array containing data [Group.ADD or Group.REMOVE, ITEM1 (if defined), ITEM2 (if defined), ITEM3 (if defined), ITEM4 (if defined), ITEM5 (if defined), BOX (if defined)].
ReturnsNo return value |
ExampleTo set the data for the 3rd SHELL 'list' row in group g to 'add 1 2 box 10': var data = [Group.ADD, 1, 2, 0, 0, 0, 10];
g.SetDataList("SHELL", 2, data);
|
SetDataRange(type[string], index[integer], data[Array of data])DescriptionSets 'range' data for a given row number and type in the group. |
The type of the item
Index of 'all' row you want the data for. Note that indices start at 0, not 1.
0 <= index <= Group.GetTotalRange()
An array containing data [Group.ADD or Group.REMOVE, START, END, BOX (if defined)].
ReturnsNo return value |
ExampleTo set the data for the 3rd SHELL 'range' row in group g to 'add 100 200 box 10': var data = [Group.ADD, 100, 200, 10];
g.SetDataRange("SHELL", 2, data);
|
SetFlag(flag[Flag])DescriptionSets a flag on the group. |
Flag to set on the group
ReturnsNo return value |
ExampleTo set flag f for group g: g.SetFlag(f);
|
Sketch(redraw (optional)[boolean])DescriptionSketches the group. The group will be sketched until you either call Group.Unsketch(), Group.UnsketchAll(), Model.UnsketchAll(), or delete the model |
If model should be redrawn or not after the group is sketched. If omitted redraw is true. If you want to sketch several groups and only redraw after the last one then use false for redraw and call View.Redraw().
ReturnsNo return value |
ExampleTo sketch group g: g.Sketch();
|
SketchFlagged(Model[Model], flag[Flag], redraw (optional)[boolean]) [static]DescriptionSketches all of the flagged groups in the model. The groups will be sketched until you either call Group.Unsketch(), Group.UnsketchFlagged(), Model.UnsketchAll(), or delete the model |
Model that all the flagged groups will be sketched in
Flag set on the groups that you want to sketch
If model should be redrawn or not after the groups are sketched. If omitted redraw is true. If you want to sketch flagged groups several times and only redraw after the last one then use false for redraw and call View.Redraw().
ReturnsNo return value |
ExampleTo sketch all groups flagged with flag in model m: Group.SketchFlagged(m, flag);
|
Total(Model[Model], exists (optional)[boolean]) [static]DescriptionReturns the total number of groups in the model. |
Model to get total for
true if only existing groups should be counted. If false or omitted referenced but undefined groups will also be included in the total.
Returnsnumber of groups Return typeNumber |
ExampleTo get the total number of groups in model m: var total = Group.Total(m);
|
Unblank()DescriptionUnblanks the group |
No arguments
ReturnsNo return value |
ExampleTo unblank group g: g.Unblank();
|
UnblankAll(Model[Model], redraw (optional)[boolean]) [static]DescriptionUnblanks all of the groups in the model. |
Model that all groups will be unblanked in
If model should be redrawn or not. If omitted redraw is false. If you want to do several (un)blanks and only redraw after the last one then use false for all redraws apart from the last one. Alternatively you can redraw using View.Redraw().
ReturnsNo return value |
ExampleTo unblank all of the groups in model m: Group.UnblankAll(m);
|
UnblankFlagged(Model[Model], flag[Flag], redraw (optional)[boolean]) [static]DescriptionUnblanks all of the flagged groups in the model. |
Model that the flagged groups will be unblanked in
Flag set on the groups that you want to unblank
If model should be redrawn or not. If omitted redraw is false. If you want to do several (un)blanks and only redraw after the last one then use false for all redraws apart from the last one. Alternatively you can redraw using View.Redraw().
ReturnsNo return value |
ExampleTo unblank all of the groups in model m flagged with f: Group.UnblankFlagged(m, f);
|
UnflagAll(Model[Model], flag[Flag]) [static]DescriptionUnsets a defined flag on all of the groups in the model. |
Model that the defined flag for all groups will be unset in
Flag to unset on the groups
ReturnsNo return value |
ExampleTo unset the flag f on all the groups in model m: Group.UnflagAll(m, f);
|
Unsketch(redraw (optional)[boolean])DescriptionUnsketches the group. |
If model should be redrawn or not after the group is unsketched. If omitted redraw is true. If you want to unsketch several groups and only redraw after the last one then use false for redraw and call View.Redraw().
ReturnsNo return value |
ExampleTo unsketch group g: g.Unsketch();
|
UnsketchAll(Model[Model], redraw (optional)[boolean]) [static]DescriptionUnsketches all groups. |
Model that all groups will be unblanked in
If model should be redrawn or not after the groups are unsketched. If omitted redraw is true. If you want to unsketch several things and only redraw after the last one then use false for redraw and call View.Redraw().
ReturnsNo return value |
ExampleTo unsketch all groups in model m: Group.UnsketchAll(m);
|
UnsketchFlagged(Model[Model], flag[Flag], redraw (optional)[boolean]) [static]DescriptionUnsketches all flagged groups in the model. |
Model that all groups will be unsketched in
Flag set on the groups that you want to unsketch
If model should be redrawn or not after the groups are unsketched. If omitted redraw is true. If you want to unsketch several things and only redraw after the last one then use false for redraw and call View.Redraw().
ReturnsNo return value |
ExampleTo unsketch all groups flagged with flag in model m: Group.UnsketchAll(m, flag);
|
No arguments
ReturnsGroup object. Return typeGroup |
ExampleTo check if Group property g.example is a parameter by using the Group.GetParameter() method: if (g.ViewParameters().GetParameter(g.example) ) do_something...
|
Warning(message[string], details (optional)[string])DescriptionAdds a warning for group. For more details on checking see the Check class. |
The warning message to give
An optional detailed warning message
ReturnsNo return value |
ExampleTo add a warning message "My custom warning" for group g: g.Warning("My custom warning");
|
Xrefs()DescriptionReturns the cross references for this group. |
No arguments
ReturnsXrefs object. Return typeXrefs |
ExampleTo get the cross references for group g: var xrefs = g.Xrefs();
|
toString()DescriptionCreates a string containing the Group data in keyword format. Note that this contains the keyword header and the keyword cards. See also Group.Keyword() and Group.KeywordCards(). |
No arguments
Returnsstring Return typeString |
ExampleTo get data for Group g in keyword format var s = g.toString();
|