Oasys.PRIMER.Sph class¶
Properties¶
Constructor¶
- classmethod Sph(model, nid, pid, mass)¶
Create a new :py:class:` <Sph>` object
- Parameters:
- Returns:
Sph object
- Return type:
dict
Example
To create a new sph element in model m with nid = 100, pid = 400, mass = 0.9:
s = Oasys.PRIMER.Sph(m, 100, 400, 0.9)
Static methods¶
- classmethod Sph.BlankAll(model, redraw=Oasys.gRPC.defaultArg)¶
Blanks all of the sphs in the model
- Parameters:
model (Model) –
Model
that all sphs 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 sphs in model m:
Oasys.PRIMER.Sph.BlankAll(m)
- classmethod Sph.BlankFlagged(model, flag, redraw=Oasys.gRPC.defaultArg)¶
Blanks all of the flagged sphs in the model
- Parameters:
model (Model) –
Model
that all the flagged sphs will be blanked inflag (Flag) – Flag set on the sphs 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 sphs in model m flagged with f:
Oasys.PRIMER.Sph.BlankFlagged(m, f)
- classmethod Sph.Create(model, modal=Oasys.gRPC.defaultArg)¶
Starts an interactive editing panel to create an sph
- Parameters:
model (Model) –
Model
that the sph 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:
Sph object (or None if not made)
- Return type:
dict
Example
To start creating an sph in model m:
s = Oasys.PRIMER.Sph.Create(m)
- classmethod Sph.First(model)¶
Returns the first sph in the model
- Parameters:
model (Model) –
Model
to get first sph in- Returns:
Sph object (or None if there are no sphs in the model)
- Return type:
Sph
Example
To get the first sph in model m:
s = Oasys.PRIMER.Sph.First(m)
- classmethod Sph.FirstFreeLabel(model, layer=Oasys.gRPC.defaultArg)¶
Returns the first free sph label in the model. Also see
Sph.LastFreeLabel()
,Sph.NextFreeLabel()
andModel.FirstFreeItemLabel()
- Parameters:
- Returns:
Sph label
- Return type:
int
Example
To get the first free sph label in model m:
label = Oasys.PRIMER.Sph.FirstFreeLabel(m)
- classmethod Sph.FlagAll(model, flag)¶
Flags all of the sphs in the model with a defined flag
- Parameters:
model (Model) –
Model
that all sphs will be flagged inflag (Flag) – Flag to set on the sphs
- Returns:
No return value
- Return type:
None
Example
To flag all of the sphs with flag f in model m:
Oasys.PRIMER.Sph.FlagAll(m, f)
- classmethod Sph.GetAll(model)¶
Returns a list of Sph objects for all of the sphs in a model in PRIMER
- Parameters:
model (Model) –
Model
to get sphs from- Returns:
List of Sph objects
- Return type:
list
Example
To make a list of Sph objects for all of the sphs in model m
s = Oasys.PRIMER.Sph.GetAll(m)
- classmethod Sph.GetFlagged(model, flag)¶
Returns a list of Sph objects for all of the flagged sphs in a model in PRIMER
- Parameters:
model (Model) –
Model
to get sphs fromflag (Flag) – Flag set on the sphs that you want to retrieve
- Returns:
List of Sph objects
- Return type:
list
Example
To make a list of Sph objects for all of the sphs in model m flagged with f
s = Oasys.PRIMER.Sph.GetFlagged(m, f)
- classmethod Sph.GetFromID(model, number)¶
Returns the Sph object for a sph ID
- Parameters:
model (Model) –
Model
to find the sph innumber (integer) – number of the sph you want the Sph object for
- Returns:
Sph object (or None if sph does not exist)
- Return type:
Sph
Example
To get the Sph object for sph 100 in model m
s = Oasys.PRIMER.Sph.GetFromID(m, 100)
- classmethod Sph.Last(model)¶
Returns the last sph in the model
- Parameters:
model (Model) –
Model
to get last sph in- Returns:
Sph object (or None if there are no sphs in the model)
- Return type:
Sph
Example
To get the last sph in model m:
s = Oasys.PRIMER.Sph.Last(m)
- classmethod Sph.LastFreeLabel(model, layer=Oasys.gRPC.defaultArg)¶
Returns the last free sph label in the model. Also see
Sph.FirstFreeLabel()
,Sph.NextFreeLabel()
and seeModel.LastFreeItemLabel()
- Parameters:
- Returns:
Sph label
- Return type:
int
Example
To get the last free sph label in model m:
label = Oasys.PRIMER.Sph.LastFreeLabel(m)
- classmethod Sph.NextFreeLabel(model, layer=Oasys.gRPC.defaultArg)¶
Returns the next free (highest+1) sph label in the model. Also see
Sph.FirstFreeLabel()
,Sph.LastFreeLabel()
andModel.NextFreeItemLabel()
- Parameters:
- Returns:
Sph label
- Return type:
int
Example
To get the next free sph label in model m:
label = Oasys.PRIMER.Sph.NextFreeLabel(m)
- classmethod Sph.Pick(prompt, limit=Oasys.gRPC.defaultArg, modal=Oasys.gRPC.defaultArg, button_text=Oasys.gRPC.defaultArg)¶
Allows the user to pick a sph
- 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 sphs from that model can be picked. If the argument is aFlag
then only sphs that are flagged with limit can be selected. If omitted, or None, any sphs 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:
Sph object (or None if not picked)
- Return type:
dict
Example
To pick a sph from model m giving the prompt ‘Pick sph from screen’:
s = Oasys.PRIMER.Sph.Pick('Pick sph from screen', m)
- classmethod Sph.RenumberAll(model, start)¶
Renumbers all of the sphs in the model
- Parameters:
model (Model) –
Model
that all sphs will be renumbered instart (integer) – Start point for renumbering
- Returns:
No return value
- Return type:
None
Example
To renumber all of the sphs in model m, from 1000000:
Oasys.PRIMER.Sph.RenumberAll(m, 1000000)
- classmethod Sph.RenumberFlagged(model, flag, start)¶
Renumbers all of the flagged sphs in the model
- Parameters:
model (Model) –
Model
that all the flagged sphs will be renumbered inflag (Flag) – Flag set on the sphs that you want to renumber
start (integer) – Start point for renumbering
- Returns:
No return value
- Return type:
None
Example
To renumber all of the sphs in model m flagged with f, from 1000000:
Oasys.PRIMER.Sph.RenumberFlagged(m, f, 1000000)
- classmethod Sph.Select(flag, prompt, limit=Oasys.gRPC.defaultArg, modal=Oasys.gRPC.defaultArg)¶
Allows the user to select sphs using standard PRIMER object menus
- Parameters:
flag (Flag) – Flag to use when selecting sphs
prompt (string) – Text to display as a prompt to the user
limit (Model or Flag) – Optional. If the argument is a
Model
then only sphs from that model can be selected. If the argument is aFlag
then only sphs that are flagged with limit can be selected (limit should be different to flag). If omitted, or None, any sphs 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 sphs selected or None if menu cancelled
- Return type:
int
Example
To select sphs from model m, flagging those selected with flag f, giving the prompt ‘Select sphs’:
Oasys.PRIMER.Sph.Select(f, 'Select sphs', m)To select sphs, flagging those selected with flag f but limiting selection to sphs flagged with flag l, giving the prompt ‘Select sphs’:
Oasys.PRIMER.Sph.Select(f, 'Select sphs', l)
- classmethod Sph.SketchFlagged(model, flag, redraw=Oasys.gRPC.defaultArg)¶
Sketches all of the flagged sphs in the model. The sphs will be sketched until you either call
Sph.Unsketch()
,Sph.UnsketchFlagged()
,Model.UnsketchAll()
, or delete the model
- Parameters:
model (Model) –
Model
that all the flagged sphs will be sketched inflag (Flag) – Flag set on the sphs that you want to sketch
redraw (boolean) – Optional. If model should be redrawn or not after the sphs are sketched. If omitted redraw is true. If you want to sketch flagged sphs 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 sphs flagged with flag in model m:
Oasys.PRIMER.Sph.SketchFlagged(m, flag)
- classmethod Sph.Total(model, exists=Oasys.gRPC.defaultArg)¶
Returns the total number of sphs in the model
- Parameters:
model (Model) –
Model
to get total forexists (boolean) – Optional. true if only existing sphs should be counted. If false or omitted referenced but undefined sphs will also be included in the total
- Returns:
number of sphs
- Return type:
int
Example
To get the total number of sphs in model m:
total = Oasys.PRIMER.Sph.Total(m)
- classmethod Sph.UnblankAll(model, redraw=Oasys.gRPC.defaultArg)¶
Unblanks all of the sphs in the model
- Parameters:
model (Model) –
Model
that all sphs 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 sphs in model m:
Oasys.PRIMER.Sph.UnblankAll(m)
- classmethod Sph.UnblankFlagged(model, flag, redraw=Oasys.gRPC.defaultArg)¶
Unblanks all of the flagged sphs in the model
- Parameters:
model (Model) –
Model
that the flagged sphs will be unblanked inflag (Flag) – Flag set on the sphs 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 sphs in model m flagged with f:
Oasys.PRIMER.Sph.UnblankFlagged(m, f)
- classmethod Sph.UnflagAll(model, flag)¶
Unsets a defined flag on all of the sphs in the model
- Parameters:
model (Model) –
Model
that the defined flag for all sphs will be unset inflag (Flag) – Flag to unset on the sphs
- Returns:
No return value
- Return type:
None
Example
To unset the flag f on all the sphs in model m:
Oasys.PRIMER.Sph.UnflagAll(m, f)
- classmethod Sph.UnsketchAll(model, redraw=Oasys.gRPC.defaultArg)¶
Unsketches all sphs
- Parameters:
model (Model) –
Model
that all sphs will be unblanked inredraw (boolean) – Optional. If model should be redrawn or not after the sphs 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 sphs in model m:
Oasys.PRIMER.Sph.UnsketchAll(m)
- classmethod Sph.UnsketchFlagged(model, flag, redraw=Oasys.gRPC.defaultArg)¶
Unsketches all flagged sphs in the model
- Parameters:
model (Model) –
Model
that all sphs will be unsketched inflag (Flag) – Flag set on the sphs that you want to unsketch
redraw (boolean) – Optional. If model should be redrawn or not after the sphs 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 sphs flagged with flag in model m:
Oasys.PRIMER.Sph.UnsketchAll(m, flag)
Instance methods¶
- Sph.AssociateComment(comment)¶
Associates a comment with a sph
- Parameters:
comment (Comment) –
Comment
that will be attached to the sph- Returns:
No return value
- Return type:
None
Example
To associate comment c to the sph s:
s.AssociateComment(c)
- Sph.Blank()¶
Blanks the sph
- Returns:
No return value
- Return type:
None
Example
To blank sph s:
s.Blank()
- Sph.Blanked()¶
Checks if the sph is blanked or not
- Returns:
True if blanked, False if not
- Return type:
bool
Example
To check if sph s is blanked:
if s.Blanked(): do_something..
- Sph.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 sph s:
s.Browse()
- Sph.ClearFlag(flag)¶
Clears a flag on the sph
- Parameters:
flag (Flag) – Flag to clear on the sph
- Returns:
No return value
- Return type:
None
Example
To clear flag f for sph s:
s.ClearFlag(f)
- Sph.Copy(range=Oasys.gRPC.defaultArg)¶
Copies the sph. The target include of the copied sph 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:
Sph object
- Return type:
Sph
Example
To copy sph s into sph z:
z = s.Copy()
- Sph.DetachComment(comment)¶
Detaches a comment from a sph
- Parameters:
comment (Comment) –
Comment
that will be detached from the sph- Returns:
No return value
- Return type:
None
Example
To detach comment c from the sph s:
s.DetachComment(c)
- Sph.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 sph s:
s.Edit()
- Sph.ExtractColour()¶
Extracts the actual colour used for sph.
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 sphcolour
property will return the valueColour.PART
instead of the actual colour. This method will return the actual colour which is used for drawing the sph
- Returns:
colour value (integer)
- Return type:
int
Example
To return the colour used for drawing sph s:
colour = s.ExtractColour()
- Sph.Flagged(flag)¶
Checks if the sph is flagged or not
- Parameters:
flag (Flag) – Flag to test on the sph
- Returns:
True if flagged, False if not
- Return type:
bool
Example
To check if sph s has flag f set on it:
if s.Flagged(f): do_something..
- Sph.GetComments()¶
Extracts the comments associated to a sph
- 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 sph s:
comm_list = s.GetComments()
- Sph.GetParameter(prop)¶
Checks if a Sph 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 theSph.ViewParameters()
method and ‘method chaining’ (see the examples below)
- Parameters:
prop (string) – sph property to get parameter for
- Returns:
Parameter object if property is a parameter, None if not
- Return type:
dict
Example
To check if Sph property s.example is a parameter:
Oasys.PRIMER.Options.property_parameter_names = True if s.GetParameter(s.example): do_something... Oasys.PRIMER.Options.property_parameter_names = FalseTo check if Sph property s.example is a parameter by using the GetParameter method:
if s.ViewParameters().GetParameter(s.example): do_something..
- Sph.Keyword()¶
Returns the keyword for this sph (*ELEMENT_SPH) Note that a carriage return is not added. See also
Sph.KeywordCards()
- Returns:
string containing the keyword
- Return type:
str
Example
To get the keyword for sph s:
key = s.Keyword()
- Sph.KeywordCards()¶
Returns the keyword cards for the sph. Note that a carriage return is not added. See also
Sph.Keyword()
- Returns:
string containing the cards
- Return type:
str
Example
To get the cards for sph s:
cards = s.KeywordCards()
- Sph.Next()¶
Returns the next sph in the model
- Returns:
Sph object (or None if there are no more sphs in the model)
- Return type:
Sph
Example
To get the sph in model m after sph s:
s = s.Next()
- Sph.Previous()¶
Returns the previous sph in the model
- Returns:
Sph object (or None if there are no more sphs in the model)
- Return type:
Sph
Example
To get the sph in model m before sph s:
s = s.Previous()
- Sph.SetFlag(flag)¶
Sets a flag on the sph
- Parameters:
flag (Flag) – Flag to set on the sph
- Returns:
No return value
- Return type:
None
Example
To set flag f for sph s:
s.SetFlag(f)
- Sph.Sketch(redraw=Oasys.gRPC.defaultArg)¶
Sketches the sph. The sph will be sketched until you either call
Sph.Unsketch()
,Sph.UnsketchAll()
,Model.UnsketchAll()
, or delete the model
- Parameters:
redraw (boolean) – Optional. If model should be redrawn or not after the sph is sketched. If omitted redraw is true. If you want to sketch several sphs 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 sph s:
s.Sketch()
- Sph.Unblank()¶
Unblanks the sph
- Returns:
No return value
- Return type:
None
Example
To unblank sph s:
s.Unblank()
- Sph.Unsketch(redraw=Oasys.gRPC.defaultArg)¶
Unsketches the sph
- Parameters:
redraw (boolean) – Optional. If model should be redrawn or not after the sph is unsketched. If omitted redraw is true. If you want to unsketch several sphs 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 sph s:
s.Unsketch()
- Sph.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:
Sph object
- Return type:
dict
Example
To check if Sph property s.example is a parameter by using the
Sph.GetParameter()
method:if s.ViewParameters().GetParameter(s.example): do_something..
- Sph.Xrefs()¶
Returns the cross references for this sph
- Returns:
Xrefs object
- Return type:
dict
Example
To get the cross references for sph s:
xrefs = s.Xrefs()