Getting Positions of Products and Parts

You can program a Get Position activity to retrieve the position of a part or a product in simulation. This part/product must belong to the resource supporting the Simulation Logic.

AlongX, AlongY, AlongZ (unit: millimeter) and AboutX, AboutY, AboutZ (unit: degree) are the output values of the activity Get Position defined in the resource Simulation Logic.

The reference axis of the coordinates is:

  • The reference axis of the resource for non-programmable resources.
  • The reference axis of the organizational resource supporting the programming context for programmable resources.

For this user task, we will only demonstrate the use of the Get Position activity for a non-programmable resource.

This task shows you how to:


Before you begin: The System and Device Designer workbench should be opened in the Live Simulation environment.

For this task, we will re-use the sample created in the Setting Displacement of Products and parts user task.

Related Topics
About Live Simulation
Writing Command Values of Mechanisms

Get Position in SFC+

You can retrieve the postion of a part or a product with the Get Postion activity programmed in SFC+.

  1. Open the sample created in the Set Displacement in SFC+ user task. The activity Set Displacement defined in the Simulation Logic of the resource allows the user to move the button cap while playing the simulation.



  2. Select the Main block and double-click Behavior in the Main window.




    • The SFC+ Editor appears as an immersive window at the center of the screen.
    • A toolbox containing all the SFC+ Editor commands appears at the right side of the screen.

  3. Select Get Position in the Activities toolbar.

  4. If the immersive window is in front of the part, click in the 3D view.

    The SFC+ Editor window becomes transparent. Now, you can click through the editor window.

  5. Select the part being the target of the activity.

    The selected part is highlighted and a bubble appears.

    Tip: Select another part if you want to change the target.

  6. Click the bubble to confirm the part selection.

    The Get Position Properties dialog box appears.

    In the Displacement frame, you can enter the name of ports or local signals containing the target position.

    • Structured: Value is a structured signal containing all the coordinates, that is, positions and angles about X, Y and Z. The signal type is:
      {AlongX:float64;AlongY:float64;AlongZ:float64;AboutX:float64;AboutY:float64;AboutZ:float64}
    • Detailed: The coordinates can be stored in different signals.

    In the Action Data frame, you can define:

    • The type of action: Pulse or Sustain
    • A conditional expression applicable on the execution of the action. If the condition is false, the action is not executed.

      See a typical example below.



    In the Declaration frame, you can define that the ports or signals used in the Position frame must be created with the activity. This must be done if the ports or signals are not already defined in the block.

  7. Select Detailed.

  8. Enter a port name in the AlongZ box.



    Note: You can enter any port or local signal compliant with the Float64 type.

  9. Click As Port in the Declaration frame.

    So, the OutZ port will be created with the activity.

  10. Click Sustain in the Action frame.

    So, the Get Position activity will be run at each simulation step.

  11. Click OK and select the Step S0 in the SFC+ Editor window

    A new action is added to step S0. The action contains an icon identifying the activity Get Position followed by the name of the product being the target of the activity.

    Tip: To modify the activity, double-click the action. You can change the target of the activity and the parameters of the Get Position Properties dialog box.

  12. To test the behavior of the activity in simulation:

    1. Select the Main block in the Simulation Logic tree and click Play in the compass.

      The block is compiled and the simulation is initialized. The Simulation toolbar and the Signals Monitoring window appear.

    2. Expand the Ports node of the Signals Monitoring window.
    3. Click Next in the control bar of the compass.



      OutZ returns the Z position of the button cap.

    4. Force the value of State to 10. That means that the "Lighted Round Push Button Led" part is going to move to 10mm.

    5. Press Enter.



    6. Click Next in the control bar of the compass.



      The device moves along the Z axis. Because of a one cycle delay, the value OutZ does not change.

      Warning: In SFC+, the position returned is not the position of the product/part at the current simulation step but the position at the previous simulation step.

    7. Click Next again.

      The value of OutZ is updated.

    8. Click the Play of the compass to close the simulation.

Get Position in DataFlow

You can retrieve the postion of a part or a product with the Get Postion activity programmed in Dataflow.

  1. Open the sample created in the Set Displacement in Dataflow user task. The activity Set Displacement defined in the resource allows the user to move the button cap while playing the simulation.



  2. Double-click the Main block.




    • The Block Editor appears as an immersive window at the center of the screen.
    • A toolbox containing all the Block Editor commands appears at the right side of the screen.

  3. Click in the 3D view to be able to select a 3D component through the Block Editor window.

    The Block Editor window becomes transparent. So, you can select the part through the immersive window.

  4. Select the part being the target of the activity.

    The selected part is highlighted and a bubble attached to it appears.

    Tip: Select another part if you want to change the target.

  5. Click the bubble to confirm the part selection.

  6. Click the place in the blank sheet where you want to position the activity block.



    Two inputs ports are displayed:

    • Position, type Position {AlongX:float64;AlongY:float64;AlongZ:float64}
    • Angle, type Angle {AboutX:float64;AboutY:float64;AboutZ:float64}

    The types Position and Angle are available as predefined types as soon as the activities Set Displacement or Get Position are used.

  7. Select Position object > Map to new Port in the contextual menu of the Position port .

  8. If you want to change the name of the new port, double_click its icon.

    The Block Properties dialog box appears. You can change the value of the field Name.

    Note: In Dataflow, you cannot create more than one Get Position activity for the same target.

  9. To test the behavior of the activity in simulation:

    1. Select the Main block thumbnail and click Play in the compass.

      The block is compiled and the simulation is initialized. The Simulation toolbar and the Signals Monitoring window appear.

    2. In the IO Monitoring window, expand the Ports node.
    3. Click Next.



      The Led_Position port returns the X,Y and Z position of the button cap.

    4. Force the value of AlongW to 10 and press Enter.

    5. Click Next.

      The button cap moves to 10mm. The value of AlongZ is updated.

    6. Stop the simulation by clicking Play in the PLM compass.