# Getting Link position

**URL:** <https://tech-community.robotics.abb.com/t/getting-link-position/11588>\
**Category:** RobotStudio\
**Tags:** robotstudioapi, position, link, robot\
**Created:** [September 5, 2024, 8:30am UTC](https://tech-community.robotics.abb.com/t/getting-link-position/11588 "2024-09-05T08:30:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ssickss](https://avatars.discourse-cdn.com/v4/letter/s/3ab097/32.png) [@ssickss](https://tech-community.robotics.abb.com/u/ssickss)\
**Post date:** [September 5, 2024, 8:30am UTC](https://tech-community.robotics.abb.com/t/getting-link-position/11588/1 "2024-09-05T08:30:27Z")

</div>

Good morning,  
I am developing an add-in in RobotStudio that needs to extract the position and orientation of Link4, Link5 and Link6 of the robot. Yesterday I tried the following code, but I got some values that were not correct, or at least not where I expected them to be.

This is my code:

foreach (GraphicComponent gc in robot.GraphicComponents)

{  
Logger.AddMessage(new LogMessage(gc.Name + " =\> X: " + gc.Transform.X + " | Y: " + gc.Transform.Y + " | Z: " + gc.Transform.Z + " | RX : " + gc.Transform.RX + " | RY : " + gc.Transform.RY + " | RZ : " + gc.Transform.RZ));  
}

Am I doing it wrong? Is there another way to get this value?  
Thanks in advance,  
**Stefano**

---

<div class="post-metadata">

**Author:** ![ssickss](https://avatars.discourse-cdn.com/v4/letter/s/3ab097/32.png) [@ssickss](https://tech-community.robotics.abb.com/u/ssickss)\
**Post date:** [September 5, 2024, 2:03pm UTC](https://tech-community.robotics.abb.com/t/getting-link-position/11588/2 "2024-09-05T14:03:32Z")

</div>

I think i figured it out.

By using Mechanism.GetJointTransform(int index) and passing it the index of the joint you want to find, you will get a matrix with the position and orientation of the joint (its Euler XYZ and Euler ZYX)

---

<div class="post-metadata">

**Author:** ![DenisFR](https://avatars.discourse-cdn.com/v4/letter/d/dc4da7/32.png) [@DenisFR](https://tech-community.robotics.abb.com/u/DenisFR)\
**Post date:** [September 5, 2024, 4:01pm UTC](https://tech-community.robotics.abb.com/t/getting-link-position/11588/3 "2024-09-05T16:01:06Z")

</div>

Hello,  
You can have a look how I update a virtual mechanism with a real one here:

> <https://github.com/DenisFR/RSMoveMecha/blob/master/RSMoveMecha/RSMoveMecha.cs#L544>

---

<div class="post-metadata">

**Author:** ![ssickss](https://avatars.discourse-cdn.com/v4/letter/s/3ab097/32.png) [@ssickss](https://tech-community.robotics.abb.com/u/ssickss)\
**Post date:** [September 6, 2024, 7:06am UTC](https://tech-community.robotics.abb.com/t/getting-link-position/11588/4 "2024-09-06T07:06:49Z")

</div>

Hello @DenisFR,  
thanks for your time and for your response,

I see that you extracted the robot joints via  
Mechanism.GetJointValues()

So I think that this is the correct way to go, to use the values inside Mechanism and not GraphicComponents, so:  
\*To get joint values of the robot you use Mechanism.GetJointValues(), that returns an array of double as result;  
\*To get the position and the orientation of the link of the joints you use Mechanism.GetJointTransform(), which gives you a Matrix4 result. Inside of it you can look for Transform and EulerXYZ/EulerZYX rotation values.
