Show / Hide Table of Contents

Creating a Path

This example provides information on creating a path in RobotStudio. The example makes use of already created targets in the station. MoveL instructions are created by using the targets.

Run your Add-In and go to the Home tab, and choose the Paths and Targets browser. A Path called myPath should be created.

Solution

  1. Get the active station object

    // Get the active station
    Station station = Station.ActiveStation;
    
  2. Create a RsPathProcedure

    // Create a path procedure
    RsPathProcedure myPath = new RsPathProcedure("myPath");
    
  3. Add path to the active task and configure it

    // Add the path to the active task and configure it
    station.ActiveTask.PathProcedures.Add(myPath);
    myPath.ModuleName = "module1";
    myPath.ShowName = true;
    myPath.Synchronize = true;
    myPath.Visible = true;
    
  4. Create instructions between every target and add them to the path

    // Create path through all targets in the active task
    foreach (RsTarget target in station.ActiveTask.Targets)
    {
        RsMoveInstruction moveInstruction = new RsMoveInstruction(
            station.ActiveTask,
            "Move",
            "Default",
            MotionType.Linear,
            station.ActiveTask.ActiveWorkObject.Name,
            target.Name,
            station.ActiveTask.ActiveTool.Name);
    
        // Add each move instruction to the path procedure
        myPath.Instructions.Add(moveInstruction);
    }
    

Example

This example provides information on creating a path in RobotStudio.

// Begin UndoStep
Project.UndoContext.BeginUndoStep("RsPathProcedure Create");

try
{
    // Get the active station
    Station station = Station.ActiveStation;

    // Create a path procedure
    RsPathProcedure myPath = new RsPathProcedure("myPath");

    // Add the path to the active task and configure it
    station.ActiveTask.PathProcedures.Add(myPath);
    myPath.ModuleName = "module1";
    myPath.ShowName = true;
    myPath.Synchronize = true;
    myPath.Visible = true;

    // Create path through all targets in the active task
    foreach (RsTarget target in station.ActiveTask.Targets)
    {
        RsMoveInstruction moveInstruction = new RsMoveInstruction(
            station.ActiveTask,
            "Move",
            "Default",
            MotionType.Linear,
            station.ActiveTask.ActiveWorkObject.Name,
            target.Name,
            station.ActiveTask.ActiveTool.Name);

        // Add each move instruction to the path procedure
        myPath.Instructions.Add(moveInstruction);
    }
}
catch
{
    Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
    throw;
}
finally
{
    Project.UndoContext.EndUndoStep();
}

Required Namespaces

ABB.Robotics.RobotStudio.Stations

See Also

  • Creating Targets
  • Deleting Path
In this article
Back to top Copyright © 2025 ABB