Oasys.PRIMER.DiscreteSphere class

Properties

property DiscreteSphere.colour: Colour

The colour of the discrete sphere

property DiscreteSphere.exists(read only): boolean

true if discrete sphere exists, false if referred to but not defined

property DiscreteSphere.include: integer

The Include file number that the discrete sphere is in

property DiscreteSphere.inertia: float

Mass moment of inertia

property DiscreteSphere.mass: float

Mass or volume value (depending on whether the _VOLUME option is set)

property DiscreteSphere.model(read only): integer

The Model number that the discrete sphere is in

property DiscreteSphere.nid: integer

Node ID

property DiscreteSphere.pid: integer

Part ID to which this element belongs

property DiscreteSphere.radius: float

Particle radius

property DiscreteSphere.transparency: integer

The transparency of the discrete sphere (0-100) 0% is opaque, 100% is transparent

property DiscreteSphere.volume: boolean

Turns _VOLUME on or OFF. Note that this does NOT refer to the data field VOLUME. For the latter see the mass property

Constructor

classmethod DiscreteSphere(model, nid, pid, mass, inertia, radius)

Create a new DiscreteSphere object

Parameters:
  • model (Model) – Model that discrete sphere will be created in

  • nid (integer) – Node ID and Element ID are the same for discrete spheres

  • pid (integer) – Part ID to which this element belongs

  • mass (real) – Mass or volume value

  • inertia (real) – Mass moment of inertia

  • radius (real) – Particle radius

Returns:

DiscreteSphere object

Return type:

dict

Example

To create a new discrete sphere in model m with nid = 100, pid = 400, mass = 0.9, inertia = 2.5, radius = 2.0:

dsph = Oasys.PRIMER.DiscreteSphere(m, 100, 400, 0.9, 2.5, 2.0)

Static methods

classmethod DiscreteSphere.BlankAll(model, redraw=Oasys.gRPC.defaultArg)

Blanks all of the discrete spheres in the model

Parameters:
  • model (Model) – Model that all discrete spheres will be blanked in

  • 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 discrete spheres in model m:

Oasys.PRIMER.DiscreteSphere.BlankAll(m)
classmethod DiscreteSphere.BlankFlagged(model, flag, redraw=Oasys.gRPC.defaultArg)

Blanks all of the flagged discrete spheres in the model

Parameters:
  • model (Model) – Model that all the flagged discrete spheres will be blanked in

  • flag (Flag) – Flag set on the discrete spheres 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 discrete spheres in model m flagged with f:

Oasys.PRIMER.DiscreteSphere.BlankFlagged(m, f)
classmethod DiscreteSphere.Create(model, modal=Oasys.gRPC.defaultArg)

Starts an interactive editing panel to create a discrete sphere

Parameters:
  • model (Model) – Model that the discrete sphere will be created in

  • 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:

DiscreteSphere object (or None if not made)

Return type:

dict

Example

To start creating a discrete sphere in model m:

dsph = Oasys.PRIMER.DiscreteSphere.Create(m)
classmethod DiscreteSphere.First(model)

Returns the first discrete sphere in the model

Parameters:

model (Model) – Model to get first discrete sphere in

Returns:

DiscreteSphere object (or None if there are no discrete spheres in the model)

Return type:

DiscreteSphere

Example

To get the first discrete sphere in model m:

dsph = Oasys.PRIMER.DiscreteSphere.First(m)
classmethod DiscreteSphere.FirstFreeLabel(model, layer=Oasys.gRPC.defaultArg)

Returns the first free discrete sphere label in the model. Also see DiscreteSphere.LastFreeLabel(), DiscreteSphere.NextFreeLabel() and Model.FirstFreeItemLabel()

Parameters:
  • model (Model) – Model to get first free discrete sphere label in

  • layer (Include number) – Optional. 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)

Returns:

DiscreteSphere label

Return type:

int

Example

To get the first free discrete sphere label in model m:

label = Oasys.PRIMER.DiscreteSphere.FirstFreeLabel(m)
classmethod DiscreteSphere.FlagAll(model, flag)

Flags all of the discrete spheres in the model with a defined flag

Parameters:
  • model (Model) – Model that all discrete spheres will be flagged in

  • flag (Flag) – Flag to set on the discrete spheres

Returns:

No return value

Return type:

None

Example

To flag all of the discrete spheres with flag f in model m:

Oasys.PRIMER.DiscreteSphere.FlagAll(m, f)
classmethod DiscreteSphere.GetAll(model)

Returns a list of DiscreteSphere objects for all of the discrete spheres in a model in PRIMER

Parameters:

model (Model) – Model to get discrete spheres from

Returns:

List of DiscreteSphere objects

Return type:

list

Example

To make a list of DiscreteSphere objects for all of the discrete spheres in model m

dsph = Oasys.PRIMER.DiscreteSphere.GetAll(m)
classmethod DiscreteSphere.GetFlagged(model, flag)

Returns a list of DiscreteSphere objects for all of the flagged discrete spheres in a model in PRIMER

Parameters:
  • model (Model) – Model to get discrete spheres from

  • flag (Flag) – Flag set on the discrete spheres that you want to retrieve

Returns:

List of DiscreteSphere objects

Return type:

list

Example

To make a list of DiscreteSphere objects for all of the discrete spheres in model m flagged with f

dsph = Oasys.PRIMER.DiscreteSphere.GetFlagged(m, f)
classmethod DiscreteSphere.GetFromID(model, number)

Returns the DiscreteSphere object for a discrete sphere ID

Parameters:
  • model (Model) – Model to find the discrete sphere in

  • number (integer) – number of the discrete sphere you want the DiscreteSphere object for

Returns:

DiscreteSphere object (or None if discrete sphere does not exist)

Return type:

DiscreteSphere

Example

To get the DiscreteSphere object for discrete sphere 100 in model m

dsph = Oasys.PRIMER.DiscreteSphere.GetFromID(m, 100)
classmethod DiscreteSphere.Last(model)

Returns the last discrete sphere in the model

Parameters:

model (Model) – Model to get last discrete sphere in

Returns:

DiscreteSphere object (or None if there are no discrete spheres in the model)

Return type:

DiscreteSphere

Example

To get the last discrete sphere in model m:

dsph = Oasys.PRIMER.DiscreteSphere.Last(m)
classmethod DiscreteSphere.LastFreeLabel(model, layer=Oasys.gRPC.defaultArg)

Returns the last free discrete sphere label in the model. Also see DiscreteSphere.FirstFreeLabel(), DiscreteSphere.NextFreeLabel() and see Model.LastFreeItemLabel()

Parameters:
  • model (Model) – Model to get last free discrete sphere label in

  • layer (Include number) – Optional. 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

Returns:

DiscreteSphere label

Return type:

int

Example

To get the last free discrete sphere label in model m:

label = Oasys.PRIMER.DiscreteSphere.LastFreeLabel(m)
classmethod DiscreteSphere.NextFreeLabel(model, layer=Oasys.gRPC.defaultArg)

Returns the next free (highest+1) discrete sphere label in the model. Also see DiscreteSphere.FirstFreeLabel(), DiscreteSphere.LastFreeLabel() and Model.NextFreeItemLabel()

Parameters:
  • model (Model) – Model to get next free discrete sphere label in

  • layer (Include number) – Optional. 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)

Returns:

DiscreteSphere label

Return type:

int

Example

To get the next free discrete sphere label in model m:

label = Oasys.PRIMER.DiscreteSphere.NextFreeLabel(m)
classmethod DiscreteSphere.Pick(prompt, limit=Oasys.gRPC.defaultArg, modal=Oasys.gRPC.defaultArg, button_text=Oasys.gRPC.defaultArg)

Allows the user to pick a discrete sphere

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 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 None, any discrete spheres from any model can be selected. from any model

  • modal (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:

DiscreteSphere object (or None if not picked)

Return type:

dict

Example

To pick a discrete sphere from model m giving the prompt ‘Pick discrete sphere from screen’:

dsph = Oasys.PRIMER.DiscreteSphere.Pick('Pick discrete sphere from screen', m)
classmethod DiscreteSphere.Select(flag, prompt, limit=Oasys.gRPC.defaultArg, modal=Oasys.gRPC.defaultArg)

Allows the user to select discrete spheres using standard PRIMER object menus

Parameters:
  • flag (Flag) – Flag to use when selecting discrete spheres

  • prompt (string) – Text to display as a prompt to the user

  • limit (Model or Flag) – Optional. 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 None, any discrete spheres can be selected. from any model

  • modal (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 discrete spheres selected or None if menu cancelled

Return type:

int

Example

To select discrete spheres from model m, flagging those selected with flag f, giving the prompt ‘Select discrete spheres’:

Oasys.PRIMER.DiscreteSphere.Select(f, 'Select discrete spheres', m)

To select discrete spheres, flagging those selected with flag f but limiting selection to discrete spheres flagged with flag l, giving the prompt ‘Select discrete spheres’:

Oasys.PRIMER.DiscreteSphere.Select(f, 'Select discrete spheres', l)
classmethod DiscreteSphere.SketchFlagged(model, flag, redraw=Oasys.gRPC.defaultArg)

Sketches 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

Parameters:
  • model (Model) – Model that all the flagged discrete spheres will be sketched in

  • flag (Flag) – Flag set on the discrete spheres that you want to sketch

  • redraw (boolean) – Optional. 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()

Returns:

No return value

Return type:

None

Example

To sketch all discrete spheres flagged with flag in model m:

Oasys.PRIMER.DiscreteSphere.SketchFlagged(m, flag)
classmethod DiscreteSphere.Total(model, exists=Oasys.gRPC.defaultArg)

Returns the total number of discrete spheres in the model

Parameters:
  • model (Model) – Model to get total for

  • exists (boolean) – Optional. 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

Returns:

number of discrete spheres

Return type:

int

Example

To get the total number of discrete spheres in model m:

total = Oasys.PRIMER.DiscreteSphere.Total(m)
classmethod DiscreteSphere.UnblankAll(model, redraw=Oasys.gRPC.defaultArg)

Unblanks all of the discrete spheres in the model

Parameters:
  • model (Model) – Model that all discrete spheres will be unblanked in

  • 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 discrete spheres in model m:

Oasys.PRIMER.DiscreteSphere.UnblankAll(m)
classmethod DiscreteSphere.UnblankFlagged(model, flag, redraw=Oasys.gRPC.defaultArg)

Unblanks all of the flagged discrete spheres in the model

Parameters:
  • model (Model) – Model that the flagged discrete spheres will be unblanked in

  • flag (Flag) – Flag set on the discrete spheres 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 discrete spheres in model m flagged with f:

Oasys.PRIMER.DiscreteSphere.UnblankFlagged(m, f)
classmethod DiscreteSphere.UnflagAll(model, flag)

Unsets a defined flag on all of the discrete spheres in the model

Parameters:
  • model (Model) – Model that the defined flag for all discrete spheres will be unset in

  • flag (Flag) – Flag to unset on the discrete spheres

Returns:

No return value

Return type:

None

Example

To unset the flag f on all the discrete spheres in model m:

Oasys.PRIMER.DiscreteSphere.UnflagAll(m, f)
classmethod DiscreteSphere.UnsketchAll(model, redraw=Oasys.gRPC.defaultArg)

Unsketches all discrete spheres

Parameters:
  • model (Model) – Model that all discrete spheres will be unblanked in

  • redraw (boolean) – Optional. 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()

Returns:

No return value

Return type:

None

Example

To unsketch all discrete spheres in model m:

Oasys.PRIMER.DiscreteSphere.UnsketchAll(m)
classmethod DiscreteSphere.UnsketchFlagged(model, flag, redraw=Oasys.gRPC.defaultArg)

Unsketches all flagged discrete spheres in the model

Parameters:
  • model (Model) – Model that all discrete spheres will be unsketched in

  • flag (Flag) – Flag set on the discrete spheres that you want to unsketch

  • redraw (boolean) – Optional. 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()

Returns:

No return value

Return type:

None

Example

To unsketch all discrete spheres flagged with flag in model m:

Oasys.PRIMER.DiscreteSphere.UnsketchAll(m, flag)

Instance methods

DiscreteSphere.AssociateComment(comment)

Associates a comment with a discrete sphere

Parameters:

comment (Comment) – Comment that will be attached to the discrete sphere

Returns:

No return value

Return type:

None

Example

To associate comment c to the discrete sphere dsph:

dsph.AssociateComment(c)
DiscreteSphere.Blank()

Blanks the discrete sphere

Returns:

No return value

Return type:

None

Example

To blank discrete sphere dsph:

dsph.Blank()
DiscreteSphere.Blanked()

Checks if the discrete sphere is blanked or not

Returns:

True if blanked, False if not

Return type:

bool

Example

To check if discrete sphere dsph is blanked:

if dsph.Blanked():
    do_something..
DiscreteSphere.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 sphere dsph:

dsph.Browse()
DiscreteSphere.ClearFlag(flag)

Clears a flag on the discrete sphere

Parameters:

flag (Flag) – Flag to clear on the discrete sphere

Returns:

No return value

Return type:

None

Example

To clear flag f for discrete sphere dsph:

dsph.ClearFlag(f)
DiscreteSphere.Copy(range=Oasys.gRPC.defaultArg)

Copies the discrete sphere. The target include of the copied discrete sphere 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:

DiscreteSphere object

Return type:

DiscreteSphere

Example

To copy discrete sphere dsph into discrete sphere z:

z = dsph.Copy()
DiscreteSphere.DetachComment(comment)

Detaches a comment from a discrete sphere

Parameters:

comment (Comment) – Comment that will be detached from the discrete sphere

Returns:

No return value

Return type:

None

Example

To detach comment c from the discrete sphere dsph:

dsph.DetachComment(c)
DiscreteSphere.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 sphere dsph:

dsph.Edit()
DiscreteSphere.ExtractColour()

Extracts the actual colour used for discrete sphere.
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 discrete sphere colour property will return the value Colour.PART instead of the actual colour. This method will return the actual colour which is used for drawing the discrete sphere

Returns:

colour value (integer)

Return type:

int

Example

To return the colour used for drawing discrete sphere dsph:

colour = dsph.ExtractColour()
DiscreteSphere.Flagged(flag)

Checks if the discrete sphere is flagged or not

Parameters:

flag (Flag) – Flag to test on the discrete sphere

Returns:

True if flagged, False if not

Return type:

bool

Example

To check if discrete sphere dsph has flag f set on it:

if dsph.Flagged(f):
    do_something..
DiscreteSphere.GetComments()

Extracts the comments associated to a discrete sphere

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 sphere dsph:

comm_list = dsph.GetComments()
DiscreteSphere.GetParameter(prop)

Checks 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)

Parameters:

prop (string) – discrete sphere property to get parameter for

Returns:

Parameter object if property is a parameter, None if not

Return type:

dict

Example

To check if DiscreteSphere property dsph.example is a parameter:

Oasys.PRIMER.Options.property_parameter_names = True
if dsph.GetParameter(dsph.example):
    do_something...
Oasys.PRIMER.Options.property_parameter_names = False

To check if DiscreteSphere property dsph.example is a parameter by using the GetParameter method:

if dsph.ViewParameters().GetParameter(dsph.example):
    do_something..
DiscreteSphere.Keyword()

Returns 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()

Returns:

string containing the keyword

Return type:

str

Example

To get the keyword for discrete sphere dsph:

key = dsph.Keyword()
DiscreteSphere.KeywordCards()

Returns the keyword cards for the discrete sphere. Note that a carriage return is not added. See also DiscreteSphere.Keyword()

Returns:

string containing the cards

Return type:

str

Example

To get the cards for discrete sphere dsph:

cards = dsph.KeywordCards()
DiscreteSphere.Next()

Returns the next discrete sphere in the model

Returns:

DiscreteSphere object (or None if there are no more discrete spheres in the model)

Return type:

DiscreteSphere

Example

To get the discrete sphere in model m after discrete sphere dsph:

dsph = dsph.Next()
DiscreteSphere.Previous()

Returns the previous discrete sphere in the model

Returns:

DiscreteSphere object (or None if there are no more discrete spheres in the model)

Return type:

DiscreteSphere

Example

To get the discrete sphere in model m before discrete sphere dsph:

dsph = dsph.Previous()
DiscreteSphere.SetFlag(flag)

Sets a flag on the discrete sphere

Parameters:

flag (Flag) – Flag to set on the discrete sphere

Returns:

No return value

Return type:

None

Example

To set flag f for discrete sphere dsph:

dsph.SetFlag(f)
DiscreteSphere.Sketch(redraw=Oasys.gRPC.defaultArg)

Sketches the discrete sphere. The discrete sphere will be sketched until you either call DiscreteSphere.Unsketch(), DiscreteSphere.UnsketchAll(), Model.UnsketchAll(), or delete the model

Parameters:

redraw (boolean) – Optional. 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()

Returns:

No return value

Return type:

None

Example

To sketch discrete sphere dsph:

dsph.Sketch()
DiscreteSphere.Unblank()

Unblanks the discrete sphere

Returns:

No return value

Return type:

None

Example

To unblank discrete sphere dsph:

dsph.Unblank()
DiscreteSphere.Unsketch(redraw=Oasys.gRPC.defaultArg)

Unsketches the discrete sphere

Parameters:

redraw (boolean) – Optional. 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()

Returns:

No return value

Return type:

None

Example

To unsketch discrete sphere dsph:

dsph.Unsketch()
DiscreteSphere.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:

DiscreteSphere object

Return type:

dict

Example

To check if DiscreteSphere property dsph.example is a parameter by using the DiscreteSphere.GetParameter() method:

if dsph.ViewParameters().GetParameter(dsph.example):
    do_something..
DiscreteSphere.Xrefs()

Returns the cross references for this discrete sphere

Returns:

Xrefs object

Return type:

dict

Example

To get the cross references for discrete sphere dsph:

xrefs = dsph.Xrefs()