Jump To Target Example
This code simply takes the first target in the list of the active task(see targets under the Paths&Targets browser tab) and jumps the robot to it. In order for this to work, you need to create a target first. See the Create Target on how to do this in the API, or simply create one in RobotStudio.
Note
This example requires a running VC.
Example
Project.UndoContext.BeginUndoStep("Jump To Target");
try
{
// Get active station
Station station = Station.ActiveStation;
// Select the first target of the active task
RsTarget target = station.ActiveTask.Targets[0];
// Jump to the target. Requires an active tool in the station and a running VC
await target.JumpToAsync(station.ActiveTask.ActiveTool, updateController: true);
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}