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