Oasys.PRIMER.Curve class¶
Constants¶
- Curve.AFTER¶
Insertion of curve data option
- Curve.BEFORE¶
Insertion of curve data option
- Curve.CURVE¶
Load curve type *DEFINE_CURVE
- Curve.CURVE_FUNCTION¶
Load curve type *DEFINE_CURVE_FUNCTION
- Curve.CURVE_SMOOTH¶
Load curve type *DEFINE_CURVE_SMOOTH
- Curve.FUNCTION¶
Load curve type *DEFINE_FUNCTION
- Curve.TABLE¶
Load curve type *DEFINE_TABLE
Properties¶
- property Curve.dattyp: integer¶
Data type
- property Curve.dist: float¶
Total distance tool will travel
- property Curve.exists(read only): boolean¶
true if curve exists, false if referred to but not defined
- property Curve.function: string¶
Function expression for
Curve.CURVE_FUNCTION
- property Curve.label: integer¶
Curve
number. Also see thelcid
property which is an alternative name for this
- property Curve.lcid: integer¶
Curve
number. Also see thelabel
property which is an alternative name for this
- property Curve.lcint: integer¶
Number of discretization points for the curve
- property Curve.ncurves: integer¶
Number of points in curve or number of curves in table. The
npoints
property is an alternative name for this. (read only for tables)
- property Curve.npoints: integer¶
Number of points in curve or number of curves in table. The
ncurves
property is an alternative name for this. (read only for tables)
- property Curve.offa: float¶
Offset for abscissa values
- property Curve.offo: float¶
Offset for ordinate values
- property Curve.sfa: float¶
Scale factor on abscissa value
- property Curve.sfo: float¶
Scale factor on ordinate value
- property Curve.sidr: integer¶
Stress initialisation by dynamic relaxation
- property Curve.tend: float¶
Time curve returns to zero
- property Curve.trise: float¶
Rise time
- property Curve.tstart: float¶
Time curve starts to rise
- property Curve.type: constant¶
Load curve type (Can be
Curve.CURVE
,Curve.CURVE_FUNCTION
,Curve.SMOOTH
,Curve.FUNCTION
orCurve.TABLE
)
- property Curve.version: string¶
Version for discretization. Can be blank, “3858” or “5434a”
- property Curve.vmax: float¶
Maximum velocity
Constructor¶
- classmethod Curve(model, options)¶
Create a new
Curve
object
- Parameters:
model (Model) –
Model
that curve will be created inoptions (dict) –
Options for creating the curve
- dattyp (optional):
(integer) Data type
- dist (Type of load curve must be Curve.CURVE_SMOOTH) (optional):
(float) Total distance tool will travel
- function (load curve type has to be Curve.FUNCTION or Curve.CURVE_FUNCTION) (optional):
(string) Function expression
- heading (optional):
(string) Title for the curve
- lcid:
(integer)
Curve
number- lcint (optional):
(integer) Data type
- offa (optional):
(float) Offset on abscissa value
- offo (optional):
(float) Offset on ordinate value
- sfa (optional):
(float) Scale factor on abscissa value
- sfo (optional):
(float) Scale factor on ordinate value
- sidr (optional):
(integer) Stress initialisation by dynamic relaxation
- tend (Type of load curve must be Curve.CURVE_SMOOTH) (optional):
(float) Time curve returns to zero
- trise (Type of load curve must be Curve.CURVE_SMOOTH) (optional):
(float) Rise time
- tstart (Type of load curve must be Curve.CURVE_SMOOTH) (optional):
(float) Time curve starts to rise
- type:
(constant) Type of load curve. Can be
Curve.CURVE
,Curve.TABLE
, Note this does not have to be defined. In previous versions of PRIMER you could only construct a basic load curve type, therefore the type argument was not used. PRIMER is still backwards compatible with this method of load curve creation- vmax (Type of load curve must be Curve.CURVE_SMOOTH) (optional):
(float) Maximum velocity
- Returns:
Curve object
- Return type:
dict
Example
To create a new curve in model m with label 200
l = Oasys.PRIMER.Curve(m, {"type": Oasys.PRIMER.Curve.CURVE, "lcid": 200})To create a new curve function in model m with label 200 and function ‘0.5*lc9*vm(22)**3’ (example from keyword manual)
l = Oasys.PRIMER.Curve(m, {"type": Oasys.PRIMER.Curve.CURVE_FUNCTION, "lcid": 200, "function": "0.5\*lc9\*vm(22)\*\*3"})To create a new function in model m with label 200 and function ‘x(t)=1000*sin(100*t)’ and title ‘x-velo’ (example from keyword manual)
l = Oasys.PRIMER.Curve(m, {"type": Oasys.PRIMER.Curve.FUNCTION, "lcid": 200, "function": "x(t)=1000\*sin(100\*t)", "heading": "x-velo"})To create a new curve function in model m with label 200’ (example from keyword manual)
l = Oasys.PRIMER.Curve(m, {"type": Oasys.PRIMER.Curve.CURVE_SMOOTH, "lcid": 200})
Static methods¶
- classmethod Curve.Create(model, modal=Oasys.gRPC.defaultArg)¶
Starts an interactive editing panel to create a curve
- Parameters:
model (Model) –
Model
that the curve 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:
Curve object (or None if not made)
- Return type:
dict
Example
To start creating a curve in model m:
l = Oasys.PRIMER.Curve.Create(m)
- classmethod Curve.CreateTable(model, modal=Oasys.gRPC.defaultArg)¶
Starts an interactive editing panel to create a table
- Parameters:
model (Model) –
Model
that the curve 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:
Curve object (or None if not made)
- Return type:
dict
Example
To start creating a table in model m:
l = Oasys.PRIMER.Curve.CreateTable(m)
- classmethod Curve.First(model)¶
Returns the first curve in the model
- Parameters:
model (Model) –
Model
to get first curve in- Returns:
Curve object (or None if there are no curves in the model)
- Return type:
Curve
Example
To get the first curve in model m:
c = Oasys.PRIMER.Curve.First(m)
- classmethod Curve.FirstFreeLabel(model, layer=Oasys.gRPC.defaultArg)¶
Returns the first free curve label in the model. Also see
Curve.LastFreeLabel()
,Curve.NextFreeLabel()
andModel.FirstFreeItemLabel()
- Parameters:
- Returns:
Curve label
- Return type:
int
Example
To get the first free curve label in model m:
label = Oasys.PRIMER.Curve.FirstFreeLabel(m)
- classmethod Curve.FlagAll(model, flag)¶
Flags all of the curves in the model with a defined flag
- Parameters:
model (Model) –
Model
that all curves will be flagged inflag (Flag) – Flag to set on the curves
- Returns:
No return value
- Return type:
None
Example
To flag all of the curves with flag f in model m:
Oasys.PRIMER.Curve.FlagAll(m, f)
- classmethod Curve.GetAll(model)¶
Returns a list of Curve objects for all of the curves in a model in PRIMER
- Parameters:
model (Model) –
Model
to get curves from- Returns:
List of Curve objects
- Return type:
list
Example
To make a list of Curve objects for all of the curves in model m
c = Oasys.PRIMER.Curve.GetAll(m)
- classmethod Curve.GetFlagged(model, flag)¶
Returns a list of Curve objects for all of the flagged curves in a model in PRIMER
- Parameters:
model (Model) –
Model
to get curves fromflag (Flag) – Flag set on the curves that you want to retrieve
- Returns:
List of Curve objects
- Return type:
list
Example
To make a list of Curve objects for all of the curves in model m flagged with f
c = Oasys.PRIMER.Curve.GetFlagged(m, f)
- classmethod Curve.GetFromID(model, number)¶
Returns the Curve object for a curve ID
- Parameters:
model (Model) –
Model
to find the curve innumber (integer) – number of the curve you want the Curve object for
- Returns:
Curve object (or None if curve does not exist)
- Return type:
Curve
Example
To get the Curve object for curve 100 in model m
c = Oasys.PRIMER.Curve.GetFromID(m, 100)
- classmethod Curve.Last(model)¶
Returns the last curve in the model
- Parameters:
model (Model) –
Model
to get last curve in- Returns:
Curve object (or None if there are no curves in the model)
- Return type:
Curve
Example
To get the last curve in model m:
c = Oasys.PRIMER.Curve.Last(m)
- classmethod Curve.LastFreeLabel(model, layer=Oasys.gRPC.defaultArg)¶
Returns the last free curve label in the model. Also see
Curve.FirstFreeLabel()
,Curve.NextFreeLabel()
and seeModel.LastFreeItemLabel()
- Parameters:
- Returns:
Curve label
- Return type:
int
Example
To get the last free curve label in model m:
label = Oasys.PRIMER.Curve.LastFreeLabel(m)
- classmethod Curve.NextFreeLabel(model, layer=Oasys.gRPC.defaultArg)¶
Returns the next free (highest+1) curve label in the model. Also see
Curve.FirstFreeLabel()
,Curve.LastFreeLabel()
andModel.NextFreeItemLabel()
- Parameters:
- Returns:
Curve label
- Return type:
int
Example
To get the next free curve label in model m:
label = Oasys.PRIMER.Curve.NextFreeLabel(m)
- classmethod Curve.RenumberAll(model, start)¶
Renumbers all of the curves in the model
- Parameters:
model (Model) –
Model
that all curves will be renumbered instart (integer) – Start point for renumbering
- Returns:
No return value
- Return type:
None
Example
To renumber all of the curves in model m, from 1000000:
Oasys.PRIMER.Curve.RenumberAll(m, 1000000)
- classmethod Curve.RenumberFlagged(model, flag, start)¶
Renumbers all of the flagged curves in the model
- Parameters:
model (Model) –
Model
that all the flagged curves will be renumbered inflag (Flag) – Flag set on the curves that you want to renumber
start (integer) – Start point for renumbering
- Returns:
No return value
- Return type:
None
Example
To renumber all of the curves in model m flagged with f, from 1000000:
Oasys.PRIMER.Curve.RenumberFlagged(m, f, 1000000)
- classmethod Curve.Select(flag, prompt, limit=Oasys.gRPC.defaultArg, modal=Oasys.gRPC.defaultArg)¶
Allows the user to select curves using standard PRIMER object menus
- Parameters:
flag (Flag) – Flag to use when selecting curves
prompt (string) – Text to display as a prompt to the user
limit (Model or Flag) – Optional. If the argument is a
Model
then only curves from that model can be selected. If the argument is aFlag
then only curves that are flagged with limit can be selected (limit should be different to flag). If omitted, or None, any curves 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 curves selected or None if menu cancelled
- Return type:
int
Example
To select curves from model m, flagging those selected with flag f, giving the prompt ‘Select curves’:
Oasys.PRIMER.Curve.Select(f, 'Select curves', m)To select curves, flagging those selected with flag f but limiting selection to curves flagged with flag l, giving the prompt ‘Select curves’:
Oasys.PRIMER.Curve.Select(f, 'Select curves', l)
- classmethod Curve.Total(model, exists=Oasys.gRPC.defaultArg)¶
Returns the total number of curves in the model
- Parameters:
model (Model) –
Model
to get total forexists (boolean) – Optional. true if only existing curves should be counted. If false or omitted referenced but undefined curves will also be included in the total
- Returns:
number of curves
- Return type:
int
Example
To get the total number of curves in model m:
total = Oasys.PRIMER.Curve.Total(m)
- classmethod Curve.UnflagAll(model, flag)¶
Unsets a defined flag on all of the curves in the model
- Parameters:
model (Model) –
Model
that the defined flag for all curves will be unset inflag (Flag) – Flag to unset on the curves
- Returns:
No return value
- Return type:
None
Example
To unset the flag f on all the curves in model m:
Oasys.PRIMER.Curve.UnflagAll(m, f)
Instance methods¶
- Curve.AddPoint(xvalue, yvalue)¶
Adds a point to a load curve
- Parameters:
xvalue (real) – The x value of the point
yvalue (real) – The y value of the point
- Returns:
No return value
- Return type:
None
Example
To add a point with values of x=3 and y=5 to curve l:
l.AddPoint(3, 5)
- Curve.AddTableEntry(value, load_curve)¶
Adds an entry line to a table
- Parameters:
value (real) – The value for for this entry in the table
load_curve (integer) – The load curve corresponding to the defined value
- Returns:
No return value
- Return type:
None
Example
To add an entry with a value of 3 for load curve 1000:
l.AddTableEntry(3, 1000)
- Curve.AssociateComment(comment)¶
Associates a comment with a curve
- Parameters:
comment (Comment) –
Comment
that will be attached to the curve- Returns:
No return value
- Return type:
None
Example
To associate comment c to the curve c:
c.AssociateComment(c)
- Curve.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 curve c:
c.Browse()
- Curve.ClearFlag(flag)¶
Clears a flag on the curve
- Parameters:
flag (Flag) – Flag to clear on the curve
- Returns:
No return value
- Return type:
None
Example
To clear flag f for curve c:
c.ClearFlag(f)
- Curve.Copy(range=Oasys.gRPC.defaultArg)¶
Copies the curve. The target include of the copied curve 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:
Curve object
- Return type:
Curve
Example
To copy curve c into curve z:
z = c.Copy()
- Curve.DetachComment(comment)¶
Detaches a comment from a curve
- Parameters:
comment (Comment) –
Comment
that will be detached from the curve- Returns:
No return value
- Return type:
None
Example
To detach comment c from the curve c:
c.DetachComment(c)
- Curve.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 curve c:
c.Edit()
- Curve.Flagged(flag)¶
Checks if the curve is flagged or not
- Parameters:
flag (Flag) – Flag to test on the curve
- Returns:
True if flagged, False if not
- Return type:
bool
Example
To check if curve c has flag f set on it:
if c.Flagged(f): do_something..
- Curve.GetComments()¶
Extracts the comments associated to a curve
- 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 curve c:
comm_list = c.GetComments()
- Curve.GetParameter(prop)¶
Checks if a Curve 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 theCurve.ViewParameters()
method and ‘method chaining’ (see the examples below)
- Parameters:
prop (string) – curve property to get parameter for
- Returns:
Parameter object if property is a parameter, None if not
- Return type:
dict
Example
To check if Curve property c.example is a parameter:
Oasys.PRIMER.Options.property_parameter_names = True if c.GetParameter(c.example): do_something... Oasys.PRIMER.Options.property_parameter_names = FalseTo check if Curve property c.example is a parameter by using the GetParameter method:
if c.ViewParameters().GetParameter(c.example): do_something..
- Curve.GetPoint(row)¶
Returns x and y data for a point in a curve
- Parameters:
row (integer) – The row point you want the data for. Note that curve points start at 0, not 1
- Returns:
A list containing the x coordinate and the y coordinate
- Return type:
list
Example
To get the curve data for the 3rd point for curve l:
if (l.npoints >= 3): point_data = l.GetPoint(3)
- Curve.GetTableEntry(row)¶
Returns the value and curve label for a row in a table
- Parameters:
row (integer) – The row point you want the data for. Note that curve points start at 0, not 1
- Returns:
A list containing the value and the load curve label
- Return type:
list
Example
To get the data for the 3rd point for table t:
if (t.npoints >= 3): row_data = t.GetTableEntry(2)
- Curve.InsertPoint(ipt, xvalue, yvalue, position)¶
Inserts point values before or after a specified row of data on a load curve
- Parameters:
ipt (integer) – The row you want to insert the data before or after. Note that the row data starts at 0, not 1
xvalue (real) – The x value of the point
yvalue (real) – The y value of the point
position (integer) – Specify either before or after the selected row. Use ‘Curve.BEFORE’ for before, and ‘Curve.AFTER’ for after
- Returns:
No return value
- Return type:
None
Example
To insert the values after the 3rd row to x=3, y=5 for curve l:
l.InsertPoint(2, 3, 5, Oasys.PRIMER.Curve.AFTER)
- Curve.InsertTableEntry(ipt, value, lcid, position)¶
Inserts a table row before or after a specified row of data on a table
- Parameters:
ipt (integer) – The row you want to insert the data before or after. Note that the row data starts at 0, not 1
value (real) – The value of the row
lcid (integer) – The load curve corresponding to the defined value
position (integer) – Specify either before or after the selected row. Use ‘Curve.BEFORE’ for before, and ‘Curve.AFTER’ for after
- Returns:
No return value
- Return type:
None
Example
To insert the values after the 3rd row to value=3, lcur=5 for table t:
t.InsertTableEntry(2, 3, 5, Oasys.PRIMER.Curve.AFTER)
- Curve.Keyword()¶
Returns the keyword for this curve (*DEFINE_CURVE_xxxx). Note that a carriage return is not added. See also
Curve.KeywordCards()
- Returns:
string containing the keyword
- Return type:
str
Example
To get the keyword for curve l:
key = l.Keyword()
- Curve.KeywordCards()¶
Returns the keyword cards for the curve. Note that a carriage return is not added. See also
Curve.Keyword()
- Returns:
string containing the cards
- Return type:
str
Example
To get the cards for curve l:
cards = l.KeywordCards()
- Curve.Next()¶
Returns the next curve in the model
- Returns:
Curve object (or None if there are no more curves in the model)
- Return type:
Curve
Example
To get the curve in model m after curve c:
c = c.Next()
- Curve.Previous()¶
Returns the previous curve in the model
- Returns:
Curve object (or None if there are no more curves in the model)
- Return type:
Curve
Example
To get the curve in model m before curve c:
c = c.Previous()
- Curve.RemovePoint(row)¶
Removes a row of data from a curve
- Parameters:
row (integer) – The row point you want to remove. Note that curve points start at 0, not 1
- Returns:
No return value
- Return type:
None
Example
To remove the curve data for the 3rd point for curve l:
if (l.npoints >= 3): point_data = l.RemovePoint(2)
- Curve.RemoveTableEntry(ipt)¶
Removes the value and loadcurve values for a specified row of data on a load curve
- Parameters:
ipt (integer) – The row you want to remove the data for. Note that the row data starts at 0, not 1
- Returns:
No return value
- Return type:
None
Example
To remove an entry at row 4:
t.RemoveTableEntry(4)
- Curve.SetFlag(flag)¶
Sets a flag on the curve
- Parameters:
flag (Flag) – Flag to set on the curve
- Returns:
No return value
- Return type:
None
Example
To set flag f for curve c:
c.SetFlag(f)
- Curve.SetPoint(ipt, xvalue, yvalue)¶
Sets the x and y values for a specified row of data on a load curve
- Parameters:
ipt (integer) – The row you want to set the data for. Note that the row data starts at 0, not 1
xvalue (real) – The x value of the point
yvalue (real) – The y value of the point
- Returns:
No return value
- Return type:
None
Example
To set the values for the 3rd row to x=3, y=5 for curve l:
l.SetPoint(2, 3, 5)
- Curve.SetTableEntry(ipt, value, load_curve)¶
Sets the value and loadcurve values for a specified row of data on a load curve
- Parameters:
ipt (integer) – The row you want to set the data for. Note that the row data starts at 0, not 1
value (real) – The value for for this entry in the table
load_curve (integer) – The load curve corresponding to the defined value
- Returns:
No return value
- Return type:
None
Example
To add an entry with a value of 3 for load curve 1000 at row 4:
t.SetTableEntry(4, 3, 1000)
- Curve.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:
Curve object
- Return type:
dict
Example
To check if Curve property c.example is a parameter by using the
Curve.GetParameter()
method:if c.ViewParameters().GetParameter(c.example): do_something..
- Curve.Xrefs()¶
Returns the cross references for this curve
- Returns:
Xrefs object
- Return type:
dict
Example
To get the cross references for curve c:
xrefs = c.Xrefs()