Oasys.PRIMER.Discrete class¶
Properties¶
- property Discrete.colour: Colour¶
The colour of the discrete
- property Discrete.eid: integer¶
Discrete
number. Also see thelabel
property which is an alternative name for this
- property Discrete.exists(read only): boolean¶
true if discrete exists, false if referred to but not defined
- property Discrete.label: integer¶
Discrete
number. Also see theeid
property which is an alternative name for this
- property Discrete.lco: boolean¶
If LCO option is set. Can be true or false
- property Discrete.offset: float¶
Initial offset
- property Discrete.pf: integer¶
Print flag. Set to write forces to the DEFORC file
- property Discrete.s: float¶
Scale factor on forces
- property Discrete.transparency: integer¶
The transparency of the discrete (0-100) 0% is opaque, 100% is transparent
- property Discrete.vid: integer¶
Orientation vector
Constructor¶
- classmethod Discrete(model, eid, pid, n1, n2, vid=Oasys.gRPC.defaultArg, s=Oasys.gRPC.defaultArg, pf=Oasys.gRPC.defaultArg, offset=Oasys.gRPC.defaultArg)¶
Create a new
Discrete
object
- Parameters:
model (Model) –
Model
that discrete will be created ineid (integer) –
Discrete
numberpid (integer) –
Part
numbern1 (integer) –
Node
number 1n2 (integer) –
Node
number 2vid (integer) – Optional. Orientation vector
s (float) – Optional. Scale factor on forces
pf (integer) – Optional. Print flag. Set to write forces to the DEFORC file
offset (float) – Optional. Initial offset
- Returns:
Discrete object
- Return type:
dict
Example
To create a new discrete in model m with label 200, in part 10, on nodes 1 and 2
m = Oasys.PRIMER.Discrete(m, 200, 10, 1, 2)
Static methods¶
- classmethod Discrete.BlankAll(model, redraw=Oasys.gRPC.defaultArg)¶
Blanks all of the discretes in the model
- Parameters:
model (Model) –
Model
that all discretes will be blanked inredraw (boolean) – Optional. 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()
- Returns:
No return value
- Return type:
None
Example
To blank all of the discretes in model m:
Oasys.PRIMER.Discrete.BlankAll(m)
- classmethod Discrete.BlankFlagged(model, flag, redraw=Oasys.gRPC.defaultArg)¶
Blanks all of the flagged discretes in the model
- Parameters:
model (Model) –
Model
that all the flagged discretes will be blanked inflag (Flag) – Flag set on the discretes that you want to blank
redraw (boolean) – Optional. 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()
- Returns:
No return value
- Return type:
None
Example
To blank all of the discretes in model m flagged with f:
Oasys.PRIMER.Discrete.BlankFlagged(m, f)
- classmethod Discrete.Create(model, modal=Oasys.gRPC.defaultArg)¶
Starts an interactive editing panel to create a discrete
- Parameters:
model (Model) –
Model
that the discrete will be created inmodal (boolean) – Optional. 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
- Returns:
Discrete object (or None if not made)
- Return type:
dict
Example
To start creating a discrete in model m:
m = Oasys.PRIMER.Discrete.Create(m)
- classmethod Discrete.First(model)¶
Returns the first discrete in the model
- Parameters:
model (Model) –
Model
to get first discrete in- Returns:
Discrete object (or None if there are no discretes in the model)
- Return type:
Discrete
Example
To get the first discrete in model m:
d = Oasys.PRIMER.Discrete.First(m)
- classmethod Discrete.FirstFreeLabel(model, layer=Oasys.gRPC.defaultArg)¶
Returns the first free discrete label in the model. Also see
Discrete.LastFreeLabel()
,Discrete.NextFreeLabel()
andModel.FirstFreeItemLabel()
- Parameters:
- Returns:
Discrete label
- Return type:
int
Example
To get the first free discrete label in model m:
label = Oasys.PRIMER.Discrete.FirstFreeLabel(m)
- classmethod Discrete.FlagAll(model, flag)¶
Flags all of the discretes in the model with a defined flag
- Parameters:
model (Model) –
Model
that all discretes will be flagged inflag (Flag) – Flag to set on the discretes
- Returns:
No return value
- Return type:
None
Example
To flag all of the discretes with flag f in model m:
Oasys.PRIMER.Discrete.FlagAll(m, f)
- classmethod Discrete.GetAll(model)¶
Returns a list of Discrete objects for all of the discretes in a model in PRIMER
- Parameters:
model (Model) –
Model
to get discretes from- Returns:
List of Discrete objects
- Return type:
list
Example
To make a list of Discrete objects for all of the discretes in model m
d = Oasys.PRIMER.Discrete.GetAll(m)
- classmethod Discrete.GetFlagged(model, flag)¶
Returns a list of Discrete objects for all of the flagged discretes in a model in PRIMER
- Parameters:
model (Model) –
Model
to get discretes fromflag (Flag) – Flag set on the discretes that you want to retrieve
- Returns:
List of Discrete objects
- Return type:
list
Example
To make a list of Discrete objects for all of the discretes in model m flagged with f
d = Oasys.PRIMER.Discrete.GetFlagged(m, f)
- classmethod Discrete.GetFromID(model, number)¶
Returns the Discrete object for a discrete ID
- Parameters:
model (Model) –
Model
to find the discrete innumber (integer) – number of the discrete you want the Discrete object for
- Returns:
Discrete object (or None if discrete does not exist)
- Return type:
Discrete
Example
To get the Discrete object for discrete 100 in model m
d = Oasys.PRIMER.Discrete.GetFromID(m, 100)
- classmethod Discrete.Last(model)¶
Returns the last discrete in the model
- Parameters:
model (Model) –
Model
to get last discrete in- Returns:
Discrete object (or None if there are no discretes in the model)
- Return type:
Discrete
Example
To get the last discrete in model m:
d = Oasys.PRIMER.Discrete.Last(m)
- classmethod Discrete.LastFreeLabel(model, layer=Oasys.gRPC.defaultArg)¶
Returns the last free discrete label in the model. Also see
Discrete.FirstFreeLabel()
,Discrete.NextFreeLabel()
and seeModel.LastFreeItemLabel()
- Parameters:
- Returns:
Discrete label
- Return type:
int
Example
To get the last free discrete label in model m:
label = Oasys.PRIMER.Discrete.LastFreeLabel(m)
- classmethod Discrete.NextFreeLabel(model, layer=Oasys.gRPC.defaultArg)¶
Returns the next free (highest+1) discrete label in the model. Also see
Discrete.FirstFreeLabel()
,Discrete.LastFreeLabel()
andModel.NextFreeItemLabel()
- Parameters:
- Returns:
Discrete label
- Return type:
int
Example
To get the next free discrete label in model m:
label = Oasys.PRIMER.Discrete.NextFreeLabel(m)
- classmethod Discrete.Pick(prompt, limit=Oasys.gRPC.defaultArg, modal=Oasys.gRPC.defaultArg, button_text=Oasys.gRPC.defaultArg)¶
Allows the user to pick a discrete
- Parameters:
prompt (string) – Text to display as a prompt to the user
limit (Model or Flag) – Optional. If the argument is a
Model
then only discretes from that model can be picked. If the argument is aFlag
then only discretes that are flagged with limit can be selected. If omitted, or None, any discretes from any model can be selected. from any modelmodal (boolean) – Optional. 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
button_text (string) – Optional. By default the window with the prompt will have a button labelled ‘Cancel’ which if pressed will cancel the pick and return None. If you want to change the text on the button use this argument. If omitted ‘Cancel’ will be used
- Returns:
Discrete object (or None if not picked)
- Return type:
dict
Example
To pick a discrete from model m giving the prompt ‘Pick discrete from screen’:
d = Oasys.PRIMER.Discrete.Pick('Pick discrete from screen', m)
- classmethod Discrete.RenumberAll(model, start)¶
Renumbers all of the discretes in the model
- Parameters:
model (Model) –
Model
that all discretes will be renumbered instart (integer) – Start point for renumbering
- Returns:
No return value
- Return type:
None
Example
To renumber all of the discretes in model m, from 1000000:
Oasys.PRIMER.Discrete.RenumberAll(m, 1000000)
- classmethod Discrete.RenumberFlagged(model, flag, start)¶
Renumbers all of the flagged discretes in the model
- Parameters:
model (Model) –
Model
that all the flagged discretes will be renumbered inflag (Flag) – Flag set on the discretes that you want to renumber
start (integer) – Start point for renumbering
- Returns:
No return value
- Return type:
None
Example
To renumber all of the discretes in model m flagged with f, from 1000000:
Oasys.PRIMER.Discrete.RenumberFlagged(m, f, 1000000)
- classmethod Discrete.Select(flag, prompt, limit=Oasys.gRPC.defaultArg, modal=Oasys.gRPC.defaultArg)¶
Allows the user to select discretes using standard PRIMER object menus
- Parameters:
flag (Flag) – Flag to use when selecting discretes
prompt (string) – Text to display as a prompt to the user
limit (Model or Flag) – Optional. If the argument is a
Model
then only discretes from that model can be selected. If the argument is aFlag
then only discretes that are flagged with limit can be selected (limit should be different to flag). If omitted, or None, any discretes can be selected. from any modelmodal (boolean) – Optional. 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
- Returns:
Number of discretes selected or None if menu cancelled
- Return type:
int
Example
To select discretes from model m, flagging those selected with flag f, giving the prompt ‘Select discretes’:
Oasys.PRIMER.Discrete.Select(f, 'Select discretes', m)To select discretes, flagging those selected with flag f but limiting selection to discretes flagged with flag l, giving the prompt ‘Select discretes’:
Oasys.PRIMER.Discrete.Select(f, 'Select discretes', l)
- classmethod Discrete.SketchFlagged(model, flag, redraw=Oasys.gRPC.defaultArg)¶
Sketches 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
- Parameters:
model (Model) –
Model
that all the flagged discretes will be sketched inflag (Flag) – Flag set on the discretes that you want to sketch
redraw (boolean) – Optional. 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()
- Returns:
No return value
- Return type:
None
Example
To sketch all discretes flagged with flag in model m:
Oasys.PRIMER.Discrete.SketchFlagged(m, flag)
- classmethod Discrete.Total(model, exists=Oasys.gRPC.defaultArg)¶
Returns the total number of discretes in the model
- Parameters:
model (Model) –
Model
to get total forexists (boolean) – Optional. true if only existing discretes should be counted. If false or omitted referenced but undefined discretes will also be included in the total
- Returns:
number of discretes
- Return type:
int
Example
To get the total number of discretes in model m:
total = Oasys.PRIMER.Discrete.Total(m)
- classmethod Discrete.UnblankAll(model, redraw=Oasys.gRPC.defaultArg)¶
Unblanks all of the discretes in the model
- Parameters:
model (Model) –
Model
that all discretes will be unblanked inredraw (boolean) – Optional. 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()
- Returns:
No return value
- Return type:
None
Example
To unblank all of the discretes in model m:
Oasys.PRIMER.Discrete.UnblankAll(m)
- classmethod Discrete.UnblankFlagged(model, flag, redraw=Oasys.gRPC.defaultArg)¶
Unblanks all of the flagged discretes in the model
- Parameters:
model (Model) –
Model
that the flagged discretes will be unblanked inflag (Flag) – Flag set on the discretes that you want to unblank
redraw (boolean) – Optional. 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()
- Returns:
No return value
- Return type:
None
Example
To unblank all of the discretes in model m flagged with f:
Oasys.PRIMER.Discrete.UnblankFlagged(m, f)
- classmethod Discrete.UnflagAll(model, flag)¶
Unsets a defined flag on all of the discretes in the model
- Parameters:
model (Model) –
Model
that the defined flag for all discretes will be unset inflag (Flag) – Flag to unset on the discretes
- Returns:
No return value
- Return type:
None
Example
To unset the flag f on all the discretes in model m:
Oasys.PRIMER.Discrete.UnflagAll(m, f)
- classmethod Discrete.UnsketchAll(model, redraw=Oasys.gRPC.defaultArg)¶
Unsketches all discretes
- Parameters:
model (Model) –
Model
that all discretes will be unblanked inredraw (boolean) – Optional. 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()
- Returns:
No return value
- Return type:
None
Example
To unsketch all discretes in model m:
Oasys.PRIMER.Discrete.UnsketchAll(m)
- classmethod Discrete.UnsketchFlagged(model, flag, redraw=Oasys.gRPC.defaultArg)¶
Unsketches all flagged discretes in the model
- Parameters:
model (Model) –
Model
that all discretes will be unsketched inflag (Flag) – Flag set on the discretes that you want to unsketch
redraw (boolean) – Optional. 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()
- Returns:
No return value
- Return type:
None
Example
To unsketch all discretes flagged with flag in model m:
Oasys.PRIMER.Discrete.UnsketchAll(m, flag)
Instance methods¶
- Discrete.AssociateComment(comment)¶
Associates a comment with a discrete
- Parameters:
comment (Comment) –
Comment
that will be attached to the discrete- Returns:
No return value
- Return type:
None
Example
To associate comment c to the discrete d:
d.AssociateComment(c)
- Discrete.Blank()¶
Blanks the discrete
- Returns:
No return value
- Return type:
None
Example
To blank discrete d:
d.Blank()
- Discrete.Blanked()¶
Checks if the discrete is blanked or not
- Returns:
True if blanked, False if not
- Return type:
bool
Example
To check if discrete d is blanked:
if d.Blanked(): do_something..
- Discrete.Browse(modal=Oasys.gRPC.defaultArg)¶
Starts an edit panel in Browse mode
- Parameters:
modal (boolean) – Optional. 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
- Returns:
no return value
- Return type:
None
Example
To Browse discrete d:
d.Browse()
- Discrete.ClearFlag(flag)¶
Clears a flag on the discrete
- Parameters:
flag (Flag) – Flag to clear on the discrete
- Returns:
No return value
- Return type:
None
Example
To clear flag f for discrete d:
d.ClearFlag(f)
- Discrete.Copy(range=Oasys.gRPC.defaultArg)¶
Copies the discrete. The target include of the copied discrete can be set using
Options.copy_target_include
- Parameters:
range (boolean) – Optional. 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()
- Returns:
Discrete object
- Return type:
Discrete
Example
To copy discrete d into discrete z:
z = d.Copy()
- Discrete.DetachComment(comment)¶
Detaches a comment from a discrete
- Parameters:
comment (Comment) –
Comment
that will be detached from the discrete- Returns:
No return value
- Return type:
None
Example
To detach comment c from the discrete d:
d.DetachComment(c)
- Discrete.Edit(modal=Oasys.gRPC.defaultArg)¶
Starts an interactive editing panel
- Parameters:
modal (boolean) – Optional. 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
- Returns:
no return value
- Return type:
None
Example
To Edit discrete d:
d.Edit()
- Discrete.ExtractColour()¶
Extracts the actual colour used for discrete.
By default in PRIMER many entities such as elements get their colour automatically from the part that they are in. PRIMER cycles through 13 default colours based on the label of the entity. In this case the discretecolour
property will return the valueColour.PART
instead of the actual colour. This method will return the actual colour which is used for drawing the discrete
- Returns:
colour value (integer)
- Return type:
int
Example
To return the colour used for drawing discrete d:
colour = d.ExtractColour()
- Discrete.Flagged(flag)¶
Checks if the discrete is flagged or not
- Parameters:
flag (Flag) – Flag to test on the discrete
- Returns:
True if flagged, False if not
- Return type:
bool
Example
To check if discrete d has flag f set on it:
if d.Flagged(f): do_something..
- Discrete.GetComments()¶
Extracts the comments associated to a discrete
- Returns:
List of Comment objects (or None if there are no comments associated to the node)
- Return type:
list
Example
To get the list of comments associated to the discrete d:
comm_list = d.GetComments()
- Discrete.GetParameter(prop)¶
Checks 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 theDiscrete.ViewParameters()
method and ‘method chaining’ (see the examples below)
- Parameters:
prop (string) – discrete property to get parameter for
- Returns:
Parameter object if property is a parameter, None if not
- Return type:
dict
Example
To check if Discrete property d.example is a parameter:
Oasys.PRIMER.Options.property_parameter_names = True if d.GetParameter(d.example): do_something... Oasys.PRIMER.Options.property_parameter_names = FalseTo check if Discrete property d.example is a parameter by using the GetParameter method:
if d.ViewParameters().GetParameter(d.example): do_something..
- Discrete.Keyword()¶
Returns the keyword for this discrete (*ELEMENT_DISCRETE). Note that a carriage return is not added. See also
Discrete.KeywordCards()
- Returns:
string containing the keyword
- Return type:
str
Example
To get the keyword for discrete m:
key = m.Keyword()
- Discrete.KeywordCards()¶
Returns the keyword cards for the discrete. Note that a carriage return is not added. See also
Discrete.Keyword()
- Returns:
string containing the cards
- Return type:
str
Example
To get the cards for discrete d:
cards = d.KeywordCards()
- Discrete.Next()¶
Returns the next discrete in the model
- Returns:
Discrete object (or None if there are no more discretes in the model)
- Return type:
Discrete
Example
To get the discrete in model m after discrete d:
d = d.Next()
- Discrete.Previous()¶
Returns the previous discrete in the model
- Returns:
Discrete object (or None if there are no more discretes in the model)
- Return type:
Discrete
Example
To get the discrete in model m before discrete d:
d = d.Previous()
- Discrete.SetFlag(flag)¶
Sets a flag on the discrete
- Parameters:
flag (Flag) – Flag to set on the discrete
- Returns:
No return value
- Return type:
None
Example
To set flag f for discrete d:
d.SetFlag(f)
- Discrete.Sketch(redraw=Oasys.gRPC.defaultArg)¶
Sketches the discrete. The discrete will be sketched until you either call
Discrete.Unsketch()
,Discrete.UnsketchAll()
,Model.UnsketchAll()
, or delete the model
- Parameters:
redraw (boolean) – Optional. 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()
- Returns:
No return value
- Return type:
None
Example
To sketch discrete d:
d.Sketch()
- Discrete.Timestep()¶
Calculates the timestep for the discrete
- Returns:
float
- Return type:
float
Example
To calculate the timestep for discrete d:
timestep = d.Timestep()
- Discrete.Unblank()¶
Unblanks the discrete
- Returns:
No return value
- Return type:
None
Example
To unblank discrete d:
d.Unblank()
- Discrete.Unsketch(redraw=Oasys.gRPC.defaultArg)¶
Unsketches the discrete
- Parameters:
redraw (boolean) – Optional. 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()
- Returns:
No return value
- Return type:
None
Example
To unsketch discrete d:
d.Unsketch()
- Discrete.ViewParameters()¶
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. This function temporarily changes the behaviour so that if a property is a parameter the parameter name is returned instead. This can be used with ‘method chaining’ (see the example below) to make sure a property argument is correct
- Returns:
Discrete object
- Return type:
dict
Example
To check if Discrete property d.example is a parameter by using the
Discrete.GetParameter()
method:if d.ViewParameters().GetParameter(d.example): do_something..
- Discrete.Xrefs()¶
Returns the cross references for this discrete
- Returns:
Xrefs object
- Return type:
dict
Example
To get the cross references for discrete d:
xrefs = d.Xrefs()