Pull Rapid variable with C#
EugeneB
✭
I post a lot of questions about - how to pull variable value from the module with C#. And I still didn't receive a clear answer. A lot of members of this forum point me in the right direction - thank you all for your examples and support.
I was able to pull a variable from my module but I can not pull the value of that variable. My code:
RapidData rd = aController.Rapid.GetRapidData("T_ROB1", "mModule", "variable");
//trying to print the value:
Console.WriteLine(rd.Value);
No output - empty space.
What I'm doing wrong?
I was able to pull a variable from my module but I can not pull the value of that variable. My code:
private NetworkScanner netScan = null;
private ControllerInfo[] ctrlInfo = null;
private ControllerInfo[] ctrlInfo = null;
private Controller aController = null;
// scanning the network for the controllers
NetworkScanner netScan = new NetworkScanner();
// getting all available controllers from the network
// using ControllerInfo[] ctrlInfo
ctrlInfo = netScan.GetControllers();
// can be used like this if you know which controller inside of ctrlInfo[] array.
// using Controller aController
aController = new Controller(ctrlInfo[0]);
//aController = ControllerFactory.CreateFrom(ctrlInfo[0]);
RapidData rd = aController.Rapid.GetRapidData("T_ROB1", "mModule", "variable");
//trying to print the value:
Console.WriteLine(rd.Value);
No output - empty space.
What I'm doing wrong?
Tagged:
0
Best Answers
-
Hello,RapidData.Value return a IRapidData like ABB.Robotics.Controllers.RapidDomain.Bool.If you want only string use RapidData.StringValue.
5 -
Thanks DenisFR. I send you a message earlier.
I finally understand how it works. Now I able to pull any variable I want from the module.
Thank you all ABB forum community.0 -
I was missing one piece of the of the code: example:Module m;RapidData r01, r02; // create instance for each variableNum v; // will work with num dataABB.Robotics.Controllers.RapidDomain.String s; // will work with string data
// I didn't know how to asosiate Num and String with my module:
// Now I do.r01 = m.GetRapidData("number");r02 = m.GetRapidData("name"); // string variable
// I did't know how to use structures - Num, and String// read valuev = (Num)r01.Value;s = (ABB.Robotics.Controllers.RapidDomain.String)r02.Value;0
Categories
- All Categories
- 5.5K RobotStudio
- 394 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 249 ScreenMaker
- 2.7K Robot Controller
- 309 IRC5
- 59 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 783 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 4 Job listings