Search Results for

    Show / Hide Table of Contents

    Importing ActionInstruction

    This example provides information on importing ActionInstruction based on process definition. An active station for this example.

    Pass the filepath of process defintion. To check the result of the addin, ensure that the instruction can be created from RobotStudio.

    Use this procedure to Import Action Instruction:

    1. Get Station object and active RsTask.

    2. Get Instruction name from filepath.

    3. If instruction exists and is MoveInstruction then Import ProcessDefinition from filepath.

    Solution

    1. Get Station object and active RsTask.

      Station station = Project.ActiveProject as Station;
      RsTask task = station.ActiveTask;
      
    2. Get Instruction name from filepath.

      const string cActionInstruction = "ActionInstruction";
      
      //Get instruction name from filepath
      string instrName = System.IO.Path.GetFileNameWithoutExtension(filePath);
      
    3. If instruction exists and is ActionInstruction then Import RsProcessDefintion from filepath.

      if (task.InstructionDescriptions.Contains(instrName.ToLower()))
      {
          if (task.InstructionDescriptions[instrName.ToLower()].ToString() == cActionInstruction)
          {
              //Import ProcessDefinition from filePath                  
              if (ImportProcessDefinitionFile(filePath))
              {
                  result = true;
              }
          }
      }
      

    Example

    This example provides information on importing RsActionInstruction based on process definition.

    private static bool ImportActionInstruction(string filePath)
    {
        bool result = false;
        Project.UndoContext.BeginUndoStep("ImportActionInstruction");
        try
        {
            //Get Station object and Active RsTask.  
            Station station = Project.ActiveProject as Station;
            RsTask task = station.ActiveTask;
            const string cActionInstruction = "ActionInstruction";
    
            //Get instruction name from filepath
            string instrName = System.IO.Path.GetFileNameWithoutExtension(filePath);
    
            //If instruction exists and is ActionInstruction then Import RsProcessDefintion from filepath.  
            if (task.InstructionDescriptions.Contains(instrName.ToLower()))
            {
                if (task.InstructionDescriptions[instrName.ToLower()].ToString() == cActionInstruction)
                {
                    //Import ProcessDefinition from filePath                  
                    if (ImportProcessDefinitionFile(filePath))
                    {
                        result = true;
                    }
                }
            }
        }
        catch (Exception ex)
        {
            Logger.AddMessage(new LogMessage(ex.Message.ToString()));
            Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
        }
        finally
        {
            Project.UndoContext.EndUndoStep();
        }
        
       
        return result;
    }
    

    This example provides information on importing RsProcessDefinition.

    private static bool ImportProcessDefinitionFile(string filePath)
    {
        TextReader textReader = null;
                    
        //Get Station object                   
        Station station = Project.ActiveProject as Station;
        try
        {
            //Read the file                          
            textReader = new StreamReader(filePath);
            XmlTextReader definitionFile = new XmlTextReader(textReader);
    
            //Import Process Definition into task     
            station.ActiveTask.ImportProcessDefinitions(definitionFile);
            textReader.Close();
    
            return true;
        }
        catch
        {
            if (textReader != null)
                textReader.Close();
            return false;
        }
    }        
    

    Required Namespaces

    ABB.Robotics.RobotStudio.Environment

    ABB.Robotics.Controllers.RapidDomain

    See Also

    • Importing MoveInstruction
    • Importing ProcessDefinition
    • Getting Process and Instruction Templates
    In this article
    Back to top Copyright © 2026 ABB Robotics