Oasys.PRIMER.Vector class¶
Properties¶
- property Vector.cid: int¶
Coordinate system ID
- property Vector.exists(read only): boolean¶
true if vector exists, false if referred to but not defined
- property Vector.label: integer¶
Vector
number. Also see thevid
property which is an alternative name for this
- property Vector.nodeh: int¶
Node ID for head of vector (for _NODES option)
- property Vector.nodes: boolean¶
_NODES option
- property Vector.nodet: int¶
Node ID for tail of vector (for _NODES option)
- property Vector.vid: integer¶
Vector
number. Also see thelabel
property which is an alternative name for this
- property Vector.xh: float¶
X coordinate of head of vector
- property Vector.xt: float¶
X coordinate of tail of vector
- property Vector.yh: float¶
Y coordinate of head of vector
- property Vector.yt: float¶
Y coordinate of tail of vector
- property Vector.zh: float¶
Z coordinate of head of vector
- property Vector.zt: float¶
Z coordinate of tail vector
Constructor¶
- classmethod Vector(model, options)¶
Create a new
Vector
object
- Parameters:
model (Model) –
Model
that vector will be created inoptions (dict) –
Options for creating the
Vector
- ch (optional):
(array) List of coordinates of head of vector [
xh
,yh
,zh
] (for *DEFINE_VECTOR)- cid (optional):
(int) Optional coordinate system ID (for *DEFINE_VECTOR)
- ct (optional):
(array) List of coordinates of tail of vector [
xt
,yt
,zt
] (for *DEFINE_VECTOR)- heading (optional):
(string) Optional title for the vector
- nodeh (optional):
(integer)
Node
ID for head of vector (for *DEFINE_VECTOR_NODES)- nodes:
(boolean) _NODES option (true for *DEFINE_VECTOR_NODES, false for *DEFINE_VECTOR)
- nodet (optional):
(integer)
Node
ID for tail of vector (for *DEFINE_VECTOR_NODES)- vid:
(integer)
Vector
ID- Returns:
Vector object
- Return type:
dict
Example
To create a new *DEFINE_VECTOR in model m with label 100 with the tail at (1.5, 2.5, 1.0) and the head at (4.5, 4.0, 3.0)
v = Oasys.PRIMER.Vector(m, {'nodes': 0, 'vid': 100, 'ct': [1.5, 2.5, 1.0], 'ch': [4.5, 4.0, 3.0]})To create a new *DEFINE_VECTOR_NODES in model m with label 200 using node 10 for the tail and node 20 for the head
v = Oasys.PRIMER.Vector(m, {'nodes': 1, 'vid': 200, 'nodet': 10, 'nodeh': 20})
Static methods¶
- classmethod Vector.BlankAll(model, redraw=Oasys.gRPC.defaultArg)¶
Blanks all of the vectors in the model
- Parameters:
model (Model) –
Model
that all vectors 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 vectors in model m:
Oasys.PRIMER.Vector.BlankAll(m)
- classmethod Vector.BlankFlagged(model, flag, redraw=Oasys.gRPC.defaultArg)¶
Blanks all of the flagged vectors in the model
- Parameters:
model (Model) –
Model
that all the flagged vectors will be blanked inflag (Flag) – Flag set on the vectors 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 vectors in model m flagged with f:
Oasys.PRIMER.Vector.BlankFlagged(m, f)
- classmethod Vector.Create(model, modal=Oasys.gRPC.defaultArg)¶
Starts an interactive editing panel to create a vector
- Parameters:
model (Model) –
Model
that the vector 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:
Vector object (or None if not made)
- Return type:
dict
Example
To start creating a vector in model m:
m = Oasys.PRIMER.Vector.Create(m)
- classmethod Vector.First(model)¶
Returns the first vector in the model
- Parameters:
model (Model) –
Model
to get first vector in- Returns:
Vector object (or None if there are no vectors in the model)
- Return type:
Vector
Example
To get the first vector in model m:
v = Oasys.PRIMER.Vector.First(m)
- classmethod Vector.FirstFreeLabel(model, layer=Oasys.gRPC.defaultArg)¶
Returns the first free vector label in the model. Also see
Vector.LastFreeLabel()
,Vector.NextFreeLabel()
andModel.FirstFreeItemLabel()
- Parameters:
- Returns:
Vector label
- Return type:
int
Example
To get the first free vector label in model m:
label = Oasys.PRIMER.Vector.FirstFreeLabel(m)
- classmethod Vector.FlagAll(model, flag)¶
Flags all of the vectors in the model with a defined flag
- Parameters:
model (Model) –
Model
that all vectors will be flagged inflag (Flag) – Flag to set on the vectors
- Returns:
No return value
- Return type:
None
Example
To flag all of the vectors with flag f in model m:
Oasys.PRIMER.Vector.FlagAll(m, f)
- classmethod Vector.GetAll(model)¶
Returns a list of Vector objects for all of the vectors in a model in PRIMER
- Parameters:
model (Model) –
Model
to get vectors from- Returns:
List of Vector objects
- Return type:
list
Example
To make a list of Vector objects for all of the vectors in model m
v = Oasys.PRIMER.Vector.GetAll(m)
- classmethod Vector.GetFlagged(model, flag)¶
Returns a list of Vector objects for all of the flagged vectors in a model in PRIMER
- Parameters:
model (Model) –
Model
to get vectors fromflag (Flag) – Flag set on the vectors that you want to retrieve
- Returns:
List of Vector objects
- Return type:
list
Example
To make a list of Vector objects for all of the vectors in model m flagged with f
v = Oasys.PRIMER.Vector.GetFlagged(m, f)
- classmethod Vector.GetFromID(model, number)¶
Returns the Vector object for a vector ID
- Parameters:
model (Model) –
Model
to find the vector innumber (integer) – number of the vector you want the Vector object for
- Returns:
Vector object (or None if vector does not exist)
- Return type:
Vector
Example
To get the Vector object for vector 100 in model m
v = Oasys.PRIMER.Vector.GetFromID(m, 100)
- classmethod Vector.Last(model)¶
Returns the last vector in the model
- Parameters:
model (Model) –
Model
to get last vector in- Returns:
Vector object (or None if there are no vectors in the model)
- Return type:
Vector
Example
To get the last vector in model m:
v = Oasys.PRIMER.Vector.Last(m)
- classmethod Vector.LastFreeLabel(model, layer=Oasys.gRPC.defaultArg)¶
Returns the last free vector label in the model. Also see
Vector.FirstFreeLabel()
,Vector.NextFreeLabel()
and seeModel.LastFreeItemLabel()
- Parameters:
- Returns:
Vector label
- Return type:
int
Example
To get the last free vector label in model m:
label = Oasys.PRIMER.Vector.LastFreeLabel(m)
- classmethod Vector.NextFreeLabel(model, layer=Oasys.gRPC.defaultArg)¶
Returns the next free (highest+1) vector label in the model. Also see
Vector.FirstFreeLabel()
,Vector.LastFreeLabel()
andModel.NextFreeItemLabel()
- Parameters:
- Returns:
Vector label
- Return type:
int
Example
To get the next free vector label in model m:
label = Oasys.PRIMER.Vector.NextFreeLabel(m)
- classmethod Vector.Pick(prompt, limit=Oasys.gRPC.defaultArg, modal=Oasys.gRPC.defaultArg, button_text=Oasys.gRPC.defaultArg)¶
Allows the user to pick a vector
- 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 vectors from that model can be picked. If the argument is aFlag
then only vectors that are flagged with limit can be selected. If omitted, or None, any vectors 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:
Vector object (or None if not picked)
- Return type:
dict
Example
To pick a vector from model m giving the prompt ‘Pick vector from screen’:
v = Oasys.PRIMER.Vector.Pick('Pick vector from screen', m)
- classmethod Vector.RenumberAll(model, start)¶
Renumbers all of the vectors in the model
- Parameters:
model (Model) –
Model
that all vectors will be renumbered instart (integer) – Start point for renumbering
- Returns:
No return value
- Return type:
None
Example
To renumber all of the vectors in model m, from 1000000:
Oasys.PRIMER.Vector.RenumberAll(m, 1000000)
- classmethod Vector.RenumberFlagged(model, flag, start)¶
Renumbers all of the flagged vectors in the model
- Parameters:
model (Model) –
Model
that all the flagged vectors will be renumbered inflag (Flag) – Flag set on the vectors that you want to renumber
start (integer) – Start point for renumbering
- Returns:
No return value
- Return type:
None
Example
To renumber all of the vectors in model m flagged with f, from 1000000:
Oasys.PRIMER.Vector.RenumberFlagged(m, f, 1000000)
- classmethod Vector.Select(flag, prompt, limit=Oasys.gRPC.defaultArg, modal=Oasys.gRPC.defaultArg)¶
Allows the user to select vectors using standard PRIMER object menus
- Parameters:
flag (Flag) – Flag to use when selecting vectors
prompt (string) – Text to display as a prompt to the user
limit (Model or Flag) – Optional. If the argument is a
Model
then only vectors from that model can be selected. If the argument is aFlag
then only vectors that are flagged with limit can be selected (limit should be different to flag). If omitted, or None, any vectors 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 vectors selected or None if menu cancelled
- Return type:
int
Example
To select vectors from model m, flagging those selected with flag f, giving the prompt ‘Select vectors’:
Oasys.PRIMER.Vector.Select(f, 'Select vectors', m)To select vectors, flagging those selected with flag f but limiting selection to vectors flagged with flag l, giving the prompt ‘Select vectors’:
Oasys.PRIMER.Vector.Select(f, 'Select vectors', l)
- classmethod Vector.SketchFlagged(model, flag, redraw=Oasys.gRPC.defaultArg)¶
Sketches all of the flagged vectors in the model. The vectors will be sketched until you either call
Vector.Unsketch()
,Vector.UnsketchFlagged()
,Model.UnsketchAll()
, or delete the model
- Parameters:
model (Model) –
Model
that all the flagged vectors will be sketched inflag (Flag) – Flag set on the vectors that you want to sketch
redraw (boolean) – Optional. If model should be redrawn or not after the vectors are sketched. If omitted redraw is true. If you want to sketch flagged vectors 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 vectors flagged with flag in model m:
Oasys.PRIMER.Vector.SketchFlagged(m, flag)
- classmethod Vector.Total(model, exists=Oasys.gRPC.defaultArg)¶
Returns the total number of vectors in the model
- Parameters:
model (Model) –
Model
to get total forexists (boolean) – Optional. true if only existing vectors should be counted. If false or omitted referenced but undefined vectors will also be included in the total
- Returns:
number of vectors
- Return type:
int
Example
To get the total number of vectors in model m:
total = Oasys.PRIMER.Vector.Total(m)
- classmethod Vector.UnblankAll(model, redraw=Oasys.gRPC.defaultArg)¶
Unblanks all of the vectors in the model
- Parameters:
model (Model) –
Model
that all vectors 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 vectors in model m:
Oasys.PRIMER.Vector.UnblankAll(m)
- classmethod Vector.UnblankFlagged(model, flag, redraw=Oasys.gRPC.defaultArg)¶
Unblanks all of the flagged vectors in the model
- Parameters:
model (Model) –
Model
that the flagged vectors will be unblanked inflag (Flag) – Flag set on the vectors 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 vectors in model m flagged with f:
Oasys.PRIMER.Vector.UnblankFlagged(m, f)
- classmethod Vector.UnflagAll(model, flag)¶
Unsets a defined flag on all of the vectors in the model
- Parameters:
model (Model) –
Model
that the defined flag for all vectors will be unset inflag (Flag) – Flag to unset on the vectors
- Returns:
No return value
- Return type:
None
Example
To unset the flag f on all the vectors in model m:
Oasys.PRIMER.Vector.UnflagAll(m, f)
- classmethod Vector.UnsketchAll(model, redraw=Oasys.gRPC.defaultArg)¶
Unsketches all vectors
- Parameters:
model (Model) –
Model
that all vectors will be unblanked inredraw (boolean) – Optional. If model should be redrawn or not after the vectors 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 vectors in model m:
Oasys.PRIMER.Vector.UnsketchAll(m)
- classmethod Vector.UnsketchFlagged(model, flag, redraw=Oasys.gRPC.defaultArg)¶
Unsketches all flagged vectors in the model
- Parameters:
model (Model) –
Model
that all vectors will be unsketched inflag (Flag) – Flag set on the vectors that you want to unsketch
redraw (boolean) – Optional. If model should be redrawn or not after the vectors 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 vectors flagged with flag in model m:
Oasys.PRIMER.Vector.UnsketchAll(m, flag)
Instance methods¶
- Vector.AssociateComment(comment)¶
Associates a comment with a vector
- Parameters:
comment (Comment) –
Comment
that will be attached to the vector- Returns:
No return value
- Return type:
None
Example
To associate comment c to the vector v:
v.AssociateComment(c)
- Vector.Blank()¶
Blanks the vector
- Returns:
No return value
- Return type:
None
Example
To blank vector v:
v.Blank()
- Vector.Blanked()¶
Checks if the vector is blanked or not
- Returns:
True if blanked, False if not
- Return type:
bool
Example
To check if vector v is blanked:
if v.Blanked(): do_something..
- Vector.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 vector v:
v.Browse()
- Vector.ClearFlag(flag)¶
Clears a flag on the vector
- Parameters:
flag (Flag) – Flag to clear on the vector
- Returns:
No return value
- Return type:
None
Example
To clear flag f for vector v:
v.ClearFlag(f)
- Vector.Copy(range=Oasys.gRPC.defaultArg)¶
Copies the vector. The target include of the copied vector 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:
Vector object
- Return type:
Vector
Example
To copy vector v into vector z:
z = v.Copy()
- Vector.DetachComment(comment)¶
Detaches a comment from a vector
- Parameters:
comment (Comment) –
Comment
that will be detached from the vector- Returns:
No return value
- Return type:
None
Example
To detach comment c from the vector v:
v.DetachComment(c)
- Vector.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 vector v:
v.Edit()
- Vector.Flagged(flag)¶
Checks if the vector is flagged or not
- Parameters:
flag (Flag) – Flag to test on the vector
- Returns:
True if flagged, False if not
- Return type:
bool
Example
To check if vector v has flag f set on it:
if v.Flagged(f): do_something..
- Vector.GetComments()¶
Extracts the comments associated to a vector
- 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 vector v:
comm_list = v.GetComments()
- Vector.GetParameter(prop)¶
Checks if a Vector 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 theVector.ViewParameters()
method and ‘method chaining’ (see the examples below)
- Parameters:
prop (string) – vector property to get parameter for
- Returns:
Parameter object if property is a parameter, None if not
- Return type:
dict
Example
To check if Vector property v.example is a parameter:
Oasys.PRIMER.Options.property_parameter_names = True if v.GetParameter(v.example): do_something... Oasys.PRIMER.Options.property_parameter_names = FalseTo check if Vector property v.example is a parameter by using the GetParameter method:
if v.ViewParameters().GetParameter(v.example): do_something..
- Vector.Keyword()¶
Returns the keyword for this vector (*DEFINE_VECTOR). Note that a carriage return is not added. See also
Vector.KeywordCards()
- Returns:
string containing the keyword
- Return type:
str
Example
To get the keyword for vector m:
key = m.Keyword()
- Vector.KeywordCards()¶
Returns the keyword cards for the vector. Note that a carriage return is not added. See also
Vector.Keyword()
- Returns:
string containing the cards
- Return type:
str
Example
To get the cards for vector v:
cards = v.KeywordCards()
- Vector.Next()¶
Returns the next vector in the model
- Returns:
Vector object (or None if there are no more vectors in the model)
- Return type:
Vector
Example
To get the vector in model m after vector v:
v = v.Next()
- Vector.Previous()¶
Returns the previous vector in the model
- Returns:
Vector object (or None if there are no more vectors in the model)
- Return type:
Vector
Example
To get the vector in model m before vector v:
v = v.Previous()
- Vector.SetFlag(flag)¶
Sets a flag on the vector
- Parameters:
flag (Flag) – Flag to set on the vector
- Returns:
No return value
- Return type:
None
Example
To set flag f for vector v:
v.SetFlag(f)
- Vector.Sketch(redraw=Oasys.gRPC.defaultArg)¶
Sketches the vector. The vector will be sketched until you either call
Vector.Unsketch()
,Vector.UnsketchAll()
,Model.UnsketchAll()
, or delete the model
- Parameters:
redraw (boolean) – Optional. If model should be redrawn or not after the vector is sketched. If omitted redraw is true. If you want to sketch several vectors 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 vector v:
v.Sketch()
- Vector.Unblank()¶
Unblanks the vector
- Returns:
No return value
- Return type:
None
Example
To unblank vector v:
v.Unblank()
- Vector.Unsketch(redraw=Oasys.gRPC.defaultArg)¶
Unsketches the vector
- Parameters:
redraw (boolean) – Optional. If model should be redrawn or not after the vector is unsketched. If omitted redraw is true. If you want to unsketch several vectors 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 vector v:
v.Unsketch()
- Vector.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:
Vector object
- Return type:
dict
Example
To check if Vector property v.example is a parameter by using the
Vector.GetParameter()
method:if v.ViewParameters().GetParameter(v.example): do_something..
- Vector.Xrefs()¶
Returns the cross references for this vector
- Returns:
Xrefs object
- Return type:
dict
Example
To get the cross references for vector v:
xrefs = v.Xrefs()