The Sph class gives you access to Element SPH cards 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 | Type | Description |
| colour | Colour | The colour of the sph element. |
| exists (read only) | logical | true if sph exists, false if referred to but not defined. |
| include | integer | The Include file number that the sph is in. |
| mass | real | Mass value. |
| model (read only) | integer | The Model number that the sph is in. |
| nid | integer | Node ID. |
| pid | integer | Part ID to which this element belongs. |
| transparency | integer | The transparency of the sph (0-100) 0% is opaque, 100% is transparent. |
Detailed DescriptionThe Sph class allows you to create, modify, edit and manipulate SPH cards. See the documentation below for more details. |
Constructornew Sph(Model[Model], nid[integer], pid[integer], mass[real])Description |
Model that sph will be created in
Node ID and Element ID are the same for the SPH option.
Part ID to which this element belongs.
Mass value.
ReturnsSph object Return typeSph |
ExampleTo create a new sph element in model m with nid = 100, pid = 400, mass = 0.9: var s = new Sph(m, 100, 400, 0.9);
|
Details of functionsAssociateComment(Comment[Comment])DescriptionAssociates a comment with a sph. |
Comment that will be attached to the sph
ReturnsNo return value |
ExampleTo associate comment c to the sph s: s.AssociateComment(c);
|
Blank()DescriptionBlanks the sph |
No arguments
ReturnsNo return value |
ExampleTo blank sph s: s.Blank();
|
BlankAll(Model[Model], redraw (optional)[boolean]) [static]DescriptionBlanks all of the sphs in the model. |
Model that all sphs 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 sphs in model m: Sph.BlankAll(m);
|
BlankFlagged(Model[Model], flag[Flag], redraw (optional)[boolean]) [static]DescriptionBlanks all of the flagged sphs in the model. |
Model that all the flagged sphs will be blanked in
Flag set on the sphs 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 sphs in model m flagged with f: Sph.BlankFlagged(m, f);
|
Blanked()DescriptionChecks if the sph is blanked or not. |
No arguments
Returnstrue if blanked, false if not. Return typeBoolean |
ExampleTo check if sph s is blanked: if (s.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 sph s: s.Browse();
|
ClearFlag(flag[Flag])DescriptionClears a flag on the sph. |
Flag to clear on the sph
ReturnsNo return value |
ExampleTo clear flag f for sph s: s.ClearFlag(f);
|
Copy(range (optional)[boolean])DescriptionCopies the sph. The target include of the copied sph 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().
ReturnsSph object Return typeSph |
ExampleTo copy sph s into sph z: var z = s.Copy();
|
Create(Model[Model], modal (optional)[boolean]) [static]DescriptionStarts an interactive editing panel to create a sph |
Model that the sph 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.
ReturnsSph object (or null if not made). Return typeSph |
ExampleTo start creating a sph in model m: var s = Sph.Create(m);
|
DetachComment(Comment[Comment])DescriptionDetaches a comment from a sph. |
Comment that will be detached from the sph
ReturnsNo return value |
ExampleTo detach comment c from the sph s: s.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 sph s: s.Edit();
|
Error(message[string], details (optional)[string])DescriptionAdds an error for sph. 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 sph s: s.Error("My custom error");
|
ExtractColour()DescriptionExtracts the actual colour used for sph. |
No arguments
Returnscolour value (integer) Return typeNumber |
ExampleTo return the colour used for drawing sph s: var colour = s.ExtractColour();
|
First(Model[Model]) [static]DescriptionReturns the first sph in the model. |
Model to get first sph in
ReturnsSph object (or null if there are no sphs in the model). Return typeSph |
ExampleTo get the first sph in model m: var s = Sph.First(m);
|
FirstFreeLabel(Model[Model], layer (optional)[Include number]) [static]DescriptionReturns the first free sph label in the model. Also see Sph.LastFreeLabel(), Sph.NextFreeLabel() and Model.FirstFreeItemLabel(). |
Model to get first free sph 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).
ReturnsSph label. Return typeNumber |
ExampleTo get the first free sph label in model m: var label = Sph.FirstFreeLabel(m);
|
FlagAll(Model[Model], flag[Flag]) [static]DescriptionFlags all of the sphs in the model with a defined flag. |
Model that all sphs will be flagged in
Flag to set on the sphs
ReturnsNo return value |
ExampleTo flag all of the sphs with flag f in model m: Sph.FlagAll(m, f);
|
Flagged(flag[Flag])DescriptionChecks if the sph is flagged or not. |
Flag to test on the sph
Returnstrue if flagged, false if not. Return typeBoolean |
ExampleTo check if sph s has flag f set on it: if (s.Flagged(f) ) do_something...
|
ForEach(Model[Model], func[function], extra (optional)[any]) [static]DescriptionCalls a function for each sph in the model. |
Model that all sphs are in
Function to call for each sph
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 Sph objects or properties for all of the sphs in a model in PRIMER. If the optional property argument is not given then an array of Sph objects is returned. If the property argument is given, that property value for each sph is returned in the array instead of a Sph object |
Model to get sphs from
Name for property to get for all sphs in the model
ReturnsArray of Sph objects or properties Return typeArray |
GetComments()DescriptionExtracts the comments associated to a sph. |
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 sph s: var comm_array = s.GetComments();
|
GetFlagged(Model[Model], flag[Flag], property (optional)[string]) [static]DescriptionReturns an array of Sph objects for all of the flagged sphs in a model in PRIMER If the optional property argument is not given then an array of Sph objects is returned. If the property argument is given, then that property value for each sph is returned in the array instead of a Sph object |
Model to get sphs from
Flag set on the sphs that you want to retrieve
Name for property to get for all flagged sphs in the model
ReturnsArray of Sph objects or properties Return typeArray |
GetFromID(Model[Model], number[integer]) [static]DescriptionReturns the Sph object for a sph ID. |
Model to find the sph in
number of the sph you want the Sph object for
ReturnsSph object (or null if sph does not exist). Return typeSph |
ExampleTo get the Sph object for sph 100 in model m var s = Sph.GetFromID(m, 100);
|
GetParameter(prop[string])DescriptionChecks if a Sph 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 Sph.ViewParameters() method and 'method chaining' (see the examples below). |
sph property to get parameter for
ReturnsParameter object if property is a parameter, null if not. Return typeParameter |
Keyword()DescriptionReturns the keyword for this sph (*ELEMENT_SPH) Note that a carriage return is not added. See also Sph.KeywordCards() |
No arguments
Returnsstring containing the keyword. Return typeString |
ExampleTo get the keyword for sph s: var key = s.Keyword();
|
KeywordCards()DescriptionReturns the keyword cards for the sph. Note that a carriage return is not added. See also Sph.Keyword() |
No arguments
Returnsstring containing the cards. Return typeString |
ExampleTo get the cards for sph s: var cards = s.KeywordCards();
|
Last(Model[Model]) [static]DescriptionReturns the last sph in the model. |
Model to get last sph in
ReturnsSph object (or null if there are no sphs in the model). Return typeSph |
ExampleTo get the last sph in model m: var s = Sph.Last(m);
|
LastFreeLabel(Model[Model], layer (optional)[Include number]) [static]DescriptionReturns the last free sph label in the model. Also see Sph.FirstFreeLabel(), Sph.NextFreeLabel() and see Model.LastFreeItemLabel() |
Model to get last free sph 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.
ReturnsSph label. Return typeNumber |
ExampleTo get the last free sph label in model m: var label = Sph.LastFreeLabel(m);
|
Next()DescriptionReturns the next sph in the model. |
No arguments
ReturnsSph object (or null if there are no more sphs in the model). Return typeSph |
ExampleTo get the sph in model m after sph s: var s = s.Next();
|
NextFreeLabel(Model[Model], layer (optional)[Include number]) [static]DescriptionReturns the next free (highest+1) sph label in the model. Also see Sph.FirstFreeLabel(), Sph.LastFreeLabel() and Model.NextFreeItemLabel() |
Model to get next free sph 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).
ReturnsSph label. Return typeNumber |
ExampleTo get the next free sph label in model m: var label = Sph.NextFreeLabel(m);
|
Pick(prompt[string], limit (optional)[Model or Flag], modal (optional)[boolean], button text (optional)[string]) [static]DescriptionAllows the user to pick a sph. |
Text to display as a prompt to the user
If the argument is a Model then only sphs from that model can be picked. If the argument is a Flag then only sphs that are flagged with limit can be selected. If omitted, or null, any sphs 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.
ReturnsSph object (or null if not picked) Return typeSph |
ExampleTo pick a sph from model m giving the prompt 'Pick sph from screen': var s = Sph.Pick('Pick sph from screen', m);
|
Previous()DescriptionReturns the previous sph in the model. |
No arguments
ReturnsSph object (or null if there are no more sphs in the model). Return typeSph |
ExampleTo get the sph in model m before sph s: var s = s.Previous();
|
RenumberAll(Model[Model], start[integer]) [static]DescriptionRenumbers all of the sphs in the model. |
Model that all sphs will be renumbered in
Start point for renumbering
ReturnsNo return value |
ExampleTo renumber all of the sphs in model m, from 1000000: Sph.RenumberAll(m, 1000000);
|
RenumberFlagged(Model[Model], flag[Flag], start[integer]) [static]DescriptionRenumbers all of the flagged sphs in the model. |
Model that all the flagged sphs will be renumbered in
Flag set on the sphs that you want to renumber
Start point for renumbering
ReturnsNo return value |
ExampleTo renumber all of the sphs in model m flagged with f, from 1000000: Sph.RenumberFlagged(m, f, 1000000);
|
Select(flag[Flag], prompt[string], limit (optional)[Model or Flag], modal (optional)[boolean]) [static]DescriptionAllows the user to select sphs using standard PRIMER object menus. |
Flag to use when selecting sphs
Text to display as a prompt to the user
If the argument is a Model then only sphs from that model can be selected. If the argument is a Flag then only sphs that are flagged with limit can be selected (limit should be different to flag). If omitted, or null, any sphs 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 sphs selected or null if menu cancelled Return typeNumber |
SetFlag(flag[Flag])DescriptionSets a flag on the sph. |
Flag to set on the sph
ReturnsNo return value |
ExampleTo set flag f for sph s: s.SetFlag(f);
|
Sketch(redraw (optional)[boolean])DescriptionSketches the sph. The sph will be sketched until you either call Sph.Unsketch(), Sph.UnsketchAll(), Model.UnsketchAll(), or delete the model |
If model should be redrawn or not after the sph is sketched. If omitted redraw is true. If you want to sketch several sphs and only redraw after the last one then use false for redraw and call View.Redraw().
ReturnsNo return value |
ExampleTo sketch sph s: s.Sketch();
|
SketchFlagged(Model[Model], flag[Flag], redraw (optional)[boolean]) [static]DescriptionSketches all of the flagged sphs in the model. The sphs will be sketched until you either call Sph.Unsketch(), Sph.UnsketchFlagged(), Model.UnsketchAll(), or delete the model |
Model that all the flagged sphs will be sketched in
Flag set on the sphs that you want to sketch
If model should be redrawn or not after the sphs are sketched. If omitted redraw is true. If you want to sketch flagged sphs several times and only redraw after the last one then use false for redraw and call View.Redraw().
ReturnsNo return value |
ExampleTo sketch all sphs flagged with flag in model m: Sph.SketchFlagged(m, flag);
|
Total(Model[Model], exists (optional)[boolean]) [static]DescriptionReturns the total number of sphs in the model. |
Model to get total for
true if only existing sphs should be counted. If false or omitted referenced but undefined sphs will also be included in the total.
Returnsnumber of sphs Return typeNumber |
ExampleTo get the total number of sphs in model m: var total = Sph.Total(m);
|
Unblank()DescriptionUnblanks the sph |
No arguments
ReturnsNo return value |
ExampleTo unblank sph s: s.Unblank();
|
UnblankAll(Model[Model], redraw (optional)[boolean]) [static]DescriptionUnblanks all of the sphs in the model. |
Model that all sphs 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 sphs in model m: Sph.UnblankAll(m);
|
UnblankFlagged(Model[Model], flag[Flag], redraw (optional)[boolean]) [static]DescriptionUnblanks all of the flagged sphs in the model. |
Model that the flagged sphs will be unblanked in
Flag set on the sphs 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 sphs in model m flagged with f: Sph.UnblankFlagged(m, f);
|
UnflagAll(Model[Model], flag[Flag]) [static]DescriptionUnsets a defined flag on all of the sphs in the model. |
Model that the defined flag for all sphs will be unset in
Flag to unset on the sphs
ReturnsNo return value |
ExampleTo unset the flag f on all the sphs in model m: Sph.UnflagAll(m, f);
|
Unsketch(redraw (optional)[boolean])DescriptionUnsketches the sph. |
If model should be redrawn or not after the sph is unsketched. If omitted redraw is true. If you want to unsketch several sphs and only redraw after the last one then use false for redraw and call View.Redraw().
ReturnsNo return value |
ExampleTo unsketch sph s: s.Unsketch();
|
UnsketchAll(Model[Model], redraw (optional)[boolean]) [static]DescriptionUnsketches all sphs. |
Model that all sphs will be unblanked in
If model should be redrawn or not after the sphs 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 sphs in model m: Sph.UnsketchAll(m);
|
UnsketchFlagged(Model[Model], flag[Flag], redraw (optional)[boolean]) [static]DescriptionUnsketches all flagged sphs in the model. |
Model that all sphs will be unsketched in
Flag set on the sphs that you want to unsketch
If model should be redrawn or not after the sphs 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 sphs flagged with flag in model m: Sph.UnsketchAll(m, flag);
|
No arguments
ReturnsSph object. Return typeSph |
ExampleTo check if Sph property s.example is a parameter by using the Sph.GetParameter() method: if (s.ViewParameters().GetParameter(s.example) ) do_something...
|
Warning(message[string], details (optional)[string])DescriptionAdds a warning for sph. 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 sph s: s.Warning("My custom warning");
|
Xrefs()DescriptionReturns the cross references for this sph. |
No arguments
ReturnsXrefs object. Return typeXrefs |
ExampleTo get the cross references for sph s: var xrefs = s.Xrefs();
|
toString()DescriptionCreates a string containing the sph data in keyword format. Note that this contains the keyword header and the keyword cards. See also Sph.Keyword() and Sph.KeywordCards(). |
No arguments
Returnsstring Return typeString |
ExampleTo get data for sph s in keyword format var str = s.toString();
|