RobotStudio event

Editing RAPID Modules through C# Add-in

Hello,

I've been working with a c# add-in that defines robot targets using a 3rd party tool. My current method involves identifying all the robotTargets present in a task using SearchRapidSymbol and then writing to the RapidData.value field of those symbols using FillFromString2. However, if I understood it correctly this method's result is similiar to debugging a c# program and using the debugger to pause and during run-time inject new values to variables, meaning that the actual code is never changed. Every time the program pointer is reset the RobotTargets are reverted back to their old values since the actual RAPID code never changed. So what I would need to do is change the actual decleration line of the RobotTarget in the RAPID module. 

Is there any way to edit rapid modules / lines in rapid modules using the RS / PC SDK directly? Or is my best bet copying the modules from the controller to local memory, editing them with a stream reader/ writer and then loading them back into the controller? This is of course possible to do it's just that I would prefer to not have to take this route. I have been looking through the API  but I couldn't find anything that seemed promising. 

Answers

  • Did you get this to work?  Did you declare the robtargets as VAR or PERS?  If you declare them as VAR when you reset the program pointer like "Move PP to Main" it will reset the value to their default value. 

  •  It's as you say, if declared as VAR they are are reset to their default value. However it is of interest for me to be able to redefine them multiple times, also PERS robtargets did not show up in my RAPID data search.

    I got it to work by copying the modules from the controller to local memory, editing the line with the robot target decleration with a stream reader/writer and then loading them back into the controller.
  • Hi Joman, 

          I meet the same problem as you. Do you mind to tell me how to copying the modules to local memory and loading them back? Thanks a lot.