Oasys.PRIMER.Mass class

Constants

Mass.NODE_SET

Mass is *MASS_NODE_SET

Properties

property Mass.colour: Colour

The colour of the mass

property Mass.eid: integer

Mass number. Also see the label property which is an alternative name for this

property Mass.exists(read only): boolean

true if mass exists, false if referred to but not defined

property Mass.id: integer

Node id or node set id

property Mass.include: integer

The Include file number that the mass is in

property Mass.label: integer

Mass number. Also see the eid property which is an alternative name for this

property Mass.mass: float

Mass value

property Mass.model(read only): integer

The Model number that the mass is in

property Mass.node_set: integer

The type of the mass. Can be false (*MASS) or Mass.NODE_SET (*MASS_NODE_SET)

property Mass.pid: integer

Part ID

property Mass.transparency: integer

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

Constructor

classmethod Mass(model, eid, id, mass, node_set=Oasys.gRPC.defaultArg)

Create a new Mass object

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

  • eid (integer) – Mass number

  • id (integer) – Node id or node set id

  • mass (float) – Mass value

  • node_set (integer) – Optional. Only used if a node set is used

Returns:

Mass object

Return type:

dict

Example

To create a new mass in model m with label 200, on node 500, or node set 500, with a mass of 3.5, use one of the following:

m = Oasys.PRIMER.Mass(m, 200, 500, 3.5)
m = Oasys.PRIMER.Mass(m, 200, 500, 3.5, Oasys.PRIMER.Mass.NODE_SET)

Static methods

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

Blanks all of the masss in the model

Parameters:
  • model (Model) – Model that all masss 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 masss in model m:

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

Blanks all of the flagged masss in the model

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

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

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

Starts an interactive editing panel to create a mass

Parameters:
  • model (Model) – Model that the mass 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:

Mass object (or None if not made)

Return type:

dict

Example

To start creating a mass in model m:

m = Oasys.PRIMER.Mass.Create(m)
classmethod Mass.First(model)

Returns the first mass in the model

Parameters:

model (Model) – Model to get first mass in

Returns:

Mass object (or None if there are no masss in the model)

Return type:

Mass

Example

To get the first mass in model m:

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

Returns the first free mass label in the model. Also see Mass.LastFreeLabel(), Mass.NextFreeLabel() and Model.FirstFreeItemLabel()

Parameters:
  • model (Model) – Model to get first free mass 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:

Mass label

Return type:

int

Example

To get the first free mass label in model m:

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

Flags all of the masss in the model with a defined flag

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

  • flag (Flag) – Flag to set on the masss

Returns:

No return value

Return type:

None

Example

To flag all of the masss with flag f in model m:

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

Returns a list of Mass objects for all of the masss in a model in PRIMER

Parameters:

model (Model) – Model to get masss from

Returns:

List of Mass objects

Return type:

list

Example

To make a list of Mass objects for all of the masss in model m

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

Returns a list of Mass objects for all of the flagged masss in a model in PRIMER

Parameters:
  • model (Model) – Model to get masss from

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

Returns:

List of Mass objects

Return type:

list

Example

To make a list of Mass objects for all of the masss in model m flagged with f

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

Returns the Mass object for a mass ID

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

  • number (integer) – number of the mass you want the Mass object for

Returns:

Mass object (or None if mass does not exist)

Return type:

Mass

Example

To get the Mass object for mass 100 in model m

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

Returns the last mass in the model

Parameters:

model (Model) – Model to get last mass in

Returns:

Mass object (or None if there are no masss in the model)

Return type:

Mass

Example

To get the last mass in model m:

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

Returns the last free mass label in the model. Also see Mass.FirstFreeLabel(), Mass.NextFreeLabel() and see Model.LastFreeItemLabel()

Parameters:
  • model (Model) – Model to get last free mass 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:

Mass label

Return type:

int

Example

To get the last free mass label in model m:

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

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

Parameters:
  • model (Model) – Model to get next free mass 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:

Mass label

Return type:

int

Example

To get the next free mass label in model m:

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

Allows the user to pick a mass

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 masss from that model can be picked. If the argument is a Flag then only masss that are flagged with limit can be selected. If omitted, or None, any masss 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:

Mass object (or None if not picked)

Return type:

dict

Example

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

m = Oasys.PRIMER.Mass.Pick('Pick mass from screen', m)
classmethod Mass.RenumberAll(model, start)

Renumbers all of the masss in the model

Parameters:
  • model (Model) – Model that all masss will be renumbered in

  • start (integer) – Start point for renumbering

Returns:

No return value

Return type:

None

Example

To renumber all of the masss in model m, from 1000000:

Oasys.PRIMER.Mass.RenumberAll(m, 1000000)
classmethod Mass.RenumberFlagged(model, flag, start)

Renumbers all of the flagged masss in the model

Parameters:
  • model (Model) – Model that all the flagged masss will be renumbered in

  • flag (Flag) – Flag set on the masss that you want to renumber

  • start (integer) – Start point for renumbering

Returns:

No return value

Return type:

None

Example

To renumber all of the masss in model m flagged with f, from 1000000:

Oasys.PRIMER.Mass.RenumberFlagged(m, f, 1000000)
classmethod Mass.Select(flag, prompt, limit=Oasys.gRPC.defaultArg, modal=Oasys.gRPC.defaultArg)

Allows the user to select masss using standard PRIMER object menus

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

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

  • limit (Model or Flag) – Optional. If the argument is a Model then only masss from that model can be selected. If the argument is a Flag then only masss that are flagged with limit can be selected (limit should be different to flag). If omitted, or None, any masss 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 masss selected or None if menu cancelled

Return type:

int

Example

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

Oasys.PRIMER.Mass.Select(f, 'Select masss', m)

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

Oasys.PRIMER.Mass.Select(f, 'Select masss', l)
classmethod Mass.SketchFlagged(model, flag, redraw=Oasys.gRPC.defaultArg)

Sketches all of the flagged masss in the model. The masss will be sketched until you either call Mass.Unsketch(), Mass.UnsketchFlagged(), Model.UnsketchAll(), or delete the model

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

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

  • redraw (boolean) – Optional. If model should be redrawn or not after the masss are sketched. If omitted redraw is true. If you want to sketch flagged masss 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 masss flagged with flag in model m:

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

Returns the total number of masss in the model

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

  • exists (boolean) – Optional. true if only existing masss should be counted. If false or omitted referenced but undefined masss will also be included in the total

Returns:

number of masss

Return type:

int

Example

To get the total number of masss in model m:

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

Unblanks all of the masss in the model

Parameters:
  • model (Model) – Model that all masss 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 masss in model m:

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

Unblanks all of the flagged masss in the model

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

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

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

Unsets a defined flag on all of the masss in the model

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

  • flag (Flag) – Flag to unset on the masss

Returns:

No return value

Return type:

None

Example

To unset the flag f on all the masss in model m:

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

Unsketches all masss

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

  • redraw (boolean) – Optional. If model should be redrawn or not after the masss 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 masss in model m:

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

Unsketches all flagged masss in the model

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

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

  • redraw (boolean) – Optional. If model should be redrawn or not after the masss 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 masss flagged with flag in model m:

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

Instance methods

Mass.AssociateComment(comment)

Associates a comment with a mass

Parameters:

comment (Comment) – Comment that will be attached to the mass

Returns:

No return value

Return type:

None

Example

To associate comment c to the mass m:

m.AssociateComment(c)
Mass.Blank()

Blanks the mass

Returns:

No return value

Return type:

None

Example

To blank mass m:

m.Blank()
Mass.Blanked()

Checks if the mass is blanked or not

Returns:

True if blanked, False if not

Return type:

bool

Example

To check if mass m is blanked:

if m.Blanked():
    do_something..
Mass.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 mass m:

m.Browse()
Mass.ClearFlag(flag)

Clears a flag on the mass

Parameters:

flag (Flag) – Flag to clear on the mass

Returns:

No return value

Return type:

None

Example

To clear flag f for mass m:

m.ClearFlag(f)
Mass.Copy(range=Oasys.gRPC.defaultArg)

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

Mass object

Return type:

Mass

Example

To copy mass m into mass z:

z = m.Copy()
Mass.DetachComment(comment)

Detaches a comment from a mass

Parameters:

comment (Comment) – Comment that will be detached from the mass

Returns:

No return value

Return type:

None

Example

To detach comment c from the mass m:

m.DetachComment(c)
Mass.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 mass m:

m.Edit()
Mass.ExtractColour()

Extracts the actual colour used for mass.
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 mass 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 mass

Returns:

colour value (integer)

Return type:

int

Example

To return the colour used for drawing mass m:

colour = m.ExtractColour()
Mass.Flagged(flag)

Checks if the mass is flagged or not

Parameters:

flag (Flag) – Flag to test on the mass

Returns:

True if flagged, False if not

Return type:

bool

Example

To check if mass m has flag f set on it:

if m.Flagged(f):
    do_something..
Mass.GetComments()

Extracts the comments associated to a mass

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 mass m:

comm_list = m.GetComments()
Mass.GetParameter(prop)

Checks if a Mass 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 Mass.ViewParameters() method and ‘method chaining’ (see the examples below)

Parameters:

prop (string) – mass property to get parameter for

Returns:

Parameter object if property is a parameter, None if not

Return type:

dict

Example

To check if Mass property m.example is a parameter:

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

To check if Mass property m.example is a parameter by using the GetParameter method:

if m.ViewParameters().GetParameter(m.example):
    do_something..
Mass.Keyword()

Returns the keyword for this mass (*ELEMENT_MASS or *ELEMENT_MASS_NODE_SET). Note that a carriage return is not added. See also Mass.KeywordCards()

Returns:

string containing the keyword

Return type:

str

Example

To get the keyword for mass m:

key = m.Keyword()
Mass.KeywordCards()

Returns the keyword cards for the mass. Note that a carriage return is not added. See also Mass.Keyword()

Returns:

string containing the cards

Return type:

str

Example

To get the cards for mass m:

cards = m.KeywordCards()
Mass.Next()

Returns the next mass in the model

Returns:

Mass object (or None if there are no more masss in the model)

Return type:

Mass

Example

To get the mass in model m after mass m:

m = m.Next()
Mass.Previous()

Returns the previous mass in the model

Returns:

Mass object (or None if there are no more masss in the model)

Return type:

Mass

Example

To get the mass in model m before mass m:

m = m.Previous()
Mass.SetFlag(flag)

Sets a flag on the mass

Parameters:

flag (Flag) – Flag to set on the mass

Returns:

No return value

Return type:

None

Example

To set flag f for mass m:

m.SetFlag(f)
Mass.Sketch(redraw=Oasys.gRPC.defaultArg)

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

Parameters:

redraw (boolean) – Optional. If model should be redrawn or not after the mass is sketched. If omitted redraw is true. If you want to sketch several masss 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 mass m:

m.Sketch()
Mass.Unblank()

Unblanks the mass

Returns:

No return value

Return type:

None

Example

To unblank mass m:

m.Unblank()
Mass.Unsketch(redraw=Oasys.gRPC.defaultArg)

Unsketches the mass

Parameters:

redraw (boolean) – Optional. If model should be redrawn or not after the mass is unsketched. If omitted redraw is true. If you want to unsketch several masss 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 mass m:

m.Unsketch()
Mass.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:

Mass object

Return type:

dict

Example

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

if m.ViewParameters().GetParameter(m.example):
    do_something..
Mass.Xrefs()

Returns the cross references for this mass

Returns:

Xrefs object

Return type:

dict

Example

To get the cross references for mass m:

xrefs = m.Xrefs()