Force
Force
Class Force()
Force(parent='MODEL', name='Force_n', label='Force_n', active=True, b1=None,
b2=None, origin=None, rm='Global_Frame', action_only=True, use_markers=False,
itype='TRANS', p1=None, p2=None, align_meth1='Point', align_pt1=None, align_vec1=None,
user=False, usr_sub='`USER()`', local_funcname='MOTSUB', use_local_dll=False,
local_dll='', local_func_type='DLL')
Create an action-only or action-reaction type of force.
setValue, getValue, getAssociatedGraphics
Keyword Arguments:
Argument | Data Type | Description | Default |
---|---|---|---|
name | String | The variable name. | Force_n, for next available integer n. |
label | String | The descriptive label. | Force_n, for next available integer n. |
parent | Object | The parent. | MODEL |
active | Bool | Used to activate or deactivate this entity. | True |
b1 | Body | Body to which the active force is applied. | None |
b2 | Body | Body to which the reactive force is applied. | None |
origin | Point | Point at which the force is applied. | None |
rm | Marker | Reference marker in which the components of the force are specified. | Global_Frame. |
action_only | Bool | Specifies an action only force when True and an action-reaction force when False. | True |
use_markers | Bool | Use explicit markers to apply the force. | False |
itype | Enum | Type of force. Takes values TRANS, ROT, TRANS_ROT, LOA or SC_ROT. | TRANS |
p1 | Point | Point on body_1 at which the action force is applied. | None |
p2 | Point | Point on body_2 at which the reaction force is applied. | None |
align_meth1 | MultiRef | Alignment method when itype is SC_ROT. One of Pointor Vector. | Point |
align_pt1 | Point | Point used to align force direction when align_meth1 is Point for itype SC_ROT. | None |
align_vec1 | Vector | Vector used to align force direction when align_meth1 is Vector for itype SC_ROT. | None |
user | Bool | Use user defined properties, if true. | False |
usr_sub | Function | The expression passed to the user dll. When using solver expressions, Templex syntax (within ``) is used and all variables are enclosed in braces {} and the rest is treated as literal. | ‘USER()' |
local_funcname | String | The function/subroutine name. | ‘MOTSUB' |
use_local_dll | Bool | Uses a local function instead of default if True. | False |
local_dll | File | The path of the local dll. Defaults to ‘'. * local_func_type (Enum) - The type of the user subroutine. one of DLL, PYTHON or MATLAB. | ‘DLL' |
Instances
Instance | Type | Description |
---|---|---|
f | Nonlinear | Nonlinear entity reference to set translational force when itype is LOA |
t | Nonlinear | Nonlinear entity reference to set rotational force when itype is LOA. |
fx | Nonlinear | Nonlinear entity reference to set translational X component of the force. |
fy | Nonlinear | Nonlinear entity reference to set translational Y component of the force. |
fz | Nonlinear | Nonlinear entity reference to set translational Z component of the force. |
tx | Nonlinear | Nonlinear entity reference to set rotational X component of the force. |
ty | Nonlinear | Nonlinear entity reference to set rotational Y component of the force. |
tz | Nonlinear | Nonlinear entity reference to set rotational Z component of the force. |
i | Marker | Marker attached to b1. |
j | Marker | Marker attached to b2. |
Notes
1. The parent parameter can only be initialized by the constructor and should not be modified directly.
2. Only parent can be used as a positional argument in the constructor.
3. Instance is a reference to an entity. You cannot modify an instance, but can modify its properties.
Methods
- getAssociatedGraphics()
-
Get all the graphics that are associated with this object.
Returns:
List of all graphic associated with this body.
Return type:
(list)
- getValue(name)
-
Returns value of an attribute
Parameters:
name str Name of the attribute Defaults to . Returns:
The return value. Return type depends on the attribute type.
- setValue(name, value, updatePanel=False)
-
Sets value of an attribute.
Parameters:
name str Name of the attribute. value ** Value of the attribute to be set. Returns:
Returns True if the value was successfully set else False.
Return type:
Bool
Force Pair
Class ForcePair()
ForcePair(parent='MODEL', name='ForcePair_n', label='ForcePair_n', active=True, sym='NONE')
Force pair containing left and right instances of singles.
Keyword Arguments:
Argument | Data Type | Description | Default |
---|---|---|---|
name | String | The variable name. | MotionPair_n, for next available integer n. |
label | String | The descriptive label. | MotionPair_n, for next available integer n. |
parent | Object | The parent. | MODEL |
active | Bool | Defines if entity is activated when True or deactivated when False. | True |
sym | Enum | The symmetry of pair entity. Takes values 'LEFT' for left entity as leader, 'RIGHT' for right entity as leader or 'NONE' when it is not symmetric. | NONE |
Instances
Instance | Type | Description |
---|---|---|
l | Point | The left force. |
r | Point | The right force. |
Notes
Instance is a reference to an entity. You cannot modify an instance, but can modify its properties.
Examples
========
Create and modify attributes of a Force.
>>> from hw import mview
>>> #Create references for visulising the Force
>>> b1 = mview.Body(inertia_props_from_graphic = True)
>>> g1 = mview.Sphere(origin = 'P_Global_Origin',body = b1)
>>> j1 = mview.Joint(type = 'ScrewJoint')
>>> j1.setValues(b1 = b1,b2 = 'B_Ground',origin = 'P_Global_Origin',align_meth1 = 'VECTOR',align_vec1 = 'V_Global_Y')
>>> j1.pitch = 0.1
>>> #Create a rotational force
>>> torque = mview.Force(itype = 'ROT')
>>> #Set multiple values at once
>>> torque.setValues(b1 = b1, origin = 'P_Global_Origin')
>>> torque.ty.lin = -20
>>> #Set gravity as "Off" for this specific example
>>> mview.getModel().DS_Gravity.op_gravity.value = 'Off'
>>> #Run the simulation to see the torque on screw joint
>>> #Modelling action-reaction force with a second body
>>> p1 = mview.Point(y = 50)
>>> b2 = mview.Body(inertia_props_from_graphic = True)
>>> g2 = mview.Sphere(origin = p1,body = b2)
>>> #Deactivate the screw joint
>>> j1.active = False
>>> newforce = torque
>>> #Apply translational action reation force between b1 and b2
>>> newforce.setValues(itype = 'TRANS',action_only = False,b2 = b2)
>>> newforce.fy.lin = -10
>>> #Run the simulation to see the action reaction force