# Reading Rapid Data from RS API

**URL:** <https://tech-community.robotics.abb.com/t/reading-rapid-data-from-rs-api/3109>\
**Category:** RobotStudio\
**Created:** [October 14, 2009, 9:57pm UTC](https://tech-community.robotics.abb.com/t/reading-rapid-data-from-rs-api/3109 "2009-10-14T21:57:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![SlickRick](https://avatars.discourse-cdn.com/v4/letter/s/48db29/32.png) [@SlickRick](https://tech-community.robotics.abb.com/u/SlickRick)\
**Post date:** [October 14, 2009, 9:57pm UTC](https://tech-community.robotics.abb.com/t/reading-rapid-data-from-rs-api/3109/1 "2009-10-14T21:57:19Z")

</div>

Hello,  
So here is what I’m trying to do. While running my RS simulation I have three different tools active at different times. When these tools are active it does not change the active tool for the station. I am able to change the station active tool through the use of API Macros but it does not fulfill what I want to accomplish. I want to know which tool is active in the simulation while it is executing. Is this possible? If so how because I cannot figure it out.

Thank You,  
Rick

---

<div class="post-metadata">

**Author:** ![SlickRick](https://avatars.discourse-cdn.com/v4/letter/s/48db29/32.png) [@SlickRick](https://tech-community.robotics.abb.com/u/SlickRick)\
**Post date:** [October 22, 2009, 8:26pm UTC](https://tech-community.robotics.abb.com/t/reading-rapid-data-from-rs-api/3109/2 "2009-10-22T20:26:07Z")

</div>

Seriously no one has a response to this???

---

<div class="post-metadata">

**Author:** ![mattdavis](https://avatars.discourse-cdn.com/v4/letter/m/8e7dd6/32.png) [@mattdavis](https://tech-community.robotics.abb.com/u/mattdavis)\
**Post date:** [October 23, 2009, 2:27am UTC](https://tech-community.robotics.abb.com/t/reading-rapid-data-from-rs-api/3109/3 "2009-10-23T02:27:44Z")

</div>

Sorry have’t checked for a while, i use multiple tools and have a tool changer setup with 4 tools mounted in it. I tied events to the inputs and outputs of the tool changer to show/hide the correct tool. I couldn’t figure out how to make the tool image change just depending on which tool the current command was using.

For testing i just have all four tools (8 actually because i have two different angle welding necks and have them with and without wire stickout for touch sensing) attached to the robot and show/hide the one i am using, the only way i can control it in the rapid program was to use event manager and tie inputs and outputs to events.

---

<div class="post-metadata">

**Author:** ![SlickRick](https://avatars.discourse-cdn.com/v4/letter/s/48db29/32.png) [@SlickRick](https://tech-community.robotics.abb.com/u/SlickRick)\
**Post date:** [October 23, 2009, 2:27pm UTC](https://tech-community.robotics.abb.com/t/reading-rapid-data-from-rs-api/3109/4 "2009-10-23T14:27:26Z")

</div>

Thanks for the response. Is there anyway for an API Macro to read rapid data from the TP?

Thanks,

---

<div class="post-metadata">

**Author:** ![Niklas\_Skoglund](https://avatars.discourse-cdn.com/v4/letter/n/5fc32e/32.png) [@Niklas\_Skoglund](https://tech-community.robotics.abb.com/u/Niklas_Skoglund)\
**Post date:** [October 27, 2009, 3:10pm UTC](https://tech-community.robotics.abb.com/t/reading-rapid-data-from-rs-api/3109/5 "2009-10-27T15:10:13Z")

</div>

Hi Rick,

you can use PC SDK to read the content of a RAPID variable from the controller, and to search for variables.

Here is a snippet from an example in the PC SDK Reference Manual.  
It calculates the sum of the variable “reg1” in all tasks.

**int** result = 0;  
**try** { _// Get all tasks_  
Task tasks = \_controller.Rapid.GetTasks();

**foreach** (Task t **in** tasks)  
{  
RapidData rdReg1 = t.GetRapidData(“user”, “reg1”);

result += **int**.Parse(rdReg1.Value.ToString());  
}  
}

For some RAPID datatypes there are specific PC SDK classes, for example robtarget and tooldata.  
If you have found a tooldata you can cast the RapidData object returned from GetRapiData() to a **ToolData** object which makes it easier to read and write individual members of the tooldata instead of interpreting the value as string.

In order to use PC SDK you must add references to the ABB.Robotics.dll and ABB.Robotics.Controllers.dll to your project. They can be found in the GAC and in the RAB installation folder for example “C:Program FilesABB Industrial ITRobotics ITRobot Application Builder 5.12PC SDK”
