Skip to main content

Rocky PrePost scripting 2024 R2

RAMotion

Last update: 17.07.2025

class RAMotion

Rocky PrePost Scripting wrapper representing a single Motion in a Motion Frame.

Access individual motions via a RAMotionFrame’s motion list:

motions = motion_frame.GetMotions()
motion_1 = motions[0]
motion_2 = motions.New()

Every RAMotion contains properties that are common to all motions (such as start and stop times) and properties that are specific to the motion’s type (translation, vibration, etc). These latter properties must be accessed by a “sub-object” that is retrieved via GetTypeObject() after the specific motion type is configured via SetType().

motions = motion_frame.GetMotions()
motion_1 = motions.New()
motion_1.SetType('Translation')
translation = motion_1.GetTypeObject()
# `translation` is a RATranslation
translation.SetVelocity([1.0, 0.0, 0.0], 'm/s')

Refer to the specific PrePost Scripting wrappers for documentation on the individual motion types:

Methods:

Name Description
GetStartTime([unit]) Get the value of "Start Time".
GetStopTime([unit]) Get the value of "Stop Time".
GetType() Get the concrete type of motion.
GetTypeObject() Get the API object that wraps the specific motion type.
GetValidTypes() Return a list with the possible values for the motion's type.
SetStartTime(value[, unit]) Set the value of "Start Time".
SetStopTime(value[, unit]) Set the value of "Stop Time".
SetType(motion_type) Set the concrete type of motion.

GetStartTime(unit: Optional[str] = None)

Get the value of “Start Time”.

  • Parameters: unit – The unit for the returned value. If no unit is provided, the returned value will be in “s”.

GetStopTime(unit: Optional[str] = None)

Get the value of “Stop Time”.

  • Parameters: unit – The unit for the returned value. If no unit is provided, the returned value will be in “s”.

GetType()

Get the concrete type of motion.

  • Return type: unicode
  • Returns: A string describing the type of motion. The returned value will be one of the strings in the “Type” drop-down menu in the UI.

GetTypeObject()

Get the API object that wraps the specific motion type.

  • Return type: ApiElementItem

GetValidTypes()

Return a list with the possible values for the motion’s type.

  • Return type: list(unicode)
  • Returns: A list of accepted values for SetType().

SetStartTime(value: Union[str, float], unit: Optional[str] = None)

Set the value of “Start Time”.

  • Parameters:
    • value – The value to set. This value can be an expression with input variables or float type.
    • unit – The unit for value. If no unit is provided, value is assumed to be in “s”.

SetStopTime(value: Union[str, float], unit: Optional[str] = None)

Set the value of “Stop Time”.

  • Parameters:
    • value – The value to set. This value can be an expression with input variables or float type.
    • unit – The unit for value. If no unit is provided, value is assumed to be in “s”.

SetType(motion_type)

Set the concrete type of motion.

  • Parameters: motion_type (unicode) – The concrete motion type. Accepted values are the strings in the “Type” drop-down menu in the UI.
  • Returns: The PrePost Scripting wrapper representing the concrete motion type.

Connect with Ansys