Show / Hide Table of Contents

Export Program

This tutorial describes how to export RAPID program from the controller on to local drive.You will need an active Station for this tutorial.

You need to pass the location where the RAPID program gets exported or saved.To check the result of the addin, ensure that the file is present in the filepath specified.

Export RAPID program by following these steps:

  1. Get RsIrc5Controller Instance.

  2. Get virtual controller object based on RsIrc5Controller's object SystemId .

  3. Get Rapid Task object and Create directory.

  4. Call SaveProgramToFile function of rapid Task passing the directory created in step3 as a parameter.

Solution

  1. Get RsIrc5Controller Instance.

    Station station = Project.ActiveProject as Station;
    RsTask rsTask = station.ActiveTask;
    RsIrc5Controller rsIrc5Controller = (RsIrc5Controller)rsTask.Parent;
    
  2. Get virtual controller object based on RsIrc5Controller's object SystemID.

    ABB.Robotics.Controllers.Controller controller = 
        new Controllers.Controller(new Guid(rsIrc5Controller.SystemId.ToString()));
    
  3. Get Rapid Task object and Create directory.

    Task controllerTask = controller.Rapid.GetTask(rsTask.Name);
    //Create Directory if it doesnot exist
    Directory.CreateDirectory(filePath);
    
  4. Call SaveProgramToFile function of rapid Task passing the directory created in step3 as a parameter.

    controllerTask.SaveProgramToFile(filePath);
    

Example

This example shows how to export RAPID program from the controller on to local drive.

private static bool ExportRAPIDProgram(string filePath)
{
    bool result = false;      
    try
    {
        //Get RsIrc5Controller instance  
        Station station = Project.ActiveProject as Station;
        RsTask rsTask = station.ActiveTask;
        RsIrc5Controller rsIrc5Controller = (RsIrc5Controller)rsTask.Parent;

        //Get Controller object based on SystemID  
        ABB.Robotics.Controllers.Controller controller = 
            new Controllers.Controller(new Guid(rsIrc5Controller.SystemId.ToString()));

        //Get Rapid Task                 
        Task controllerTask = controller.Rapid.GetTask(rsTask.Name);
        //Create Directory if it doesnot exist
        Directory.CreateDirectory(filePath);

        //Export Program               
        controllerTask.SaveProgramToFile(filePath);
        result = true;
    }
    catch (ABB.Robotics.GeneralException)
    {
        result = false;
    }
    catch (Exception)
    {
        result = false;
    }
    return result;
}

Required Namespaces

System.IO

ABB.Robotics.RobotStudio.Environment

ABB.Robotics.Controllers.RapidDomain

See Also

  • Load Program
  • Save Program
In this article
Back to top Copyright © 2024 ABB