RsTargetCollection Class |
Namespace: ABB.Robotics.RobotStudio.Stations
public class RsTargetCollection : ICollection, IEnumerable, IEnumerable<RsTarget>
The RsTargetCollection type exposes the following members.
Name | Description | |
---|---|---|
Add(RsTarget) |
Add a target to a task.
| |
Add(RsTarget, RsTarget) |
Add a target to a task.
| |
Contains | ||
CopyTo(Array, Int32) | ||
CopyTo(RsTarget, Int32) | ||
Equals | (Inherited from Object.) | |
Finalize | (Inherited from Object.) | |
GetEnumerator | ||
GetHashCode | (Inherited from Object.) | |
GetType | (Inherited from Object.) | |
MemberwiseClone | (Inherited from Object.) | |
Remove |
Removes a target to from a task.
| |
ToArray | ||
ToString | (Inherited from Object.) |
Project.UndoContext.BeginUndoStep("Copy Target"); try { // Instance active station. Station stn = Station.ActiveStation; // Get the active workobject. RsWorkObject wobj = stn.ActiveTask.ActiveWorkObject; // Create a new RobTarget and add it to the ActiveTask. RsRobTarget robTarget = new RsRobTarget(); robTarget.Name = stn.ActiveTask.GetValidRapidName("MyTarget", "_", 10); stn.ActiveTask.DataDeclarations.Add(robTarget); // Create an RsTarget from wobj and RobTarget. RsTarget target = new RsTarget(wobj, robTarget); // Set the name of the target. target.Name = robTarget.Name; // Add RsTarget to ActiveTask. stn.ActiveTask.Targets.Add(target); // Copy the target. RsTarget targetCopy = (RsTarget)target.Copy(); // Set the new name to the copied targets. targetCopy.Name = target.Name + "_Copy"; // Add the copied target, after the original target, to the ActiveTask. stn.ActiveTask.Targets.Add(targetCopy, target); // Move the new target 0.5 meters along the X-axis. targetCopy.Transform.X = targetCopy.Transform.X + 0.5; // Set the highlight color of the target. target.Highlight(Color.Green); // Reset the highlight color of the target copy. targetCopy.ResetHighlight(); // Remove the original target. stn.ActiveTask.Targets.Remove(target); } catch (Exception) { Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback); throw; } finally { Project.UndoContext.EndUndoStep(); }