# How can I pull a variable from the module/routine with pc sdk?

**URL:** <https://tech-community.robotics.abb.com/t/how-can-i-pull-a-variable-from-the-module-routine-with-pc-sdk/8293>\
**Category:** Developer Tools\
**Tags:** pc-sdk, robotstudio, virtual-irc5, robotstudio-sdk, robotapps\
**Created:** [June 8, 2018, 5:20pm UTC](https://tech-community.robotics.abb.com/t/how-can-i-pull-a-variable-from-the-module-routine-with-pc-sdk/8293 "2018-06-08T17:20:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![EugeneB](https://avatars.discourse-cdn.com/v4/letter/e/d07c76/32.png) [@EugeneB](https://tech-community.robotics.abb.com/u/EugeneB)\
**Post date:** [June 8, 2018, 5:20pm UTC](https://tech-community.robotics.abb.com/t/how-can-i-pull-a-variable-from-the-module-routine-with-pc-sdk/8293/1 "2018-06-08T17:20:09Z")

</div>

I set up a variable in my module - var time. How can I pull this variable info from that module/routine with pc sdk?

---

<div class="post-metadata">

**Author:** ![scottMHA](https://avatars.discourse-cdn.com/v4/letter/s/a8b319/32.png) [@scottMHA](https://tech-community.robotics.abb.com/u/scottMHA)\
**Post date:** [June 11, 2018, 2:06pm UTC](https://tech-community.robotics.abb.com/t/how-can-i-pull-a-variable-from-the-module-routine-with-pc-sdk/8293/2 "2018-06-11T14:06:56Z")

</div>

This should do what you want, it will return all rob targets for each task.

```auto
RsTaskCollection tasks = irc5controller.Tasks;
            foreach (RsTask task in tasks)
            {
                RsDataDeclaration[] datadecls = task.FindDataDeclarationsByType(typeof(RsRobTarget));
            }

```

You just need to change the RsRobTarget for what ever data type your variable is.

---

<div class="post-metadata">

**Author:** ![EugeneB](https://avatars.discourse-cdn.com/v4/letter/e/d07c76/32.png) [@EugeneB](https://tech-community.robotics.abb.com/u/EugeneB)\
**Post date:** [June 11, 2018, 4:18pm UTC](https://tech-community.robotics.abb.com/t/how-can-i-pull-a-variable-from-the-module-routine-with-pc-sdk/8293/3 "2018-06-11T16:18:49Z")

</div>

RsTaskCollection is ABB.Robotics.RobotStudio.Stations class and irc5controller is an instance of the Controller class correct? It given me an error in this line: RsTaskCollection tasks = irc5controller.Tasks - problem with Tasks - “irc5controller” does not contain a definition for the Tasks. How can I do this without of using RobotStudio classes?

---

<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:** [June 11, 2018, 5:02pm UTC](https://tech-community.robotics.abb.com/t/how-can-i-pull-a-variable-from-the-module-routine-with-pc-sdk/8293/4 "2018-06-11T17:02:55Z")

</div>

@EugeneB: I give you an example in your other thread:

> **[ABB Robotics Community - Maintenance](https://forums.robotstudio.com/discussion/10841/how-can-i-read-from-running-robot-with-the-c-from-robotstudion-controller#latest)**

---

<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:** [June 12, 2018, 2:38pm UTC](https://tech-community.robotics.abb.com/t/how-can-i-pull-a-variable-from-the-module-routine-with-pc-sdk/8293/5 "2018-06-12T14:38:09Z")

</div>

Here what I’ve post to EugeneB for other:

You can found in GetModule() how I do to find data.

```auto
//First prepare search
                    RapidSymbolSearchProperties rssp = RapidSymbolSearchProperties.CreateDefault();
                    rssp.GlobalSymbols = true;
                    rssp.InUse = false;
                    rssp.LocalSymbols = true;
                    rssp.Recursive = false;
                    rssp.SearchMethod = SymbolSearchMethod.Block;
                    rssp.Types = SymbolTypes.Data;
//Then look at all data in module
                    string typeName = "";// "GfxShapeData"; Don't find GfxShapeData Directly.
                    RapidSymbol[] rsArray = module.SearchRapidSymbol(rssp, typeName, string.Empty);
                    foreach (RapidSymbol rs in rsArray)
                    {
                        RapidData rd = module.GetRapidData(rs);
                        RapidDataType rdt = controller.Rapid.GetRapidDataType(rs);//Only grabe GfxShapeData, here you can do what you want like read rd.Name                        if (rd.RapidType == "GfxShapeData")
                        {
                            sDatasList += ";" + rs.Name;
                        }
                    }

```

In GetGfxShapeData I pull data, it’s more complicated as it’s a record type.

```auto
                    RapidData rd = module.GetRapidData(sDataName);
                    if (rd.RapidType == "GfxShapeData")
                    {
                        RapidDataType rdt = controller.Rapid.GetRapidDataType(task.Name, module.Name, rd.Name);

                        sd = new GfxShapeData(rdt, rd);
                        if (sd.IsNotNull)
                        {
                            //Update Properties
                            component.Properties["ShapeType"].Value = (sd.ShapeType == GfxShapeData.ShapeTypes.Box) ? "Box" : "Capsule";
                            component.Properties["ParentAxis"].Value = sd.ParentAxis.Value;

```

Here a simple example to get a PERS bool bTest:=FALSE; value:

```auto
                    RapidData test = module.GetRapidData("bTest");
                    string s = test.StringValue;
                    Bool bTest = (Bool)test.Value;

```

Bool is on namespace ABB.Robotics.Controllers.RapidDomain.
