Deleting Path
This example provides information on deleting a RsPathProcedure. The example makes use of an already created path in the station. The path is deleted from station given the name.
Run your Addin and go to the Home tab, and choose the Paths and Targets browser. The path named myPath should be removed.
Solution
Get active station object
// Get the active station Station station = Station.ActiveStation;Define the name of the path, a placeholder for the path, and get the RsPathProcedure
// Define the name of the path procedure to delete string pathName = "myPath"; // Placeholder for the path procedure to be deleted RsPathProcedure procedure = null; // Get path procedure by name procedure = station.ActiveTask.FindPathProcedureFromModuleScope(pathName, "module1");If a PathProcedure was found, delete PathProcedure
// If the path is found, remove the procedure from the active task's path procedures if (procedure != null) { station.ActiveTask.PathProcedures.Remove(procedure); }
Example
This example provides information on deleting a path in RobotStudio.
// Begin UndoStep
Project.UndoContext.BeginUndoStep("RsPathProcedure Delete");
try
{
// Get the active station
Station station = Station.ActiveStation;
// Define the name of the path procedure to delete
string pathName = "myPath";
// Placeholder for the path procedure to be deleted
RsPathProcedure procedure = null;
// Get path procedure by name
procedure = station.ActiveTask.FindPathProcedureFromModuleScope(pathName, "module1");
// If the path is found, remove the procedure from the active task's path procedures
if (procedure != null)
{
station.ActiveTask.PathProcedures.Remove(procedure);
}
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Required Namespaces
ABB.Robotics.RobotStudio.Stations