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