Deleting RsProcessDefinition
This example provides information on deleting an RsProcessDefinition from RobotStudio. An active station is needed for this example.
Pass a process definition name as a parameter. To check the result of the Add-In, ensure that the process defintion has been deleted from RobotStudio template manager.
Solution
Get the active station.
// Get active station Station station = Station.ActiveStation;Try to get the RsProcessDefinition from the RsProcessDefinitionCollection of the active task based on the definition name.
// Try to get the process definition from the active task if (station.ActiveTask.ProcessDefinitions.TryGetProcessDefinition(processDefinitionName, out RsProcessDefinition definition))Remove the RsProcessDefinition object from the RsProcessDefinitionCollection of the active task.
// Remove the process definition if found station.ActiveTask.ProcessDefinitions.Remove(definition);
Example
This example provides information on deleting an RsProcessDefinition from RobotStudio.
private static void DeleteProcessDefinition(string processDefinitionName)
{
Project.UndoContext.BeginUndoStep("DeleteProcessDefinition");
try
{
// Get active station
Station station = Station.ActiveStation;
// Try to get the process definition from the active task
if (station.ActiveTask.ProcessDefinitions.TryGetProcessDefinition(processDefinitionName, out RsProcessDefinition definition))
{
// Remove the process definition if found
station.ActiveTask.ProcessDefinitions.Remove(definition);
}
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
}
Required Namespaces
ABB.Robotics.RobotStudio.Stations