Search Results for

    Show / Hide Table of Contents

    Getting Targets from a Path

    This example provides information on retrieving targets from a RsPathProcedure object. You can apply this method directly to a specific RsPathProcedure object or use the currently selected path procedure in the active task by referencing Station.ActiveStation.ActiveTask.ActivePathProcedure. In this example, the passed path object is called pathProcedure.

    Solution

    1. Get RsInstruction from the path procedure and iterate over each instruction.

      // Iterate over every instructions in the path procedure 
      foreach (var instruction in pathProcedure.Instructions)
      
    2. Within the iteration, check if the current instruction is of type RsMoveInstruction.

      // If instruction type is RsMoveInstruction then execute the next steps
      if (instruction is RsMoveInstruction moveInstruction)
      
    3. Get RsRobTarget from the move instruction.

      // Get robtarget from move instruction
      string strToPoint = moveInstruction.GetToPointArgument().Value;
      RsRobTarget robTarget =
          task.FindDataDeclarationFromModuleScope(strToPoint, pathProcedure.ModuleName)
          as RsRobTarget;
      
    4. Get RsWorkObject from the move instruction.

      // Get work object from move instruction
      string strWorkObject = moveInstruction.GetWObjArgument().Value;
      RsWorkObject workobject =
          task.FindDataDeclarationFromModuleScope(strWorkObject, pathProcedure.ModuleName)
          as RsWorkObject;
      
    5. Get targets based on the workobject and robtarget.

      // Get targets based on the workobject and robtarget
      RsTarget[] arrTarget = task.FindTargets(workobject, robTarget);
      

    Example

    This example provides information on retrieving targets from RsPathProcedure object.

    private static List<RsTarget> GetTargetsfromPath(RsPathProcedure pathProcedure)
    {
        // Placeholder for targets to be returned
        List<RsTarget> targets = new List<RsTarget>();
    
        if (pathProcedure != null)
        {
            // Get RsTask object reference from path procedure
            if (pathProcedure.Parent is RsTask task)
            {
                // Iterate over every instructions in the path procedure 
                foreach (var instruction in pathProcedure.Instructions)
                {
                    // If instruction type is RsMoveInstruction then execute the next steps
                    if (instruction is RsMoveInstruction moveInstruction)
                    {
                        // Get robtarget from move instruction
                        string strToPoint = moveInstruction.GetToPointArgument().Value;
                        RsRobTarget robTarget =
                            task.FindDataDeclarationFromModuleScope(strToPoint, pathProcedure.ModuleName)
                            as RsRobTarget;
    
                        // Get work object from move instruction
                        string strWorkObject = moveInstruction.GetWObjArgument().Value;
                        RsWorkObject workobject =
                            task.FindDataDeclarationFromModuleScope(strWorkObject, pathProcedure.ModuleName)
                            as RsWorkObject;
    
                        // Get targets based on the workobject and robtarget
                        RsTarget[] arrTarget = task.FindTargets(workobject, robTarget);
                        targets.AddRange(arrTarget);
                    }
                }
            }
        }
        return targets;
    }
    

    Required Namespaces

    ABB.Robotics.Math

    ABB.Robotics.RobotStudio.Stations

    See Also

    • Creating Path
    In this article
    Back to top Copyright © 2026 ABB Robotics