Oasys.PRIMER.Parameter class¶
Constants¶
- Parameter.CHARACTER¶
Parameter is a character
- Parameter.INTEGER¶
Parameter is an integer
- Parameter.LOCAL¶
Parameter has _LOCAL suffix (used in suffix argument for constructor)
- Parameter.MUTABLE¶
Parameter has _MUTABLE suffix (used in suffix argument for constructor)
- Parameter.NOECHO¶
Parameter has _NOECHO suffix (used in suffix argument for constructor)
- Parameter.REAL¶
Parameter is a real
Properties¶
- property Parameter.expression(read only): boolean¶
true if this parameter is a *PARAMETER_EXPRESSION, false otherwise
- property Parameter.local: boolean¶
true if this parameter is a *PARAMETER_… _LOCAL, false otherwise
- property Parameter.mutable: boolean¶
true if this parameter is a *PARAMETER_… _MUTABLE, false otherwise
- property Parameter.noecho: boolean¶
true if this parameter is a *PARAMETER_… _NOECHO, false otherwise
- property Parameter.type(read only): constant¶
Can be
Parameter.INTEGER
,Parameter.REAL
orParameter.CHARACTER
- property Parameter.value: integer/float/string¶
Parameter
value. The value will be a string for parameterexpressions
, or a number for normal parameters.
By default when a parameter value is changed PRIMER will re-evaluate and update all of the parameters in the model as changing this parameter could cause others to change because of parameter expressions. There could be some situations where changing parameters one at a time could cause problems with re-evaluation. For example, changing parameter A could temporarily cause a division by zero when re-evaluating parameter expression B until parameter C is changed. In this case the automatic re-evaluation can be prevented by usingParameter.SaveAll
andParameter.UpdateAll
Constructor¶
- classmethod Parameter(model, name, type, expression, value, suffix=Oasys.gRPC.defaultArg)¶
Create a new
Parameter
object
- Parameters:
model (Model) –
Model
that parameter will be created inname (string) –
Parameter
nametype (constant) – Can be
Parameter.INTEGER
,Parameter.REAL
orParameter.CHARACTER
expression (boolean) – true if
*PARAMETER_EXPRESSION
, false otherwisevalue (integer/float/string) – Parameter value. The value will be a string for character parameters or parameter
expressions
, or a number for integer or real parameterssuffix (constant) – Optional. Keyword suffix Can be
Parameter.LOCAL
for *PARAMETER_…_LOCAL,Parameter.MUTABLE
for *PARAMETER_…_MUTABLE, orParameter.NOECHO
for *PARAMETER_…_NOECHO. These may be bitwise ORed together, ie Parameter.LOCAL | Parameter.MUTABLE | Parameter.NOECHO. If omitted the parameter will not be local or mutable- Returns:
Parameter object
- Return type:
dict
Example
To create a new real parameter THK in model m with value 5.0
p = Oasys.PRIMER.Parameter(m, "THK", Oasys.PRIMER.Parameter.REAL, False, 5.0)To create a new LOCAL integer parameter INDEX in model m with value 3
p = Oasys.PRIMER.Parameter(m, "INDEX", Oasys.PRIMER.Parameter.INTEGER, False, 3, Oasys.PRIMER.Parameter.LOCAL)
Static methods¶
- classmethod Parameter.AutoReorder(model)¶
Auto Reorders all the parameters in the model
- Parameters:
model (Model) –
Model
that contains all parameters that will be re-ordered- Returns:
No return value
- Return type:
None
Example
To auto-reorder all parameters in model m:
Oasys.PRIMER.Parameter.AutoReorder(m)
- classmethod Parameter.FlagAll(model, flag)¶
Flags all of the parameters in the model with a defined flag
- Parameters:
model (Model) –
Model
that all parameters will be flagged inflag (Flag) – Flag to set on the parameters
- Returns:
No return value
- Return type:
None
Example
To flag all of the parameters with flag f in model m:
Oasys.PRIMER.Parameter.FlagAll(m, f)
- classmethod Parameter.GetAll(model)¶
Returns a list of Parameter objects for all of the parameters in a model in Primer
- Parameters:
model (Model) –
Model
to get parameters from- Returns:
List of Parameter objects
- Return type:
list
Example
To make a list of Parameter objects for all of the parameters in model m
p = Oasys.PRIMER.Parameter.GetAll(m)
- classmethod Parameter.GetAllOfName(model)¶
Returns a list of Parameter objects for all parameters in a model matching Name. If none are found that match it will return None. (Multiple parameters of the same name may exist if they use the _LOCAL or _MUTABLE suffices. PRIMER will also store multiple illegal instances of parameter name, using the instance as determined by the PARAMETER_DUPLICATION card.)
- Parameters:
model (Model) –
Model
to get parameters from- Returns:
List of Parameter objects
- Return type:
list
Example
To make a list of Parameter objects for all of the parameters of name in model m
p = Oasys.PRIMER.Parameter.GetAllOfName(m, name)
- classmethod Parameter.GetFromName(model, parameter_name)¶
Returns the stored Parameter object for a parameter name. WARNING: if more than one parameter Name exists (eg _LOCAL, _MUTABLE) then only the first occurrence is returned. To return all parameters matching Name use GetAllOfName() instead
- Parameters:
model (Model) –
Model
to find the parameter inparameter_name (string) – name of the parameter you want the Parameter object for
- Returns:
Parameter object (or None if parameter does not exist)
- Return type:
Parameter
Example
To get the Parameter object for parameter “THK” in model m
p = Oasys.PRIMER.Parameter.GetFromName(m, "THK")
- classmethod Parameter.SaveAll(model)¶
Saves the current status and values of all of the parameters in the model. Calling this will also have the effect of turning off re-evaluating and updating of all parameters in the model when a parameter
value
is changed.
To update several parameters in a model without re-evaluating all the parameters after each one is changed first call this, then update all of the parametervalues
, and then callParameter.UpdateAll
to apply the update.
Parameter.SaveAll
must be called before usingParameter.UpdateAll
- Parameters:
model (Model) –
Model
that the parameters will be saved in- Returns:
No return value
- Return type:
None
Example
To save the status of all of the parameters in model m:
Oasys.PRIMER.Parameter.SaveAll(m)
- classmethod Parameter.UnflagAll(model, flag)¶
Unsets a defined flag on all of the parameters in the model
- Parameters:
model (Model) –
Model
that the defined flag for all parameters will be unset inflag (Flag) – Flag to unset on the parameters
- Returns:
No return value
- Return type:
None
Example
To unset the flag f on all of the parameters in model m:
Oasys.PRIMER.Parameter.UnflagAll(m, f)
- classmethod Parameter.UpdateAll(model)¶
Updates all of the parameters in the model after saving the state of all parameters using
Parameter.SaveAll
and modifying the parametervalues
. As parameter re-evaluation has been suppressed byParameter.SaveAll
you should ensure that all parameters in the model can beevaluated
correctly before calling this to ensure that there are no errors. If any of the parameters cannot be evaluated then the values saved inParameter.SaveAll
will be restored, the update will be aborted and an exception thrown. Calling this will also have the effect of turning back on re-evaluating and updating of all parameters in the model when a parametervalue
is changed.
Parameter.SaveAll
must be called before this method can be used
- Parameters:
model (Model) –
Model
that the parameters will be updated in- Returns:
No return value
- Return type:
None
Example
To update all of the parameters in model m:
Oasys.PRIMER.Parameter.UpdateAll(m)
Instance methods¶
- Parameter.ClearFlag(flag)¶
Clears a flag on the parameter
- Parameters:
flag (Flag) – Flag to clear on the parameter
- Returns:
No return value
- Return type:
None
Example
To clear flag f for parameter p:
p.ClearFlag(f)
- Parameter.Evaluate()¶
Evaluates a parameter expression, updating the evaluated value stored in PRIMER and returns the value. If the parameter is not an expression then the parameter value will just be returned.
If evaluating the expression cannot be done because of an error (e.g. dividing by zero) an exception will be thrown
- Returns:
number (real and integer parameters) or string (character parameters)
- Return type:
int
Example
To evaluate parameter p:
value = p.Evaluate()
- Parameter.Flagged(flag)¶
Checks if the parameter is flagged or not
- Parameters:
flag (Flag) – Flag to test on the parameter
- Returns:
True if flagged, False if not
- Return type:
bool
Example
To check if parameter p has flag f set on it:
p.Flagged(f) )
- Parameter.Keyword()¶
Returns the keyword for this parameter (*PARAMETER, *PARAMETER_EXPRESSION). Note that a carriage return is not added. See also
Parameter.KeywordCards()
- Returns:
string containing the keyword
- Return type:
str
Example
To get the keyword for parameter p:
key = p.Keyword()
- Parameter.KeywordCards()¶
Returns the keyword cards for the parameter. Note that a carriage return is not added. See also
Parameter.Keyword()
- Returns:
string containing the cards
- Return type:
str
Example
To get the cards for parameter p:
cards = p.KeywordCards()
- Parameter.SetFlag(flag)¶
Sets a flag on the parameter
- Parameters:
flag (Flag) – Flag to set on the parameter
- Returns:
No return value
- Return type:
None
Example
To set flag f for parameter p:
p.SetFlag(f)
- Parameter.Xrefs()¶
Returns the cross references for this parameter
- Returns:
Xrefs object
- Return type:
dict
Example
To get the cross references for parameter p:
xrefs = p.Xrefs()