Exception when calling ABB.Robotics.Controllers.RapidDomain.Task.SaveProgramToFile
First I check all Controllers:
foreach (ControllerObjectReference controllerReference in ControllerManager.ControllerReferences)
....
Then all the Tasks der Controller checked: (ABB.Robotics.Controllers.Controller)
var rapidTasks = controller.Rapid.GetTasks();Then the Modules should be saved: { private readonly ABB.Robotics.Controllers.RapidDomain.Task_task; … … string f = "d:\\01_DATEN\\03_Temp\\" + _task.Name; try { _task.SaveProgramToFile(f); } catch (Exception ex) { Logger.AddMessage("Problem saving file " + f + ex); } ….. }0
Comments
-
The function "SaveProgramToFile" needs as argument the directory where the program will be saved. When using subdirectories, the definition for the path-separator is critical. In your case, you are using "\\" and this will throw an error in RobotStudio (I did not test on a real machine).
See the following code for a working solution:private void button1_Click(object sender, EventArgs e) { //Declare Variables Controller RobotController = null; string filePath; try { //Get RobotController RobotController = new Controller(); //Set directory filePath = RobotController.FileSystem.LocalDirectory + @/files_backup; foreach (Task t in RobotController.Rapid.GetTasks()) { // save to file t.SaveProgramToFile(filePath); // dispose t.Dispose(); } GTPUMessageBox.Show(this, null, "Saved in " + filePath, null); } catch (Exception ex) { // Exception handling GTPUMessageBox.Show(this, null, "Error...\n" + ex.Message, null); } finally { // clean-up controller if (RobotController != null) { RobotController.Dispose(); RobotController = null; } } }
0
Categories
- All Categories
- 5.5K RobotStudio
- 395 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 249 ScreenMaker
- 2.7K Robot Controller
- 310 IRC5
- 59 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 785 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 4 Job listings