Oasys.PRIMER.Sensor class¶
Properties¶
- property Sensor.acc: float¶
Activating acceleration
- property Sensor.atime: float¶
Time over which acceleration must be exceeded
- property Sensor.colour: Colour¶
The colour of the sensor
- property Sensor.dmn: float¶
Minimum distance
- property Sensor.dmx: float¶
Maximum distance
- property Sensor.dof: integer¶
Degree of freedom
- property Sensor.exists(read only): boolean¶
true if sensor exists, false if referred to but not defined
- property Sensor.label: integer¶
Sensor
number. Also see thesbacid
property which is an alternative name for this
- property Sensor.pulmn: float¶
Maximum pull-out
- property Sensor.pulmx: float¶
Maximum pull-out
- property Sensor.pulrat: float¶
Rate of pull-out (length/time units)
- property Sensor.pultim: float¶
Time over which rate of pull#out must be exceeded
- property Sensor.sbsfl: integer¶
Sensor flag
- property Sensor.sbsid: integer¶
Sensor
number. Also see thelabel
property which is an alternative name for this
- property Sensor.sbstyp: integer¶
Sensor type
- property Sensor.time: float¶
Time at which sensor triggers
- property Sensor.transparency: integer¶
The transparency of the sensor (0-100) 0% is opaque, 100% is transparent
Constructor¶
- classmethod Sensor(model, sbsid, sbstyp, sbsfl=Oasys.gRPC.defaultArg, nid=Oasys.gRPC.defaultArg, nid2=Oasys.gRPC.defaultArg)¶
Create a new
Seatbelt Sensor
object
- Parameters:
model (Model) –
Model
that sensor will be created insbsid (integer) –
Sensor
numbersbstyp (integer) – Sensor type
sbsfl (integer) – Optional. Sensor flag. Default 0
nid (integer) – Optional. Optional node ID: Compulsory for types 1 and 4
nid2 (integer) – Optional. Optional node ID 2: Compulsory for type 4
- Returns:
Sensor object
- Return type:
dict
Example
To create a new seatbelt sensor in model m with label 100, type 1 and node 1:
s = Oasys.PRIMER.Sensor(m, 100, 1, 0, 1)
Static methods¶
- classmethod Sensor.BlankAll(model, redraw=Oasys.gRPC.defaultArg)¶
Blanks all of the sensors in the model
- Parameters:
model (Model) –
Model
that all sensors 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 sensors in model m:
Oasys.PRIMER.Sensor.BlankAll(m)
- classmethod Sensor.BlankFlagged(model, flag, redraw=Oasys.gRPC.defaultArg)¶
Blanks all of the flagged sensors in the model
- Parameters:
model (Model) –
Model
that all the flagged sensors will be blanked inflag (Flag) – Flag set on the sensors 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 sensors in model m flagged with f:
Oasys.PRIMER.Sensor.BlankFlagged(m, f)
- classmethod Sensor.Create(model, modal=Oasys.gRPC.defaultArg)¶
Starts an interactive editing panel to create a sensor
- Parameters:
model (Model) –
Model
that the sensor 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:
Sensor object (or None if not made)
- Return type:
dict
Example
To start creating an sensor in model m:
s = Oasys.PRIMER.Sensor.Create(m)
- classmethod Sensor.First(model)¶
Returns the first sensor in the model
- Parameters:
model (Model) –
Model
to get first sensor in- Returns:
Sensor object (or None if there are no sensors in the model)
- Return type:
Sensor
Example
To get the first sensor in model m:
s = Oasys.PRIMER.Sensor.First(m)
- classmethod Sensor.FirstFreeLabel(model, layer=Oasys.gRPC.defaultArg)¶
Returns the first free sensor label in the model. Also see
Sensor.LastFreeLabel()
,Sensor.NextFreeLabel()
andModel.FirstFreeItemLabel()
- Parameters:
- Returns:
Sensor label
- Return type:
int
Example
To get the first free sensor label in model m:
label = Oasys.PRIMER.Sensor.FirstFreeLabel(m)
- classmethod Sensor.FlagAll(model, flag)¶
Flags all of the sensors in the model with a defined flag
- Parameters:
model (Model) –
Model
that all sensors will be flagged inflag (Flag) – Flag to set on the sensors
- Returns:
No return value
- Return type:
None
Example
To flag all of the sensors with flag f in model m:
Oasys.PRIMER.Sensor.FlagAll(m, f)
- classmethod Sensor.GetAll(model)¶
Returns a list of Sensor objects for all of the sensors in a model in PRIMER
- Parameters:
model (Model) –
Model
to get sensors from- Returns:
List of Sensor objects
- Return type:
list
Example
To make a list of Sensor objects for all of the sensors in model m
s = Oasys.PRIMER.Sensor.GetAll(m)
- classmethod Sensor.GetFlagged(model, flag)¶
Returns a list of Sensor objects for all of the flagged sensors in a model in PRIMER
- Parameters:
model (Model) –
Model
to get sensors fromflag (Flag) – Flag set on the sensors that you want to retrieve
- Returns:
List of Sensor objects
- Return type:
list
Example
To make a list of Sensor objects for all of the sensors in model m flagged with f
s = Oasys.PRIMER.Sensor.GetFlagged(m, f)
- classmethod Sensor.GetFromID(model, number)¶
Returns the Sensor object for a sensor ID
- Parameters:
model (Model) –
Model
to find the sensor innumber (integer) – number of the sensor you want the Sensor object for
- Returns:
Sensor object (or None if sensor does not exist)
- Return type:
Sensor
Example
To get the Sensor object for sensor 100 in model m
s = Oasys.PRIMER.Sensor.GetFromID(m, 100)
- classmethod Sensor.Last(model)¶
Returns the last sensor in the model
- Parameters:
model (Model) –
Model
to get last sensor in- Returns:
Sensor object (or None if there are no sensors in the model)
- Return type:
Sensor
Example
To get the last sensor in model m:
s = Oasys.PRIMER.Sensor.Last(m)
- classmethod Sensor.LastFreeLabel(model, layer=Oasys.gRPC.defaultArg)¶
Returns the last free sensor label in the model. Also see
Sensor.FirstFreeLabel()
,Sensor.NextFreeLabel()
and seeModel.LastFreeItemLabel()
- Parameters:
- Returns:
Sensor label
- Return type:
int
Example
To get the last free sensor label in model m:
label = Oasys.PRIMER.Sensor.LastFreeLabel(m)
- classmethod Sensor.NextFreeLabel(model, layer=Oasys.gRPC.defaultArg)¶
Returns the next free (highest+1) sensor label in the model. Also see
Sensor.FirstFreeLabel()
,Sensor.LastFreeLabel()
andModel.NextFreeItemLabel()
- Parameters:
- Returns:
Sensor label
- Return type:
int
Example
To get the next free sensor label in model m:
label = Oasys.PRIMER.Sensor.NextFreeLabel(m)
- classmethod Sensor.Pick(prompt, limit=Oasys.gRPC.defaultArg, modal=Oasys.gRPC.defaultArg, button_text=Oasys.gRPC.defaultArg)¶
Allows the user to pick a sensor
- 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 sensors from that model can be picked. If the argument is aFlag
then only sensors that are flagged with limit can be selected. If omitted, or None, any sensors 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:
Sensor object (or None if not picked)
- Return type:
dict
Example
To pick a sensor from model m giving the prompt ‘Pick sensor from screen’:
s = Oasys.PRIMER.Sensor.Pick('Pick sensor from screen', m)
- classmethod Sensor.RenumberAll(model, start)¶
Renumbers all of the sensors in the model
- Parameters:
model (Model) –
Model
that all sensors will be renumbered instart (integer) – Start point for renumbering
- Returns:
No return value
- Return type:
None
Example
To renumber all of the sensors in model m, from 1000000:
Oasys.PRIMER.Sensor.RenumberAll(m, 1000000)
- classmethod Sensor.RenumberFlagged(model, flag, start)¶
Renumbers all of the flagged sensors in the model
- Parameters:
model (Model) –
Model
that all the flagged sensors will be renumbered inflag (Flag) – Flag set on the sensors that you want to renumber
start (integer) – Start point for renumbering
- Returns:
No return value
- Return type:
None
Example
To renumber all of the sensors in model m flagged with f, from 1000000:
Oasys.PRIMER.Sensor.RenumberFlagged(m, f, 1000000)
- classmethod Sensor.Select(flag, prompt, limit=Oasys.gRPC.defaultArg, modal=Oasys.gRPC.defaultArg)¶
Allows the user to select sensors using standard PRIMER object menus
- Parameters:
flag (Flag) – Flag to use when selecting sensors
prompt (string) – Text to display as a prompt to the user
limit (Model or Flag) – Optional. If the argument is a
Model
then only sensors from that model can be selected. If the argument is aFlag
then only sensors that are flagged with limit can be selected (limit should be different to flag). If omitted, or None, any sensors 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 sensors selected or None if menu cancelled
- Return type:
int
Example
To select sensors from model m, flagging those selected with flag f, giving the prompt ‘Select sensors’:
Oasys.PRIMER.Sensor.Select(f, 'Select sensors', m)To select sensors, flagging those selected with flag f but limiting selection to sensors flagged with flag l, giving the prompt ‘Select sensors’:
Oasys.PRIMER.Sensor.Select(f, 'Select sensors', l)
- classmethod Sensor.SketchFlagged(model, flag, redraw=Oasys.gRPC.defaultArg)¶
Sketches all of the flagged sensors in the model. The sensors will be sketched until you either call
Sensor.Unsketch()
,Sensor.UnsketchFlagged()
,Model.UnsketchAll()
, or delete the model
- Parameters:
model (Model) –
Model
that all the flagged sensors will be sketched inflag (Flag) – Flag set on the sensors that you want to sketch
redraw (boolean) – Optional. If model should be redrawn or not after the sensors are sketched. If omitted redraw is true. If you want to sketch flagged sensors 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 sensors flagged with flag in model m:
Oasys.PRIMER.Sensor.SketchFlagged(m, flag)
- classmethod Sensor.Total(model, exists=Oasys.gRPC.defaultArg)¶
Returns the total number of sensors in the model
- Parameters:
model (Model) –
Model
to get total forexists (boolean) – Optional. true if only existing sensors should be counted. If false or omitted referenced but undefined sensors will also be included in the total
- Returns:
number of sensors
- Return type:
int
Example
To get the total number of sensors in model m:
total = Oasys.PRIMER.Sensor.Total(m)
- classmethod Sensor.UnblankAll(model, redraw=Oasys.gRPC.defaultArg)¶
Unblanks all of the sensors in the model
- Parameters:
model (Model) –
Model
that all sensors 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 sensors in model m:
Oasys.PRIMER.Sensor.UnblankAll(m)
- classmethod Sensor.UnblankFlagged(model, flag, redraw=Oasys.gRPC.defaultArg)¶
Unblanks all of the flagged sensors in the model
- Parameters:
model (Model) –
Model
that the flagged sensors will be unblanked inflag (Flag) – Flag set on the sensors 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 sensors in model m flagged with f:
Oasys.PRIMER.Sensor.UnblankFlagged(m, f)
- classmethod Sensor.UnflagAll(model, flag)¶
Unsets a defined flag on all of the sensors in the model
- Parameters:
model (Model) –
Model
that the defined flag for all sensors will be unset inflag (Flag) – Flag to unset on the sensors
- Returns:
No return value
- Return type:
None
Example
To unset the flag f on all the sensors in model m:
Oasys.PRIMER.Sensor.UnflagAll(m, f)
- classmethod Sensor.UnsketchAll(model, redraw=Oasys.gRPC.defaultArg)¶
Unsketches all sensors
- Parameters:
model (Model) –
Model
that all sensors will be unblanked inredraw (boolean) – Optional. If model should be redrawn or not after the sensors 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 sensors in model m:
Oasys.PRIMER.Sensor.UnsketchAll(m)
- classmethod Sensor.UnsketchFlagged(model, flag, redraw=Oasys.gRPC.defaultArg)¶
Unsketches all flagged sensors in the model
- Parameters:
model (Model) –
Model
that all sensors will be unsketched inflag (Flag) – Flag set on the sensors that you want to unsketch
redraw (boolean) – Optional. If model should be redrawn or not after the sensors 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 sensors flagged with flag in model m:
Oasys.PRIMER.Sensor.UnsketchAll(m, flag)
Instance methods¶
- Sensor.AssociateComment(comment)¶
Associates a comment with a sensor
- Parameters:
comment (Comment) –
Comment
that will be attached to the sensor- Returns:
No return value
- Return type:
None
Example
To associate comment c to the sensor s:
s.AssociateComment(c)
- Sensor.Blank()¶
Blanks the sensor
- Returns:
No return value
- Return type:
None
Example
To blank sensor s:
s.Blank()
- Sensor.Blanked()¶
Checks if the sensor is blanked or not
- Returns:
True if blanked, False if not
- Return type:
bool
Example
To check if sensor s is blanked:
if s.Blanked(): do_something..
- Sensor.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 sensor s:
s.Browse()
- Sensor.ClearFlag(flag)¶
Clears a flag on the sensor
- Parameters:
flag (Flag) – Flag to clear on the sensor
- Returns:
No return value
- Return type:
None
Example
To clear flag f for sensor s:
s.ClearFlag(f)
- Sensor.Copy(range=Oasys.gRPC.defaultArg)¶
Copies the sensor. The target include of the copied sensor 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:
Sensor object
- Return type:
Sensor
Example
To copy sensor s into sensor z:
z = s.Copy()
- Sensor.DetachComment(comment)¶
Detaches a comment from a sensor
- Parameters:
comment (Comment) –
Comment
that will be detached from the sensor- Returns:
No return value
- Return type:
None
Example
To detach comment c from the sensor s:
s.DetachComment(c)
- Sensor.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 sensor s:
s.Edit()
- Sensor.ExtractColour()¶
Extracts the actual colour used for sensor.
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 sensorcolour
property will return the valueColour.PART
instead of the actual colour. This method will return the actual colour which is used for drawing the sensor
- Returns:
colour value (integer)
- Return type:
int
Example
To return the colour used for drawing sensor s:
colour = s.ExtractColour()
- Sensor.Flagged(flag)¶
Checks if the sensor is flagged or not
- Parameters:
flag (Flag) – Flag to test on the sensor
- Returns:
True if flagged, False if not
- Return type:
bool
Example
To check if sensor s has flag f set on it:
if s.Flagged(f): do_something..
- Sensor.GetComments()¶
Extracts the comments associated to a sensor
- 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 sensor s:
comm_list = s.GetComments()
- Sensor.GetParameter(prop)¶
Checks if a Sensor 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 theSensor.ViewParameters()
method and ‘method chaining’ (see the examples below)
- Parameters:
prop (string) – sensor property to get parameter for
- Returns:
Parameter object if property is a parameter, None if not
- Return type:
dict
Example
To check if Sensor 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 Sensor property s.example is a parameter by using the GetParameter method:
if s.ViewParameters().GetParameter(s.example): do_something..
- Sensor.Keyword()¶
Returns the keyword for this sensor (*ELEMENT_SEATBELT_SENSEROMETER) Note that a carriage return is not added. See also
Sensor.KeywordCards()
- Returns:
string containing the keyword
- Return type:
str
Example
To get the keyword for sensor s:
key = s.Keyword()
- Sensor.KeywordCards()¶
Returns the keyword cards for the sensor. Note that a carriage return is not added. See also
Sensor.Keyword()
- Returns:
string containing the cards
- Return type:
str
Example
To get the cards for sensor s:
cards = s.KeywordCards()
- Sensor.Next()¶
Returns the next sensor in the model
- Returns:
Sensor object (or None if there are no more sensors in the model)
- Return type:
Sensor
Example
To get the sensor in model m after sensor s:
s = s.Next()
- Sensor.Previous()¶
Returns the previous sensor in the model
- Returns:
Sensor object (or None if there are no more sensors in the model)
- Return type:
Sensor
Example
To get the sensor in model m before sensor s:
s = s.Previous()
- Sensor.SetFlag(flag)¶
Sets a flag on the sensor
- Parameters:
flag (Flag) – Flag to set on the sensor
- Returns:
No return value
- Return type:
None
Example
To set flag f for sensor s:
s.SetFlag(f)
- Sensor.Sketch(redraw=Oasys.gRPC.defaultArg)¶
Sketches the sensor. The sensor will be sketched until you either call
Sensor.Unsketch()
,Sensor.UnsketchAll()
,Model.UnsketchAll()
, or delete the model
- Parameters:
redraw (boolean) – Optional. If model should be redrawn or not after the sensor is sketched. If omitted redraw is true. If you want to sketch several sensors 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 sensor s:
s.Sketch()
- Sensor.Unblank()¶
Unblanks the sensor
- Returns:
No return value
- Return type:
None
Example
To unblank sensor s:
s.Unblank()
- Sensor.Unsketch(redraw=Oasys.gRPC.defaultArg)¶
Unsketches the sensor
- Parameters:
redraw (boolean) – Optional. If model should be redrawn or not after the sensor is unsketched. If omitted redraw is true. If you want to unsketch several sensors 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 sensor s:
s.Unsketch()
- Sensor.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:
Sensor object
- Return type:
dict
Example
To check if Sensor property s.example is a parameter by using the
Sensor.GetParameter()
method:if s.ViewParameters().GetParameter(s.example): do_something..
- Sensor.Xrefs()¶
Returns the cross references for this sensor
- Returns:
Xrefs object
- Return type:
dict
Example
To get the cross references for sensor s:
xrefs = s.Xrefs()