Technical Support

{{ post.title }} 글 편집 글 편집 (이전 에디터) Author {{ post.author.name }} Posted on

Version {{ post.target_version }} Product
{{ product.name }}
Tutorial/Manual {{ post.manual_title }} Attached File {{ post.file.upload_filename }}

Sometimes you need modeling where motion occurs only at a certain distance. When the distance between two markers is less than 100, the modeling method is described below as an example of modeling the movement of the body falling down.

Such a model can be implemented simply by using the IF() function Expression.


This explanation is based on the example model below, so download the example model and refer to it.

▶ Example Model Download: Distance_Motion.rdyn

  • Two CMotions represent X-direction translational motion and Y-direction free fall motion
  • A model that allows the box located at the top to fall down when the distance between the two boxes is 100mm through Expression


First, create an Expression that measures the distance.

  1. Click [SubEntity tab > Expression group > Expression icon].
  2. Enter DX(Body1.Marker1, Body2.Marker1, Body2.Marker1).
  • This function is written based on the example model.
  • The ABS() function is used in the example model to return a real number.
  • The DX() function calculates the x-direction position for one marker or the distance between two markers in the x-direction of the reference marker.
  • More information about the Expression function can be found in the Expression Function Handbook .


Next, create a Variable Equation.

In this example, let's create a Variable Equation to use the distance measurement expression in the IF() function.

Variable Equation is utilized when using one expression in another expression.

NBVMfJPbPwXa0km5brl3qvXdfeKuAUNU.jpeg

  1. Click [SubEntity tab > Equation group > Variable Equation icon]
  2. After clicking the Create button, select the distance measurement expression created earlier and click 'OK'.
  3. Variable Equation VE1 is created.


In Expression, write the IF function as shown below.

The IF function specifies a condition and returns the specified function value depending on whether it is satisfied or not. (for more details: Expression Function Handbook )

IF(Varval(VE1):0,0,IF(Varval(VE1)-100:-200,-200,0))

  • Use in IF(f1:f2,f3,f4) format
  • Varval(VE1): Use Variable Equation created above (Distance Measurement Expression)
  • f1: Calculation formula that assigns conditions
  • f2: Value (or function) returned when f1 is less than IFT (If Tolerance)
  • f3: Value (or function) returned when f1 is equal to IFT
  • f4: Value (or function) returned when f1 is greater than IFT
  • *: As IFT (If Tolerance) , when an If statement branches, it is difficult to numerically accurately calculate 0, so it is a parameter that compensates to respond to the condition of 0 by giving a small range. For more details )


Lastly, define Expression in Motion.

You can apply the expression to which the IF() function created above is applied to the motion of the joint. In the example model, CMotion is defined as y-direction motion.

Q3e0Hl36HTwljp1RFN06vhmhYHt7XoXE.jpeg


Now, when performing a simulation, you can see that when the distance between the two bodies is 100mm, they have a downward movement.


In addition, related contents that can utilize the IF() function and sensors are provided as follows. You can learn how to use IF() function, and how to model with motion according to conditions.