Oasys.PRIMER.Mechanism class¶
Constants¶
Connection types¶
Coupler modes¶
Properties¶
- property Mechanism.assemblies(read only): integer¶
Number of assemblies defined
- property Mechanism.connections(read only): integer¶
Number of connections defined
- property Mechanism.exists(read only): boolean¶
true if mechanism exists, false if referred to but not defined
- property Mechanism.id(read only): integer¶
Mechanism
number. Also see thelabel
property which is an alternative name for this
- property Mechanism.label(read only): integer¶
Mechanism
number. Also see theid
property which is an alternative name for this
- property Mechanism.points(read only): integer¶
Number of reference points defined
- property Mechanism.title: string¶
Mechanism
title
Static methods¶
- classmethod Mechanism.BlankAll(model, redraw=Oasys.gRPC.defaultArg)¶
Blanks all of the mechanisms in the model
- Parameters:
model (Model) –
Model
that all mechanisms 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 mechanisms in model m:
Oasys.PRIMER.Mechanism.BlankAll(m)
- classmethod Mechanism.BlankFlagged(model, flag, redraw=Oasys.gRPC.defaultArg)¶
Blanks all of the flagged mechanisms in the model
- Parameters:
model (Model) –
Model
that all the flagged mechanisms will be blanked inflag (Flag) – Flag set on the mechanisms 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 mechanisms in model m flagged with f:
Oasys.PRIMER.Mechanism.BlankFlagged(m, f)
- classmethod Mechanism.First(model)¶
Returns the first mechanism in the model
- Parameters:
model (Model) –
Model
to get first mechanism in- Returns:
Mechanism object (or None if there are no mechanisms in the model)
- Return type:
Mechanism
Example
To get the first mechanism in model m:
m = Oasys.PRIMER.Mechanism.First(m)
- classmethod Mechanism.FirstFreeLabel(model, layer=Oasys.gRPC.defaultArg)¶
Returns the first free mechanism label in the model. Also see
Mechanism.LastFreeLabel()
,Mechanism.NextFreeLabel()
andModel.FirstFreeItemLabel()
- Parameters:
- Returns:
Mechanism label
- Return type:
int
Example
To get the first free mechanism label in model m:
label = Oasys.PRIMER.Mechanism.FirstFreeLabel(m)
- classmethod Mechanism.FlagAll(model, flag)¶
Flags all of the mechanisms in the model with a defined flag
- Parameters:
model (Model) –
Model
that all mechanisms will be flagged inflag (Flag) – Flag to set on the mechanisms
- Returns:
No return value
- Return type:
None
Example
To flag all of the mechanisms with flag f in model m:
Oasys.PRIMER.Mechanism.FlagAll(m, f)
- classmethod Mechanism.GetAll(model)¶
Returns a list of Mechanism objects for all of the mechanisms in a model in PRIMER
- Parameters:
model (Model) –
Model
to get mechanisms from- Returns:
List of Mechanism objects
- Return type:
list
Example
To make a list of Mechanism objects for all of the mechanisms in model m
m = Oasys.PRIMER.Mechanism.GetAll(m)
- classmethod Mechanism.GetFlagged(model, flag)¶
Returns a list of Mechanism objects for all of the flagged mechanisms in a model in PRIMER
- Parameters:
model (Model) –
Model
to get mechanisms fromflag (Flag) – Flag set on the mechanisms that you want to retrieve
- Returns:
List of Mechanism objects
- Return type:
list
Example
To make a list of Mechanism objects for all of the mechanisms in model m flagged with f
m = Oasys.PRIMER.Mechanism.GetFlagged(m, f)
- classmethod Mechanism.GetFromID(model, number)¶
Returns the Mechanism object for a mechanism ID
- Parameters:
model (Model) –
Model
to find the mechanism innumber (integer) – number of the mechanism you want the Mechanism object for
- Returns:
Mechanism object (or None if mechanism does not exist)
- Return type:
Mechanism
Example
To get the Mechanism object for mechanism 100 in model m
m = Oasys.PRIMER.Mechanism.GetFromID(m, 100)
- classmethod Mechanism.Last(model)¶
Returns the last mechanism in the model
- Parameters:
model (Model) –
Model
to get last mechanism in- Returns:
Mechanism object (or None if there are no mechanisms in the model)
- Return type:
Mechanism
Example
To get the last mechanism in model m:
m = Oasys.PRIMER.Mechanism.Last(m)
- classmethod Mechanism.LastFreeLabel(model, layer=Oasys.gRPC.defaultArg)¶
Returns the last free mechanism label in the model. Also see
Mechanism.FirstFreeLabel()
,Mechanism.NextFreeLabel()
and seeModel.LastFreeItemLabel()
- Parameters:
- Returns:
Mechanism label
- Return type:
int
Example
To get the last free mechanism label in model m:
label = Oasys.PRIMER.Mechanism.LastFreeLabel(m)
- classmethod Mechanism.NextFreeLabel(model, layer=Oasys.gRPC.defaultArg)¶
Returns the next free (highest+1) mechanism label in the model. Also see
Mechanism.FirstFreeLabel()
,Mechanism.LastFreeLabel()
andModel.NextFreeItemLabel()
- Parameters:
- Returns:
Mechanism label
- Return type:
int
Example
To get the next free mechanism label in model m:
label = Oasys.PRIMER.Mechanism.NextFreeLabel(m)
- classmethod Mechanism.Pick(prompt, limit=Oasys.gRPC.defaultArg, modal=Oasys.gRPC.defaultArg, button_text=Oasys.gRPC.defaultArg)¶
Allows the user to pick a mechanism
- 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 mechanisms from that model can be picked. If the argument is aFlag
then only mechanisms that are flagged with limit can be selected. If omitted, or None, any mechanisms 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:
Mechanism object (or None if not picked)
- Return type:
dict
Example
To pick a mechanism from model m giving the prompt ‘Pick mechanism from screen’:
m = Oasys.PRIMER.Mechanism.Pick('Pick mechanism from screen', m)
- classmethod Mechanism.RenumberAll(model, start)¶
Renumbers all of the mechanisms in the model
- Parameters:
model (Model) –
Model
that all mechanisms will be renumbered instart (integer) – Start point for renumbering
- Returns:
No return value
- Return type:
None
Example
To renumber all of the mechanisms in model m, from 1000000:
Oasys.PRIMER.Mechanism.RenumberAll(m, 1000000)
- classmethod Mechanism.RenumberFlagged(model, flag, start)¶
Renumbers all of the flagged mechanisms in the model
- Parameters:
model (Model) –
Model
that all the flagged mechanisms will be renumbered inflag (Flag) – Flag set on the mechanisms that you want to renumber
start (integer) – Start point for renumbering
- Returns:
No return value
- Return type:
None
Example
To renumber all of the mechanisms in model m flagged with f, from 1000000:
Oasys.PRIMER.Mechanism.RenumberFlagged(m, f, 1000000)
- classmethod Mechanism.Select(flag, prompt, limit=Oasys.gRPC.defaultArg, modal=Oasys.gRPC.defaultArg)¶
Allows the user to select mechanisms using standard PRIMER object menus
- Parameters:
flag (Flag) – Flag to use when selecting mechanisms
prompt (string) – Text to display as a prompt to the user
limit (Model or Flag) – Optional. If the argument is a
Model
then only mechanisms from that model can be selected. If the argument is aFlag
then only mechanisms that are flagged with limit can be selected (limit should be different to flag). If omitted, or None, any mechanisms 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 mechanisms selected or None if menu cancelled
- Return type:
int
Example
To select mechanisms from model m, flagging those selected with flag f, giving the prompt ‘Select mechanisms’:
Oasys.PRIMER.Mechanism.Select(f, 'Select mechanisms', m)To select mechanisms, flagging those selected with flag f but limiting selection to mechanisms flagged with flag l, giving the prompt ‘Select mechanisms’:
Oasys.PRIMER.Mechanism.Select(f, 'Select mechanisms', l)
- classmethod Mechanism.SketchFlagged(model, flag, redraw=Oasys.gRPC.defaultArg)¶
Sketches all of the flagged mechanisms in the model. The mechanisms will be sketched until you either call
Mechanism.Unsketch()
,Mechanism.UnsketchFlagged()
,Model.UnsketchAll()
, or delete the model
- Parameters:
model (Model) –
Model
that all the flagged mechanisms will be sketched inflag (Flag) – Flag set on the mechanisms that you want to sketch
redraw (boolean) – Optional. If model should be redrawn or not after the mechanisms are sketched. If omitted redraw is true. If you want to sketch flagged mechanisms 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 mechanisms flagged with flag in model m:
Oasys.PRIMER.Mechanism.SketchFlagged(m, flag)
- classmethod Mechanism.Total(model, exists=Oasys.gRPC.defaultArg)¶
Returns the total number of mechanisms in the model
- Parameters:
model (Model) –
Model
to get total forexists (boolean) – Optional. true if only existing mechanisms should be counted. If false or omitted referenced but undefined mechanisms will also be included in the total
- Returns:
number of mechanisms
- Return type:
int
Example
To get the total number of mechanisms in model m:
total = Oasys.PRIMER.Mechanism.Total(m)
- classmethod Mechanism.UnblankAll(model, redraw=Oasys.gRPC.defaultArg)¶
Unblanks all of the mechanisms in the model
- Parameters:
model (Model) –
Model
that all mechanisms 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 mechanisms in model m:
Oasys.PRIMER.Mechanism.UnblankAll(m)
- classmethod Mechanism.UnblankFlagged(model, flag, redraw=Oasys.gRPC.defaultArg)¶
Unblanks all of the flagged mechanisms in the model
- Parameters:
model (Model) –
Model
that the flagged mechanisms will be unblanked inflag (Flag) – Flag set on the mechanisms 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 mechanisms in model m flagged with f:
Oasys.PRIMER.Mechanism.UnblankFlagged(m, f)
- classmethod Mechanism.UnflagAll(model, flag)¶
Unsets a defined flag on all of the mechanisms in the model
- Parameters:
model (Model) –
Model
that the defined flag for all mechanisms will be unset inflag (Flag) – Flag to unset on the mechanisms
- Returns:
No return value
- Return type:
None
Example
To unset the flag f on all the mechanisms in model m:
Oasys.PRIMER.Mechanism.UnflagAll(m, f)
- classmethod Mechanism.UnsketchAll(model, redraw=Oasys.gRPC.defaultArg)¶
Unsketches all mechanisms
- Parameters:
model (Model) –
Model
that all mechanisms will be unblanked inredraw (boolean) – Optional. If model should be redrawn or not after the mechanisms 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 mechanisms in model m:
Oasys.PRIMER.Mechanism.UnsketchAll(m)
- classmethod Mechanism.UnsketchFlagged(model, flag, redraw=Oasys.gRPC.defaultArg)¶
Unsketches all flagged mechanisms in the model
- Parameters:
model (Model) –
Model
that all mechanisms will be unsketched inflag (Flag) – Flag set on the mechanisms that you want to unsketch
redraw (boolean) – Optional. If model should be redrawn or not after the mechanisms 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 mechanisms flagged with flag in model m:
Oasys.PRIMER.Mechanism.UnsketchAll(m, flag)
Instance methods¶
- Mechanism.AddNodeSetToAssembly(index, nsid)¶
Add node set to assembly
- Parameters:
index (integer) – The index of the assembly in which you want to add node set. Note that reference points start at 0, not 1. 0 <= index <
assemblies
nsid (integer) – The node set ID that you want to add
- Returns:
No return value
- Return type:
None
Example
To add node set 3 in 3rd assembly in mechanism m:
m.AddNodeSetToAssembly(2,3)
- Mechanism.AddPartSetToAssembly(index, psid)¶
Add part set to assembly
- Parameters:
index (integer) – The index of the assembly in which you want to add part set. Note that reference points start at 0, not 1. 0 <= index <
assemblies
psid (integer) – The part set ID that you want to add
- Returns:
No return value
- Return type:
None
Example
To add part set 3 in 3rd assembly in mechanism m:
m.AddPartSetToAssembly(2,3)
- Mechanism.AddPartToAssembly(index, pid)¶
Add part to assembly
- Parameters:
index (integer) – The index of the assembly in which you want to add part. Note that reference points start at 0, not 1. 0 <= index <
assemblies
pid (integer) – The part ID that you want to add
- Returns:
No return value
- Return type:
None
Example
To add part 3 in 3rd assembly in mechanism m:
m.AddPartToAssembly(2,3)
- Mechanism.AssociateComment(comment)¶
Associates a comment with a mechanism
- Parameters:
comment (Comment) –
Comment
that will be attached to the mechanism- Returns:
No return value
- Return type:
None
Example
To associate comment c to the mechanism m:
m.AssociateComment(c)
- Mechanism.Blank()¶
Blanks the mechanism
- Returns:
No return value
- Return type:
None
Example
To blank mechanism m:
m.Blank()
- Mechanism.Blanked()¶
Checks if the mechanism is blanked or not
- Returns:
True if blanked, False if not
- Return type:
bool
Example
To check if mechanism m is blanked:
if m.Blanked(): do_something..
- Mechanism.ClearFlag(flag)¶
Clears a flag on the mechanism
- Parameters:
flag (Flag) – Flag to clear on the mechanism
- Returns:
No return value
- Return type:
None
Example
To clear flag f for mechanism m:
m.ClearFlag(f)
- Mechanism.Copy(range=Oasys.gRPC.defaultArg)¶
Copies the mechanism. The target include of the copied mechanism 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:
Mechanism object
- Return type:
Mechanism
Example
To copy mechanism m into mechanism z:
z = m.Copy()
- Mechanism.DetachComment(comment)¶
Detaches a comment from a mechanism
- Parameters:
comment (Comment) –
Comment
that will be detached from the mechanism- Returns:
No return value
- Return type:
None
Example
To detach comment c from the mechanism m:
m.DetachComment(c)
- Mechanism.Flagged(flag)¶
Checks if the mechanism is flagged or not
- Parameters:
flag (Flag) – Flag to test on the mechanism
- Returns:
True if flagged, False if not
- Return type:
bool
Example
To check if mechanism m has flag f set on it:
if m.Flagged(f): do_something..
- Mechanism.GetAssembly(index)¶
Returns the information for an assembly
- Parameters:
index (integer) – The index of the assembly you want the coordinates for. Note that reference points start at 0, not 1. 0 <= index <
assemblies
- Returns:
Dict with properties
- label:
(integer) Assembly label
- parent:
(integer) Parent assembly label
- title:
(string) Assembly title
- Return type:
dict
Example
To get the information for the 3rd assembly for mechanism m:
info = m.GetAssembly(2)
- Mechanism.GetComments()¶
Extracts the comments associated to a mechanism
- 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 mechanism m:
comm_list = m.GetComments()
- Mechanism.GetConnection(index)¶
Returns the information for a connection
- Parameters:
index (integer) – The index of the connection you want the information for. Note that connections start at 0, not 1. 0 <= index <
connections
- Returns:
Dict with properties
- angle:
(real) Current angle in degrees (for
Mechanism.LINE
andMechanism.HINGE
)- assembly1:
(integer) Assembly 1 label
- assembly2:
(integer) Assembly 2 label
- assembly3:
(integer) Assembly 3 label
- coefficient1:
(real) Coefficient for linear coupler equation for connection 1 (for
Mechanism.COUPLER
)- coefficient2:
(real) Coefficient for linear coupler equation for connection 2 (for
Mechanism.COUPLER
)- coefficient3:
(real) Coefficient for linear coupler equation for connection 3 (for
Mechanism.COUPLER
)- connection1:
(integer) Connection 1 label (for
Mechanism.COUPLER
)- connection2:
(integer) Connection 2 label (for
Mechanism.COUPLER
)- connection3:
(integer) Connection 3 label (for
Mechanism.COUPLER
)- distance:
(real) Current distance (for
Mechanism.LINE
)- factor1:
(real) Factor 1 on Assembly 3 (
Mechanism.LINE
only)- factor2:
(real) Factor 2 on Assembly 3 (
Mechanism.LINE
only)- label:
(integer) Connection label
- locked:
(integer) 1 if locked (for
Mechanism.LINE
,Mechanism.PIN
andMechanism.HINGE
)- mode1:
(integer) Coupling mode for connection 1. 0 = translational coupling, 1 = rotational coupling (for
Mechanism.COUPLER
)- mode2:
(integer) Coupling mode for connection 2. 0 = translational coupling, 1 = rotational coupling (for
Mechanism.COUPLER
)- mode3:
(integer) Coupling mode for connection 3. 0 = translational coupling, 1 = rotational coupling (for
Mechanism.COUPLER
)- node1:
(integer) Node 1 label (for
Mechanism.LINE
,Mechanism.PIN
andMechanism.HINGE
)- node2:
(integer) Node 2 label (for
Mechanism.LINE
,Mechanism.PIN
andMechanism.HINGE
)- nrotation:
(real) -ve rotation limit in degrees (for
Mechanism.LINE
andMechanism.HINGE
)- nslide:
(real) -ve slide translation (for
Mechanism.LINE
)- protation:
(real) +ve rotation limit in degrees (for
Mechanism.LINE
andMechanism.HINGE
)- pslide:
(real) +ve slide translation (for
Mechanism.LINE
)- title:
(string) Connection label
- type:
(integer) Mechanism type (
Mechanism.COUPLER
,Mechanism.HINGE
,Mechanism.LINE
,Mechanism.PIN
)- x1:
(real) X1 coordinates (for
Mechanism.LINE
,Mechanism.PIN
andMechanism.HINGE
)- x2:
(real) X2 coordinates (for
Mechanism.LINE
,Mechanism.PIN
andMechanism.HINGE
)- y1:
(real) Y1 coordinates (for
Mechanism.LINE
,Mechanism.PIN
andMechanism.HINGE
)- y2:
(real) Y2 coordinates (for
Mechanism.LINE
,Mechanism.PIN
andMechanism.HINGE
)- z1:
(real) Z1 coordinates (for
Mechanism.LINE
,Mechanism.PIN
andMechanism.HINGE
)- z2:
(real) Z2 coordinates (for
Mechanism.LINE
,Mechanism.PIN
andMechanism.HINGE
)- Return type:
dict
Example
To get the information for the 3rd connection for mechanism m:
info = m.GetConnection(2)
- Mechanism.GetParameter(prop)¶
Checks if a Mechanism 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 theMechanism.ViewParameters()
method and ‘method chaining’ (see the examples below)
- Parameters:
prop (string) – mechanism property to get parameter for
- Returns:
Parameter object if property is a parameter, None if not
- Return type:
dict
Example
To check if Mechanism property m.example is a parameter:
Oasys.PRIMER.Options.property_parameter_names = True if m.GetParameter(m.example): do_something... Oasys.PRIMER.Options.property_parameter_names = FalseTo check if Mechanism property m.example is a parameter by using the GetParameter method:
if m.ViewParameters().GetParameter(m.example): do_something..
- Mechanism.GetPoint(index)¶
Returns the information for a reference point
- Parameters:
index (integer) – The index of the reference point you want the information for. Note that reference points start at 0, not 1. 0 <= index <
points
- Returns:
Dict with properties
- assembly:
(integer) Assembly label
- csys:
(integer) Coordinate system
- hpt:
(boolean) If point has been automatically created by PRIMER at the H-point
- label:
(integer) Point label
- node:
(integer) Node label (0 if coordinate)
- rx:
(boolean) Point restrained rotationally in X
- ry:
(boolean) Point restrained rotationally in Y
- rz:
(boolean) Point restrained rotationally in Z
- title:
(string) Point title
- tx:
(boolean) Point restrained translationally in X
- ty:
(boolean) Point restrained translationally in Y
- tz:
(boolean) Point restrained translationally in Z
- x:
(real) Node/point x coordinate
- y:
(real) Node/point y coordinate
- z:
(real) Node/point z coordinate
- Return type:
dict
Example
To get the information for the 3rd reference point for mechanism m:
info = m.GetPoint(2)
- Mechanism.GetPointData(rpt)¶
Returns the coordinates of a reference point
- Parameters:
rpt (integer) – The reference point you want the coordinates for. Note that reference points start at 0, not 1
- Returns:
List containing the reference point coordinates
- Return type:
list
Example
To get the coordinates of the 3rd reference point for mechanism mec:
c = mec.GetPointData(2)
- Mechanism.GetPointTitle(rpt)¶
Returns the title of a reference point
- Parameters:
rpt (integer) – The reference point you want the title for. Note that reference points start at 0, not 1
- Returns:
The reference point title
- Return type:
str
Example
To get the title of the 3rd reference point for mechanism mec:
c = mec.GetPointTitle(2)
- Mechanism.Next()¶
Returns the next mechanism in the model
- Returns:
Mechanism object (or None if there are no more mechanisms in the model)
- Return type:
Mechanism
Example
To get the mechanism in model m after mechanism m:
m = m.Next()
- Mechanism.Previous()¶
Returns the previous mechanism in the model
- Returns:
Mechanism object (or None if there are no more mechanisms in the model)
- Return type:
Mechanism
Example
To get the mechanism in model m before mechanism m:
m = m.Previous()
- Mechanism.RemoveConnection(index)¶
Removes a connection from a mechanism
- Parameters:
index (integer) – The index of the connection you want to remove. Note that connections start at 0, not 1. 0 <= index <
connections
- Returns:
no return value
- Return type:
None
Example
To remove the 3rd connection for mechanism m:
m.RemoveConnection(2)
- Mechanism.RemoveNodeSetFromAssembly(index, nsid)¶
Remove node set from assembly
- Parameters:
index (integer) – The index of the assembly from which you want to remove the node set. Note that reference points start at 0, not 1. 0 <= index <
assemblies
nsid (integer) – The node set ID that you want to remove
- Returns:
No return value
- Return type:
None
Example
To remove node set 3 from 3rd assembly in mechanism m:
m.RemoveNodeSetFromAssembly(2,3)
- Mechanism.RemovePartFromAssembly(index, pid)¶
Remove part from assembly
- Parameters:
index (integer) – The index of the assembly from which you want to remove the part. Note that reference points start at 0, not 1. 0 <= index <
assemblies
pid (integer) – The part ID that you want to remove
- Returns:
No return value
- Return type:
None
Example
To remove part 3 from 3rd assembly in mechanism m:
m.RemovePartFromAssembly(2,3)
- Mechanism.RemovePartSetFromAssembly(index, psid)¶
Remove part set from assembly
- Parameters:
index (integer) – The index of the assembly from which you want to remove the part set. Note that reference points start at 0, not 1. 0 <= index <
assemblies
psid (integer) – The part set ID that you want to remove
- Returns:
No return value
- Return type:
None
Example
To remove part set 3 from 3rd assembly in mechanism m:
m.RemovePartSetFromAssembly(2,3)
- Mechanism.RemovePoint(index)¶
Removes a reference point from a mechanism
- Parameters:
index (integer) – The index of the reference point you want to remove. Note that reference points start at 0, not 1. 0 <= index <
points
- Returns:
no return value
- Return type:
None
Example
To remove the 3rd reference point for mechanism m:
m.RemovePoint(2)
- Mechanism.SetConnection(index, data)¶
Sets the data for a connection in a mechanism
- Parameters:
index (integer) – The index of the connection you want to set. Note that connections start at 0, not 1. To add a new connection use index
connections
data (dict) –
Object containing the connection data. The properties can be:
- angle (optional):
(real) Current angle in degrees (for
Mechanism.LINE
andMechanism.HINGE
)- assembly1 (optional):
(integer) Assembly 1 label (required for
Mechanism.LINE
,Mechanism.PIN
andMechanism.HINGE
)- assembly2 (optional):
(integer) Assembly 2 label (required for
Mechanism.LINE
,Mechanism.PIN
andMechanism.HINGE
)- assembly3:
(integer) Assembly 3 label (required for
Mechanism.LINE
)- coefficient1 (optional):
(real) Coefficient for linear coupler equation for connection 1 (for
Mechanism.COUPLER
)- coefficient2 (optional):
(real) Coefficient for linear coupler equation for connection 2 (for
Mechanism.COUPLER
)- coefficient3 (optional):
(real) Coefficient for linear coupler equation for connection 3 (for
Mechanism.COUPLER
)- connection1 (optional):
(integer) Connection 1 label (for
Mechanism.COUPLER
)- connection2 (optional):
(integer) Connection 2 label (for
Mechanism.COUPLER
)- connection3 (optional):
(integer) Connection 3 label (for
Mechanism.COUPLER
)- distance (optional):
(real) Current distance (for
Mechanism.LINE
)- factor1 (optional):
(real) Factor 1 on Assembly 3 (
Mechanism.LINE
only)- factor2 (optional):
(real) Factor 2 on Assembly 3 (
Mechanism.LINE
only)- locked (optional):
(integer) 1 if locked (for
Mechanism.LINE
,Mechanism.PIN
andMechanism.HINGE
)- mode1 (optional):
(integer) Coupling mode for connection 1. 0 = translational coupling, 1 = rotational coupling (for
Mechanism.COUPLER
)- mode2 (optional):
(integer) Coupling mode for connection 2. 0 = translational coupling, 1 = rotational coupling (for
Mechanism.COUPLER
)- mode3 (optional):
(integer) Coupling mode for connection 3. 0 = translational coupling, 1 = rotational coupling (for
Mechanism.COUPLER
)- node1 (optional):
(integer) Node 1 label (for
Mechanism.LINE
,Mechanism.PIN
andMechanism.HINGE
, not required if using x1, y1 and z1)- node2 (optional):
(integer) Node 2 label (for
Mechanism.LINE
,Mechanism.PIN
andMechanism.HINGE
, not required if using x2, y2 and z2)- nrotation (optional):
(real) -ve rotation limit in degrees (for
Mechanism.LINE
andMechanism.HINGE
)- nslide (optional):
(real) -ve slide translation (for
Mechanism.LINE
)- protation (optional):
(real) +ve rotation limit in degrees (for
Mechanism.LINE
andMechanism.HINGE
)- pslide (optional):
(real) +ve slide translation (for
Mechanism.LINE
)- title (optional):
(string) Title
- type:
(integer) Connection type. Can be one of:
Mechanism.PIN
,Mechanism.LINE
,Mechanism.HINGE
orMechanism.COUPLER
]- x1 (optional):
(real) x1 coordinate (for
Mechanism.LINE
,Mechanism.PIN
andMechanism.HINGE
, not required if using node1)- x2 (optional):
(real) x2 coordinate (for
Mechanism.LINE
,Mechanism.PIN
andMechanism.HINGE
, not required if using node2)- y1 (optional):
(real) y1 coordinate (for
Mechanism.LINE
,Mechanism.PIN
andMechanism.HINGE
, not required if using node1)- y2 (optional):
(real) y2 coordinate (for
Mechanism.LINE
,Mechanism.PIN
andMechanism.HINGE
, not required if using node2)- z1 (optional):
(real) z1 coordinate (for
Mechanism.LINE
,Mechanism.PIN
andMechanism.HINGE
, not required if using node1)- z2 (optional):
(real) z2 coordinate (for
Mechanism.LINE
,Mechanism.PIN
andMechanism.HINGE
, not required if using node2)- Returns:
no return value
- Return type:
None
Example
To add a new pin connection to mechanism m between assemblies 5 and 6 at node 1000 with title “Example connection”:
data = { "type":Oasys.PRIMER.Mechanism.PIN, "assembly1":5, "assembly2":6, "node1":1000, "title":"Example connection" } m.SetConnection(m.connections, data)
- Mechanism.SetFlag(flag)¶
Sets a flag on the mechanism
- Parameters:
flag (Flag) – Flag to set on the mechanism
- Returns:
No return value
- Return type:
None
Example
To set flag f for mechanism m:
m.SetFlag(f)
- Mechanism.SetPoint(index, data)¶
Sets the data for a reference point in a mechanism
- Parameters:
index (integer) – The index of the reference point you want to set. Note that reference points start at 0, not 1. To add a new point use index
points
data (dict) –
Object containing the reference point data. The properties can be:
- assembly:
(integer) Assembly label
- csys (optional):
(integer) Coordinate system label
- node (optional):
(integer) Node label (not required if using x, y and z)
- rx (optional):
(boolean) Point restrained rotationally in X
- ry (optional):
(boolean) Point restrained rotationally in Y
- rz (optional):
(boolean) Point restrained rotationally in Z
- title (optional):
(string) Point title
- tx (optional):
(boolean) Point restrained translationally in X
- ty (optional):
(boolean) Point restrained translationally in Y
- tz (optional):
(boolean) Point restrained translationally in Z
- x (optional):
(real) x coordinate (not required if using node)
- y (optional):
(real) y coordinate (not required if using node)
- z (optional):
(real) z coordinate (not required if using node)
- Returns:
no return value
- Return type:
None
Example
To add a new reference point to mechanism m assembly 5 at node 1000 with title “Example point” restrained in x:
data = { "assembly":5, "node":1000, "title":"Example point", "tx":True } m.SetPoint(m.points, data)To add a new reference point to mechanism m assembly 5 at (10, 20, 30) with title “Example point”:
data = { "assembly":5, "x":10, "y":20, "z":30, "title":"Example point" } m.SetPoint(m.points, data)
- Mechanism.Sketch(redraw=Oasys.gRPC.defaultArg)¶
Sketches the mechanism. The mechanism will be sketched until you either call
Mechanism.Unsketch()
,Mechanism.UnsketchAll()
,Model.UnsketchAll()
, or delete the model
- Parameters:
redraw (boolean) – Optional. If model should be redrawn or not after the mechanism is sketched. If omitted redraw is true. If you want to sketch several mechanisms 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 mechanism m:
m.Sketch()
- Mechanism.Unblank()¶
Unblanks the mechanism
- Returns:
No return value
- Return type:
None
Example
To unblank mechanism m:
m.Unblank()
- Mechanism.Unsketch(redraw=Oasys.gRPC.defaultArg)¶
Unsketches the mechanism
- Parameters:
redraw (boolean) – Optional. If model should be redrawn or not after the mechanism is unsketched. If omitted redraw is true. If you want to unsketch several mechanisms 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 mechanism m:
m.Unsketch()
- Mechanism.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:
Mechanism object
- Return type:
dict
Example
To check if Mechanism property m.example is a parameter by using the
Mechanism.GetParameter()
method:if m.ViewParameters().GetParameter(m.example): do_something..
- Mechanism.Xrefs()¶
Returns the cross references for this mechanism
- Returns:
Xrefs object
- Return type:
dict
Example
To get the cross references for mechanism m:
xrefs = m.Xrefs()