Class RsTarget
Defines a target position by the combination of a RsWorkObject and a RsRobTarget.
Inherited Members
Namespace: ABB.Robotics.RobotStudio.Stations
Assembly: ABB.Robotics.RobotStudio.Stations.dll
Syntax
sistent("Target")]
public sealed class RsTarget : ProjectObject, IHasTransform, ISupportCopy, IGfxObject
Constructors
RsTarget(RsWorkObject, RsRobTarget)
Initializes a new instance of the RsTarget class.
Declaration
public RsTarget(RsWorkObject workObject, RsRobTarget robTarget)
Parameters
Type | Name | Description |
---|---|---|
RsWorkObject | workObject | Workobject data declaration. |
RsRobTarget | robTarget | Robtarget data declaration |
Examples
Create a target.
Project.UndoContext.BeginUndoStep("Create Target");
try
{
// Instance active station.
Station stn = Station.ActiveStation;
// Get the active workobject.
RsWorkObject wobj = stn.ActiveTask.ActiveWorkObject;
// Create a new RsRobTarget and add it to ActiveTask.
RsRobTarget robTarget = new RsRobTarget();
robTarget.Name = stn.ActiveTask.GetValidRapidName("MyRobTarget", "_", 10);
stn.ActiveTask.DataDeclarations.Add(robTarget);
// Create an RsTarget from wobj and RobTarget.
RsTarget target = new RsTarget(wobj, robTarget);
target.Name = robTarget.Name;
// Add RsTarget to ActiveTask.
stn.ActiveTask.Targets.Add(target);
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Properties
ApproachVector
Gets or sets an AxisDirection that represents an approach vector for this target.
Declaration
public AxisDirection ApproachVector { get; set; }
Property Value
Type | Description |
---|---|
AxisDirection |
Examples
Get ApproachVector.
Project.UndoContext.BeginUndoStep("Target Properties");
try
{
// Instance active station.
Station stn = Station.ActiveStation;
// Get the active workobject.
RsWorkObject wobj = stn.ActiveTask.ActiveWorkObject;
// Create a new RsRobTarget and add it to ActiveTask.
RsRobTarget robTarget = new RsRobTarget();
robTarget.Name = stn.ActiveTask.GetValidRapidName("MyRobTarget", "_", 10);
stn.ActiveTask.DataDeclarations.Add(robTarget);
// Create an RsTarget from wobj and RobTarget.
RsTarget target = new RsTarget(wobj, robTarget);
// Add RsTarget to ActiveTask.
stn.ActiveTask.Targets.Add(target);
// Set the name of the target.
target.Name = robTarget.Name;
// Add a custom attribute to the target.
target.Attributes.Add("MyAttribute", "10");
// Output the project that the target is part of, and the parent of the target.
Logger.AddMessage(new LogMessage("The target: " + target.Name + " is part of the project: " +
target.ContainingProject.Name + ". The targets parent is: " + target.Parent.Name));
// Output the ToString-reprentation of the target and its types diplay name.
Logger.AddMessage(new LogMessage("The targets ToString representation is '" +
target.ToString() + "' and its TypeDisplayName is '" + target.TypeDisplayName + "'."));
// Set the workobject of the target as the active workobject.
stn.ActiveTask.ActiveWorkObject = target.WorkObject;
// Create a copy of the RobTarget.
RsRobTarget newRobTarget = (RsRobTarget)robTarget.Copy();
// Assign the copy to the target.
target.RobTarget = newRobTarget;
// Check if the target is invisible, and make it visible and yellow.
if (!target.Visible)
{
target.Visible = true;
Color col = Color.Yellow;
target.Color = col;
}
// Make the target's grapical display size twice as large.
target.FrameSize = target.FrameSize * 2;
// Get the transform and output its values using the logger.
Logger.AddMessage(new LogMessage("Transform of target: " + target.Name
+ "; X: " + target.Transform.X
+ "; Y: " + target.Transform.Y
+ "; Z: " + target.Transform.Z
+ "; Rx: " + target.Transform.RX
+ "; Ry: " + target.Transform.RY
+ "; Rz: " + target.Transform.RZ
));
// Get the ReferenceFrame of the target.
Transform refFrame = target.ReferenceFrame;
// Show the reference frame in the graphics.
target.ShowReferenceFrame = true;
// If the AxisDirection of the target is undefined then set it to negative x.
if (target.ApproachVector == AxisDirection.Undefined)
{
target.ApproachVector = AxisDirection.NegativeX;
}
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Color
Gets or sets the color of the graphical target frame. Color.Empty means the target is color-coded in red/green/blue.
Declaration
public Color Color { get; set; }
Property Value
Type | Description |
---|---|
Color |
Examples
Get/Set Color.
Project.UndoContext.BeginUndoStep("Target Properties");
try
{
// Instance active station.
Station stn = Station.ActiveStation;
// Get the active workobject.
RsWorkObject wobj = stn.ActiveTask.ActiveWorkObject;
// Create a new RsRobTarget and add it to ActiveTask.
RsRobTarget robTarget = new RsRobTarget();
robTarget.Name = stn.ActiveTask.GetValidRapidName("MyRobTarget", "_", 10);
stn.ActiveTask.DataDeclarations.Add(robTarget);
// Create an RsTarget from wobj and RobTarget.
RsTarget target = new RsTarget(wobj, robTarget);
// Add RsTarget to ActiveTask.
stn.ActiveTask.Targets.Add(target);
// Set the name of the target.
target.Name = robTarget.Name;
// Add a custom attribute to the target.
target.Attributes.Add("MyAttribute", "10");
// Output the project that the target is part of, and the parent of the target.
Logger.AddMessage(new LogMessage("The target: " + target.Name + " is part of the project: " +
target.ContainingProject.Name + ". The targets parent is: " + target.Parent.Name));
// Output the ToString-reprentation of the target and its types diplay name.
Logger.AddMessage(new LogMessage("The targets ToString representation is '" +
target.ToString() + "' and its TypeDisplayName is '" + target.TypeDisplayName + "'."));
// Set the workobject of the target as the active workobject.
stn.ActiveTask.ActiveWorkObject = target.WorkObject;
// Create a copy of the RobTarget.
RsRobTarget newRobTarget = (RsRobTarget)robTarget.Copy();
// Assign the copy to the target.
target.RobTarget = newRobTarget;
// Check if the target is invisible, and make it visible and yellow.
if (!target.Visible)
{
target.Visible = true;
Color col = Color.Yellow;
target.Color = col;
}
// Make the target's grapical display size twice as large.
target.FrameSize = target.FrameSize * 2;
// Get the transform and output its values using the logger.
Logger.AddMessage(new LogMessage("Transform of target: " + target.Name
+ "; X: " + target.Transform.X
+ "; Y: " + target.Transform.Y
+ "; Z: " + target.Transform.Z
+ "; Rx: " + target.Transform.RX
+ "; Ry: " + target.Transform.RY
+ "; Rz: " + target.Transform.RZ
));
// Get the ReferenceFrame of the target.
Transform refFrame = target.ReferenceFrame;
// Show the reference frame in the graphics.
target.ShowReferenceFrame = true;
// If the AxisDirection of the target is undefined then set it to negative x.
if (target.ApproachVector == AxisDirection.Undefined)
{
target.ApproachVector = AxisDirection.NegativeX;
}
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
DisplayName
Declaration
public override string DisplayName { get; }
Property Value
Type | Description |
---|---|
String |
Overrides
FrameSize
Gets or sets the size of the graphical target frame.
Declaration
public double FrameSize { get; set; }
Property Value
Type | Description |
---|---|
Double |
Examples
Get/Set FrameSize.
Project.UndoContext.BeginUndoStep("Target Properties");
try
{
// Instance active station.
Station stn = Station.ActiveStation;
// Get the active workobject.
RsWorkObject wobj = stn.ActiveTask.ActiveWorkObject;
// Create a new RsRobTarget and add it to ActiveTask.
RsRobTarget robTarget = new RsRobTarget();
robTarget.Name = stn.ActiveTask.GetValidRapidName("MyRobTarget", "_", 10);
stn.ActiveTask.DataDeclarations.Add(robTarget);
// Create an RsTarget from wobj and RobTarget.
RsTarget target = new RsTarget(wobj, robTarget);
// Add RsTarget to ActiveTask.
stn.ActiveTask.Targets.Add(target);
// Set the name of the target.
target.Name = robTarget.Name;
// Add a custom attribute to the target.
target.Attributes.Add("MyAttribute", "10");
// Output the project that the target is part of, and the parent of the target.
Logger.AddMessage(new LogMessage("The target: " + target.Name + " is part of the project: " +
target.ContainingProject.Name + ". The targets parent is: " + target.Parent.Name));
// Output the ToString-reprentation of the target and its types diplay name.
Logger.AddMessage(new LogMessage("The targets ToString representation is '" +
target.ToString() + "' and its TypeDisplayName is '" + target.TypeDisplayName + "'."));
// Set the workobject of the target as the active workobject.
stn.ActiveTask.ActiveWorkObject = target.WorkObject;
// Create a copy of the RobTarget.
RsRobTarget newRobTarget = (RsRobTarget)robTarget.Copy();
// Assign the copy to the target.
target.RobTarget = newRobTarget;
// Check if the target is invisible, and make it visible and yellow.
if (!target.Visible)
{
target.Visible = true;
Color col = Color.Yellow;
target.Color = col;
}
// Make the target's grapical display size twice as large.
target.FrameSize = target.FrameSize * 2;
// Get the transform and output its values using the logger.
Logger.AddMessage(new LogMessage("Transform of target: " + target.Name
+ "; X: " + target.Transform.X
+ "; Y: " + target.Transform.Y
+ "; Z: " + target.Transform.Z
+ "; Rx: " + target.Transform.RX
+ "; Ry: " + target.Transform.RY
+ "; Rz: " + target.Transform.RZ
));
// Get the ReferenceFrame of the target.
Transform refFrame = target.ReferenceFrame;
// Show the reference frame in the graphics.
target.ShowReferenceFrame = true;
// If the AxisDirection of the target is undefined then set it to negative x.
if (target.ApproachVector == AxisDirection.Undefined)
{
target.ApproachVector = AxisDirection.NegativeX;
}
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Name
Gets or sets the name of the object
Declaration
public override string Name { get; set; }
Property Value
Type | Description |
---|---|
String |
Overrides
ReferenceFrame
Gets a Transform that represents a user-defined reference frame for the target.
Declaration
public Transform ReferenceFrame { get; }
Property Value
Type | Description |
---|---|
Transform |
Remarks
The local Matrix is relative to the WorkObject.
Examples
Get ReferenceFrame.
Project.UndoContext.BeginUndoStep("Target Properties");
try
{
// Instance active station.
Station stn = Station.ActiveStation;
// Get the active workobject.
RsWorkObject wobj = stn.ActiveTask.ActiveWorkObject;
// Create a new RsRobTarget and add it to ActiveTask.
RsRobTarget robTarget = new RsRobTarget();
robTarget.Name = stn.ActiveTask.GetValidRapidName("MyRobTarget", "_", 10);
stn.ActiveTask.DataDeclarations.Add(robTarget);
// Create an RsTarget from wobj and RobTarget.
RsTarget target = new RsTarget(wobj, robTarget);
// Add RsTarget to ActiveTask.
stn.ActiveTask.Targets.Add(target);
// Set the name of the target.
target.Name = robTarget.Name;
// Add a custom attribute to the target.
target.Attributes.Add("MyAttribute", "10");
// Output the project that the target is part of, and the parent of the target.
Logger.AddMessage(new LogMessage("The target: " + target.Name + " is part of the project: " +
target.ContainingProject.Name + ". The targets parent is: " + target.Parent.Name));
// Output the ToString-reprentation of the target and its types diplay name.
Logger.AddMessage(new LogMessage("The targets ToString representation is '" +
target.ToString() + "' and its TypeDisplayName is '" + target.TypeDisplayName + "'."));
// Set the workobject of the target as the active workobject.
stn.ActiveTask.ActiveWorkObject = target.WorkObject;
// Create a copy of the RobTarget.
RsRobTarget newRobTarget = (RsRobTarget)robTarget.Copy();
// Assign the copy to the target.
target.RobTarget = newRobTarget;
// Check if the target is invisible, and make it visible and yellow.
if (!target.Visible)
{
target.Visible = true;
Color col = Color.Yellow;
target.Color = col;
}
// Make the target's grapical display size twice as large.
target.FrameSize = target.FrameSize * 2;
// Get the transform and output its values using the logger.
Logger.AddMessage(new LogMessage("Transform of target: " + target.Name
+ "; X: " + target.Transform.X
+ "; Y: " + target.Transform.Y
+ "; Z: " + target.Transform.Z
+ "; Rx: " + target.Transform.RX
+ "; Ry: " + target.Transform.RY
+ "; Rz: " + target.Transform.RZ
));
// Get the ReferenceFrame of the target.
Transform refFrame = target.ReferenceFrame;
// Show the reference frame in the graphics.
target.ShowReferenceFrame = true;
// If the AxisDirection of the target is undefined then set it to negative x.
if (target.ApproachVector == AxisDirection.Undefined)
{
target.ApproachVector = AxisDirection.NegativeX;
}
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
RobTarget
Gets or sets the RsRobTarget associated with the target.
Declaration
public RsRobTarget RobTarget { get; set; }
Property Value
Type | Description |
---|---|
RsRobTarget |
Examples
Get/Set RobTarget.
Project.UndoContext.BeginUndoStep("Target Properties");
try
{
// Instance active station.
Station stn = Station.ActiveStation;
// Get the active workobject.
RsWorkObject wobj = stn.ActiveTask.ActiveWorkObject;
// Create a new RsRobTarget and add it to ActiveTask.
RsRobTarget robTarget = new RsRobTarget();
robTarget.Name = stn.ActiveTask.GetValidRapidName("MyRobTarget", "_", 10);
stn.ActiveTask.DataDeclarations.Add(robTarget);
// Create an RsTarget from wobj and RobTarget.
RsTarget target = new RsTarget(wobj, robTarget);
// Add RsTarget to ActiveTask.
stn.ActiveTask.Targets.Add(target);
// Set the name of the target.
target.Name = robTarget.Name;
// Add a custom attribute to the target.
target.Attributes.Add("MyAttribute", "10");
// Output the project that the target is part of, and the parent of the target.
Logger.AddMessage(new LogMessage("The target: " + target.Name + " is part of the project: " +
target.ContainingProject.Name + ". The targets parent is: " + target.Parent.Name));
// Output the ToString-reprentation of the target and its types diplay name.
Logger.AddMessage(new LogMessage("The targets ToString representation is '" +
target.ToString() + "' and its TypeDisplayName is '" + target.TypeDisplayName + "'."));
// Set the workobject of the target as the active workobject.
stn.ActiveTask.ActiveWorkObject = target.WorkObject;
// Create a copy of the RobTarget.
RsRobTarget newRobTarget = (RsRobTarget)robTarget.Copy();
// Assign the copy to the target.
target.RobTarget = newRobTarget;
// Check if the target is invisible, and make it visible and yellow.
if (!target.Visible)
{
target.Visible = true;
Color col = Color.Yellow;
target.Color = col;
}
// Make the target's grapical display size twice as large.
target.FrameSize = target.FrameSize * 2;
// Get the transform and output its values using the logger.
Logger.AddMessage(new LogMessage("Transform of target: " + target.Name
+ "; X: " + target.Transform.X
+ "; Y: " + target.Transform.Y
+ "; Z: " + target.Transform.Z
+ "; Rx: " + target.Transform.RX
+ "; Ry: " + target.Transform.RY
+ "; Rz: " + target.Transform.RZ
));
// Get the ReferenceFrame of the target.
Transform refFrame = target.ReferenceFrame;
// Show the reference frame in the graphics.
target.ShowReferenceFrame = true;
// If the AxisDirection of the target is undefined then set it to negative x.
if (target.ApproachVector == AxisDirection.Undefined)
{
target.ApproachVector = AxisDirection.NegativeX;
}
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
ShowName
Gets or sets whether the name of the target will be displayed in the graphics
Declaration
public bool ShowName { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Examples
Get/Set ShowName.
Project.UndoContext.BeginUndoStep("Target Properties");
try
{
// Instance active station.
Station stn = Station.ActiveStation;
// Get the active workobject.
RsWorkObject wobj = stn.ActiveTask.ActiveWorkObject;
// Create a new RsRobTarget and add it to ActiveTask.
RsRobTarget robTarget = new RsRobTarget();
robTarget.Name = stn.ActiveTask.GetValidRapidName("MyRobTarget", "_", 10);
stn.ActiveTask.DataDeclarations.Add(robTarget);
// Create an RsTarget from wobj and RobTarget.
RsTarget target = new RsTarget(wobj, robTarget);
// Add RsTarget to ActiveTask.
stn.ActiveTask.Targets.Add(target);
// Set the name of the target.
target.Name = robTarget.Name;
// Add a custom attribute to the target.
target.Attributes.Add("MyAttribute", "10");
// Output the project that the target is part of, and the parent of the target.
Logger.AddMessage(new LogMessage("The target: " + target.Name + " is part of the project: " +
target.ContainingProject.Name + ". The targets parent is: " + target.Parent.Name));
// Output the ToString-reprentation of the target and its types diplay name.
Logger.AddMessage(new LogMessage("The targets ToString representation is '" +
target.ToString() + "' and its TypeDisplayName is '" + target.TypeDisplayName + "'."));
// Set the workobject of the target as the active workobject.
stn.ActiveTask.ActiveWorkObject = target.WorkObject;
// Create a copy of the RobTarget.
RsRobTarget newRobTarget = (RsRobTarget)robTarget.Copy();
// Assign the copy to the target.
target.RobTarget = newRobTarget;
// Check if the target is invisible, and make it visible and yellow.
if (!target.Visible)
{
target.Visible = true;
Color col = Color.Yellow;
target.Color = col;
}
// Make the target's grapical display size twice as large.
target.FrameSize = target.FrameSize * 2;
// Get the transform and output its values using the logger.
Logger.AddMessage(new LogMessage("Transform of target: " + target.Name
+ "; X: " + target.Transform.X
+ "; Y: " + target.Transform.Y
+ "; Z: " + target.Transform.Z
+ "; Rx: " + target.Transform.RX
+ "; Ry: " + target.Transform.RY
+ "; Rz: " + target.Transform.RZ
));
// Get the ReferenceFrame of the target.
Transform refFrame = target.ReferenceFrame;
// Show the reference frame in the graphics.
target.ShowReferenceFrame = true;
// If the AxisDirection of the target is undefined then set it to negative x.
if (target.ApproachVector == AxisDirection.Undefined)
{
target.ApproachVector = AxisDirection.NegativeX;
}
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
ShowReferenceFrame
Gets or sets a value indicating whether the ReferenceFrame will be displayed in the graphics
Declaration
public bool ShowReferenceFrame { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Examples
Get/Set ShowReferenceFrame.
Project.UndoContext.BeginUndoStep("Target Properties");
try
{
// Instance active station.
Station stn = Station.ActiveStation;
// Get the active workobject.
RsWorkObject wobj = stn.ActiveTask.ActiveWorkObject;
// Create a new RsRobTarget and add it to ActiveTask.
RsRobTarget robTarget = new RsRobTarget();
robTarget.Name = stn.ActiveTask.GetValidRapidName("MyRobTarget", "_", 10);
stn.ActiveTask.DataDeclarations.Add(robTarget);
// Create an RsTarget from wobj and RobTarget.
RsTarget target = new RsTarget(wobj, robTarget);
// Add RsTarget to ActiveTask.
stn.ActiveTask.Targets.Add(target);
// Set the name of the target.
target.Name = robTarget.Name;
// Add a custom attribute to the target.
target.Attributes.Add("MyAttribute", "10");
// Output the project that the target is part of, and the parent of the target.
Logger.AddMessage(new LogMessage("The target: " + target.Name + " is part of the project: " +
target.ContainingProject.Name + ". The targets parent is: " + target.Parent.Name));
// Output the ToString-reprentation of the target and its types diplay name.
Logger.AddMessage(new LogMessage("The targets ToString representation is '" +
target.ToString() + "' and its TypeDisplayName is '" + target.TypeDisplayName + "'."));
// Set the workobject of the target as the active workobject.
stn.ActiveTask.ActiveWorkObject = target.WorkObject;
// Create a copy of the RobTarget.
RsRobTarget newRobTarget = (RsRobTarget)robTarget.Copy();
// Assign the copy to the target.
target.RobTarget = newRobTarget;
// Check if the target is invisible, and make it visible and yellow.
if (!target.Visible)
{
target.Visible = true;
Color col = Color.Yellow;
target.Color = col;
}
// Make the target's grapical display size twice as large.
target.FrameSize = target.FrameSize * 2;
// Get the transform and output its values using the logger.
Logger.AddMessage(new LogMessage("Transform of target: " + target.Name
+ "; X: " + target.Transform.X
+ "; Y: " + target.Transform.Y
+ "; Z: " + target.Transform.Z
+ "; Rx: " + target.Transform.RX
+ "; Ry: " + target.Transform.RY
+ "; Rz: " + target.Transform.RZ
));
// Get the ReferenceFrame of the target.
Transform refFrame = target.ReferenceFrame;
// Show the reference frame in the graphics.
target.ShowReferenceFrame = true;
// If the AxisDirection of the target is undefined then set it to negative x.
if (target.ApproachVector == AxisDirection.Undefined)
{
target.ApproachVector = AxisDirection.NegativeX;
}
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Transform
Gets a Transform that specifies the position of the target.
Declaration
public Transform Transform { get; }
Property Value
Type | Description |
---|---|
Transform |
Remarks
The local Matrix is relative to the WorkObject. Changing the transform will change the Frame of the RobTarget.
Examples
Get Transform.
Project.UndoContext.BeginUndoStep("Target Properties");
try
{
// Instance active station.
Station stn = Station.ActiveStation;
// Get the active workobject.
RsWorkObject wobj = stn.ActiveTask.ActiveWorkObject;
// Create a new RsRobTarget and add it to ActiveTask.
RsRobTarget robTarget = new RsRobTarget();
robTarget.Name = stn.ActiveTask.GetValidRapidName("MyRobTarget", "_", 10);
stn.ActiveTask.DataDeclarations.Add(robTarget);
// Create an RsTarget from wobj and RobTarget.
RsTarget target = new RsTarget(wobj, robTarget);
// Add RsTarget to ActiveTask.
stn.ActiveTask.Targets.Add(target);
// Set the name of the target.
target.Name = robTarget.Name;
// Add a custom attribute to the target.
target.Attributes.Add("MyAttribute", "10");
// Output the project that the target is part of, and the parent of the target.
Logger.AddMessage(new LogMessage("The target: " + target.Name + " is part of the project: " +
target.ContainingProject.Name + ". The targets parent is: " + target.Parent.Name));
// Output the ToString-reprentation of the target and its types diplay name.
Logger.AddMessage(new LogMessage("The targets ToString representation is '" +
target.ToString() + "' and its TypeDisplayName is '" + target.TypeDisplayName + "'."));
// Set the workobject of the target as the active workobject.
stn.ActiveTask.ActiveWorkObject = target.WorkObject;
// Create a copy of the RobTarget.
RsRobTarget newRobTarget = (RsRobTarget)robTarget.Copy();
// Assign the copy to the target.
target.RobTarget = newRobTarget;
// Check if the target is invisible, and make it visible and yellow.
if (!target.Visible)
{
target.Visible = true;
Color col = Color.Yellow;
target.Color = col;
}
// Make the target's grapical display size twice as large.
target.FrameSize = target.FrameSize * 2;
// Get the transform and output its values using the logger.
Logger.AddMessage(new LogMessage("Transform of target: " + target.Name
+ "; X: " + target.Transform.X
+ "; Y: " + target.Transform.Y
+ "; Z: " + target.Transform.Z
+ "; Rx: " + target.Transform.RX
+ "; Ry: " + target.Transform.RY
+ "; Rz: " + target.Transform.RZ
));
// Get the ReferenceFrame of the target.
Transform refFrame = target.ReferenceFrame;
// Show the reference frame in the graphics.
target.ShowReferenceFrame = true;
// If the AxisDirection of the target is undefined then set it to negative x.
if (target.ApproachVector == AxisDirection.Undefined)
{
target.ApproachVector = AxisDirection.NegativeX;
}
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Visible
Gets or sets whether a target frame is visible in the graphics.
Declaration
public bool Visible { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Examples
Get/Set Visible.
Project.UndoContext.BeginUndoStep("Target Properties");
try
{
// Instance active station.
Station stn = Station.ActiveStation;
// Get the active workobject.
RsWorkObject wobj = stn.ActiveTask.ActiveWorkObject;
// Create a new RsRobTarget and add it to ActiveTask.
RsRobTarget robTarget = new RsRobTarget();
robTarget.Name = stn.ActiveTask.GetValidRapidName("MyRobTarget", "_", 10);
stn.ActiveTask.DataDeclarations.Add(robTarget);
// Create an RsTarget from wobj and RobTarget.
RsTarget target = new RsTarget(wobj, robTarget);
// Add RsTarget to ActiveTask.
stn.ActiveTask.Targets.Add(target);
// Set the name of the target.
target.Name = robTarget.Name;
// Add a custom attribute to the target.
target.Attributes.Add("MyAttribute", "10");
// Output the project that the target is part of, and the parent of the target.
Logger.AddMessage(new LogMessage("The target: " + target.Name + " is part of the project: " +
target.ContainingProject.Name + ". The targets parent is: " + target.Parent.Name));
// Output the ToString-reprentation of the target and its types diplay name.
Logger.AddMessage(new LogMessage("The targets ToString representation is '" +
target.ToString() + "' and its TypeDisplayName is '" + target.TypeDisplayName + "'."));
// Set the workobject of the target as the active workobject.
stn.ActiveTask.ActiveWorkObject = target.WorkObject;
// Create a copy of the RobTarget.
RsRobTarget newRobTarget = (RsRobTarget)robTarget.Copy();
// Assign the copy to the target.
target.RobTarget = newRobTarget;
// Check if the target is invisible, and make it visible and yellow.
if (!target.Visible)
{
target.Visible = true;
Color col = Color.Yellow;
target.Color = col;
}
// Make the target's grapical display size twice as large.
target.FrameSize = target.FrameSize * 2;
// Get the transform and output its values using the logger.
Logger.AddMessage(new LogMessage("Transform of target: " + target.Name
+ "; X: " + target.Transform.X
+ "; Y: " + target.Transform.Y
+ "; Z: " + target.Transform.Z
+ "; Rx: " + target.Transform.RX
+ "; Ry: " + target.Transform.RY
+ "; Rz: " + target.Transform.RZ
));
// Get the ReferenceFrame of the target.
Transform refFrame = target.ReferenceFrame;
// Show the reference frame in the graphics.
target.ShowReferenceFrame = true;
// If the AxisDirection of the target is undefined then set it to negative x.
if (target.ApproachVector == AxisDirection.Undefined)
{
target.ApproachVector = AxisDirection.NegativeX;
}
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
WorkObject
Gets or sets the RsWorkObject associated with the target.
Declaration
public RsWorkObject WorkObject { get; set; }
Property Value
Type | Description |
---|---|
RsWorkObject |
Examples
Get/Set WorkObject.
Project.UndoContext.BeginUndoStep("Target Properties");
try
{
// Instance active station.
Station stn = Station.ActiveStation;
// Get the active workobject.
RsWorkObject wobj = stn.ActiveTask.ActiveWorkObject;
// Create a new RsRobTarget and add it to ActiveTask.
RsRobTarget robTarget = new RsRobTarget();
robTarget.Name = stn.ActiveTask.GetValidRapidName("MyRobTarget", "_", 10);
stn.ActiveTask.DataDeclarations.Add(robTarget);
// Create an RsTarget from wobj and RobTarget.
RsTarget target = new RsTarget(wobj, robTarget);
// Add RsTarget to ActiveTask.
stn.ActiveTask.Targets.Add(target);
// Set the name of the target.
target.Name = robTarget.Name;
// Add a custom attribute to the target.
target.Attributes.Add("MyAttribute", "10");
// Output the project that the target is part of, and the parent of the target.
Logger.AddMessage(new LogMessage("The target: " + target.Name + " is part of the project: " +
target.ContainingProject.Name + ". The targets parent is: " + target.Parent.Name));
// Output the ToString-reprentation of the target and its types diplay name.
Logger.AddMessage(new LogMessage("The targets ToString representation is '" +
target.ToString() + "' and its TypeDisplayName is '" + target.TypeDisplayName + "'."));
// Set the workobject of the target as the active workobject.
stn.ActiveTask.ActiveWorkObject = target.WorkObject;
// Create a copy of the RobTarget.
RsRobTarget newRobTarget = (RsRobTarget)robTarget.Copy();
// Assign the copy to the target.
target.RobTarget = newRobTarget;
// Check if the target is invisible, and make it visible and yellow.
if (!target.Visible)
{
target.Visible = true;
Color col = Color.Yellow;
target.Color = col;
}
// Make the target's grapical display size twice as large.
target.FrameSize = target.FrameSize * 2;
// Get the transform and output its values using the logger.
Logger.AddMessage(new LogMessage("Transform of target: " + target.Name
+ "; X: " + target.Transform.X
+ "; Y: " + target.Transform.Y
+ "; Z: " + target.Transform.Z
+ "; Rx: " + target.Transform.RX
+ "; Ry: " + target.Transform.RY
+ "; Rz: " + target.Transform.RZ
));
// Get the ReferenceFrame of the target.
Transform refFrame = target.ReferenceFrame;
// Show the reference frame in the graphics.
target.ShowReferenceFrame = true;
// If the AxisDirection of the target is undefined then set it to negative x.
if (target.ApproachVector == AxisDirection.Undefined)
{
target.ApproachVector = AxisDirection.NegativeX;
}
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Methods
AfterLoad(PimDocument)
Declaration
protected override void AfterLoad(PimDocument doc)
Parameters
Type | Name | Description |
---|---|---|
RobotStudio.API.Persistence.PimDocument | doc |
Overrides
Copy()
Creates a deep copy of the target, with the same workobject and robtarget
Declaration
public ProjectObject Copy()
Returns
Type | Description |
---|---|
ProjectObject |
Examples
Copy Target.
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();
}
Highlight()
Highlights the graphical frame in the default selection color.
Declaration
public void Highlight()
Highlight(Color)
Sets a temporary color of the graphical frame.
Declaration
public void Highlight(Color color)
Parameters
Type | Name | Description |
---|---|---|
Color | color | The color that should be used to highlight the frame |
Examples
Target Highlight.
Project.UndoContext.BeginUndoStep("Target Properties");
try
{
// Instance active station.
Station stn = Station.ActiveStation;
// Get the active workobject.
RsWorkObject wobj = stn.ActiveTask.ActiveWorkObject;
// Create a new RsRobTarget and add it to ActiveTask.
RsRobTarget robTarget = new RsRobTarget();
robTarget.Name = stn.ActiveTask.GetValidRapidName("MyRobTarget", "_", 10);
stn.ActiveTask.DataDeclarations.Add(robTarget);
// Create an RsTarget from wobj and RobTarget.
RsTarget target = new RsTarget(wobj, robTarget);
// Add RsTarget to ActiveTask.
stn.ActiveTask.Targets.Add(target);
// Set the name of the target.
target.Name = robTarget.Name;
// Add a custom attribute to the target.
target.Attributes.Add("MyAttribute", "10");
// Output the project that the target is part of, and the parent of the target.
Logger.AddMessage(new LogMessage("The target: " + target.Name + " is part of the project: " +
target.ContainingProject.Name + ". The targets parent is: " + target.Parent.Name));
// Output the ToString-reprentation of the target and its types diplay name.
Logger.AddMessage(new LogMessage("The targets ToString representation is '" +
target.ToString() + "' and its TypeDisplayName is '" + target.TypeDisplayName + "'."));
// Set the workobject of the target as the active workobject.
stn.ActiveTask.ActiveWorkObject = target.WorkObject;
// Create a copy of the RobTarget.
RsRobTarget newRobTarget = (RsRobTarget)robTarget.Copy();
// Assign the copy to the target.
target.RobTarget = newRobTarget;
// Check if the target is invisible, and make it visible and yellow.
if (!target.Visible)
{
target.Visible = true;
Color col = Color.Yellow;
target.Color = col;
}
// Make the target's grapical display size twice as large.
target.FrameSize = target.FrameSize * 2;
// Get the transform and output its values using the logger.
Logger.AddMessage(new LogMessage("Transform of target: " + target.Name
+ "; X: " + target.Transform.X
+ "; Y: " + target.Transform.Y
+ "; Z: " + target.Transform.Z
+ "; Rx: " + target.Transform.RX
+ "; Ry: " + target.Transform.RY
+ "; Rz: " + target.Transform.RZ
));
// Get the ReferenceFrame of the target.
Transform refFrame = target.ReferenceFrame;
// Show the reference frame in the graphics.
target.ShowReferenceFrame = true;
// If the AxisDirection of the target is undefined then set it to negative x.
if (target.ApproachVector == AxisDirection.Undefined)
{
target.ApproachVector = AxisDirection.NegativeX;
}
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
JumpTo(RsToolData)
Jumps the tool and the attached robot to the target.
Declaration
olete("Use JumpToAsync() instead")]
public bool JumpTo(RsToolData tool)
Parameters
Type | Name | Description |
---|---|---|
RsToolData | tool | The tool data to perform the jump with |
Returns
Type | Description |
---|---|
Boolean |
Remarks
In order to be able to jump to a target there has to be a tool in the station. You also have to make sure the VC is running.
Examples
JumpTo Target.
Project.UndoContext.BeginUndoStep("Jump To Target");
try
{
// Instance active station.
Station stn = Station.ActiveStation;
// Get a target.
RsTarget target = stn.ActiveTask.Targets[0];
// Jump to the target. Requires an active tool in the station and a running VC.
target.JumpTo(stn.ActiveTask.ActiveTool);
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
JumpTo(RsToolData, ConfigurationData)
Jumps the tool and the attached robot to the target with specified configuration. Completely ignores the configuration already defined.
Declaration
public bool JumpTo(RsToolData tool, ConfigurationData configuration)
Parameters
Type | Name | Description |
---|---|---|
RsToolData | tool | The tool data to perform the jump with |
ConfigurationData | configuration | The suggested configuration to be used instead of the defined one. |
Returns
Type | Description |
---|---|
Boolean |
Remarks
In order to be able to jump to a target there has to be a tool in the station. You also have to make sure the VC is running.
JumpTo(RsToolData, ConfigurationData, Boolean)
Tries to jump the tool and the attached robot to the target with specified configuration, ignoring the configuration already defined on the target.
Declaration
public bool JumpTo(RsToolData tool, ConfigurationData configuration, bool updateController)
Parameters
Type | Name | Description |
---|---|---|
RsToolData | tool | The tool data to perform the jump with |
ConfigurationData | configuration | The suggested configuration to be used instead of the defined one. |
Boolean | updateController | Specifies if the joint values in the controller shall be updated in addition to the joint values of the mechanism. |
Returns
Type | Description |
---|---|
Boolean |
Remarks
In order to be able to jump to a target there has to be a tool in the station. You also have to make sure the VC is running.
JumpTo(RsToolData, Boolean)
Jumps the tool and the attached robot to the target. Optionally updates the joint values in the virtual controller. Updating the joint values in the controller is time consuning compared to only updating the Mechanism joint value. If you need to frequently call this method, it is recomended to update the joint values in the controller, only for the last call.
Declaration
olete("Use JumpToAsync() instead")]
public bool JumpTo(RsToolData tool, bool updateController)
Parameters
Type | Name | Description |
---|---|---|
RsToolData | tool | The tool data to perform the jump with |
Boolean | updateController | Specifies if the joint values in the controller shall be updated in addition to the joint values of the mechanism. |
Returns
Type | Description |
---|---|
Boolean |
Remarks
In order to be able to jump to a target there has to be a tool in the station. You also have to make sure the VC is running.
Examples
JumpTo Target.
Project.UndoContext.BeginUndoStep("Jump To Target");
try
{
// Instance active station.
Station stn = Station.ActiveStation;
// Get a target.
RsTarget target = stn.ActiveTask.Targets[0];
// Jump to the target. Requires an active tool in the station and a running VC.
target.JumpTo(stn.ActiveTask.ActiveTool);
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
JumpTo(RsToolData, ValueType)
Declaration
olete("Use JumpTo(RsToolData tool, ConfigurationData configuration) instead")]
public bool JumpTo(RsToolData tool, ValueType configuration)
Parameters
Type | Name | Description |
---|---|---|
RsToolData | tool | |
ValueType | configuration |
Returns
Type | Description |
---|---|
Boolean |
JumpTo(RsToolData, ValueType, Boolean)
Declaration
olete("Use JumpToAsync(RsToolData tool, ConfigurationData configuration, bool updateController) instead")]
public bool JumpTo(RsToolData tool, ValueType configuration, bool updateController)
Parameters
Type | Name | Description |
---|---|---|
RsToolData | tool | |
ValueType | configuration | |
Boolean | updateController |
Returns
Type | Description |
---|---|
Boolean |
JumpToAsync(RsToolData, ConfigurationData, Boolean)
Tries to jump the tool and the attached robot to the target with specified configuration, ignoring the configuration already defined.
Declaration
public Task<bool> JumpToAsync(RsToolData tool, ConfigurationData configuration, bool updateController)
Parameters
Type | Name | Description |
---|---|---|
RsToolData | tool | The tool data to perform the jump with |
ConfigurationData | configuration | The suggested configuration to be used instead of the defined one. |
Boolean | updateController | Specifies if the joint values in the controller shall be updated in addition to the joint values of the mechanism. |
Returns
Type | Description |
---|---|
Task<Boolean> |
Remarks
In order to be able to jump to a target there has to be a tool in the station. You also have to make sure the VC is running.
JumpToAsync(RsToolData, Boolean)
Jumps the tool and the attached robot to the target. Optionally updates the joint values in the virtual controller. Updating the joint values in the controller is time consuning compared to only updating the Mechanism joint value. If you need to frequently call this method, it is recomended to update the joint values in the controller, only for the last call.
Declaration
public Task<bool> JumpToAsync(RsToolData tool, bool updateController)
Parameters
Type | Name | Description |
---|---|---|
RsToolData | tool | The tool data to perform the jump with |
Boolean | updateController | Specifies if the joint values in the controller shall be updated in addition to the joint values of the mechanism. |
Returns
Type | Description |
---|---|
Task<Boolean> |
Examples
JumpTo Target.
Project.UndoContext.BeginUndoStep("Jump To Target");
try
{
// Instance active station.
Station stn = Station.ActiveStation;
// Get a target.
RsTarget target = stn.ActiveTask.Targets[0];
// Jump to the target. Requires an active tool in the station and a running VC.
target.JumpTo(stn.ActiveTask.ActiveTool);
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
JumpToAsync(RsToolData, Boolean, ConfigurationMode)
Jumps the tool and the attached robot to the target. Optionally updates the joint values in the virtual controller. Updating the joint values in the controller is time consuning compared to only updating the Mechanism joint value. If you need to frequently call this method, it is recomended to update the joint values in the controller, only for the last call.
Declaration
public Task<JumpResult> JumpToAsync(RsToolData tool, bool updateController, ConfigurationMode cfgMode)
Parameters
Type | Name | Description |
---|---|---|
RsToolData | tool | The tool data to perform the jump with |
Boolean | updateController | Specifies if the joint values in the controller shall be updated in addition to the joint values of the mechanism. |
ConfigurationMode | cfgMode | Specifies how the arm configuration stored in the target shall be used. In this case this method returns true only if the mechanism can move to the specified target with its specified arm configuration. |
Returns
Type | Description |
---|---|
Task<JumpResult> |
Examples
JumpTo Target.
Project.UndoContext.BeginUndoStep("Jump To Target");
try
{
// Instance active station.
Station stn = Station.ActiveStation;
// Get a target.
RsTarget target = stn.ActiveTask.Targets[0];
// Jump to the target. Requires an active tool in the station and a running VC.
target.JumpTo(stn.ActiveTask.ActiveTool);
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
ResetHighlight()
Resets the graphical frame to the default color.
Declaration
public void ResetHighlight()
Examples
Reset Target Highlight.
Project.UndoContext.BeginUndoStep("Target Properties");
try
{
// Instance active station.
Station stn = Station.ActiveStation;
// Get the active workobject.
RsWorkObject wobj = stn.ActiveTask.ActiveWorkObject;
// Create a new RsRobTarget and add it to ActiveTask.
RsRobTarget robTarget = new RsRobTarget();
robTarget.Name = stn.ActiveTask.GetValidRapidName("MyRobTarget", "_", 10);
stn.ActiveTask.DataDeclarations.Add(robTarget);
// Create an RsTarget from wobj and RobTarget.
RsTarget target = new RsTarget(wobj, robTarget);
// Add RsTarget to ActiveTask.
stn.ActiveTask.Targets.Add(target);
// Set the name of the target.
target.Name = robTarget.Name;
// Add a custom attribute to the target.
target.Attributes.Add("MyAttribute", "10");
// Output the project that the target is part of, and the parent of the target.
Logger.AddMessage(new LogMessage("The target: " + target.Name + " is part of the project: " +
target.ContainingProject.Name + ". The targets parent is: " + target.Parent.Name));
// Output the ToString-reprentation of the target and its types diplay name.
Logger.AddMessage(new LogMessage("The targets ToString representation is '" +
target.ToString() + "' and its TypeDisplayName is '" + target.TypeDisplayName + "'."));
// Set the workobject of the target as the active workobject.
stn.ActiveTask.ActiveWorkObject = target.WorkObject;
// Create a copy of the RobTarget.
RsRobTarget newRobTarget = (RsRobTarget)robTarget.Copy();
// Assign the copy to the target.
target.RobTarget = newRobTarget;
// Check if the target is invisible, and make it visible and yellow.
if (!target.Visible)
{
target.Visible = true;
Color col = Color.Yellow;
target.Color = col;
}
// Make the target's grapical display size twice as large.
target.FrameSize = target.FrameSize * 2;
// Get the transform and output its values using the logger.
Logger.AddMessage(new LogMessage("Transform of target: " + target.Name
+ "; X: " + target.Transform.X
+ "; Y: " + target.Transform.Y
+ "; Z: " + target.Transform.Z
+ "; Rx: " + target.Transform.RX
+ "; Ry: " + target.Transform.RY
+ "; Rz: " + target.Transform.RZ
));
// Get the ReferenceFrame of the target.
Transform refFrame = target.ReferenceFrame;
// Show the reference frame in the graphics.
target.ShowReferenceFrame = true;
// If the AxisDirection of the target is undefined then set it to negative x.
if (target.ApproachVector == AxisDirection.Undefined)
{
target.ApproachVector = AxisDirection.NegativeX;
}
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Events
WorkObjectChanged
Raised when the WorkObject property changes.
Declaration
public static event ProjectObjectPropertyChangedEventHandler WorkObjectChanged
Event Type
Type | Description |
---|---|
ProjectObjectPropertyChangedEventHandler |