Translating Target
This example provides information on re-associating targets with respect to another workobject without repositioning.. This example expects targets are already created and a workobject with the name "WorkObject1" exists in RobotStudio.
Use this procedure to translate target using SetRelativeTransfrom method.
Create a variable to store the target's workobject (say oldWorkObject).
Assign new workobject to the target (target get transform to new position based new workobject).
Set relative transform of target to RobTarget's frame global matrix relative to oldWorkObject.
Solution
Create a variable to store the target's workobject (say oldWorkObject).
RsWorkObject oldWorkObject = target.WorkObject;
Assign new workobject to the target.
target.WorkObject = newWorkObject;
Set relative transform of target to RobTarget's frame global matrix relative to oldWorkObject.
target.Transform.SetRelativeTransform(oldWorkObject.ObjectFrame.GlobalMatrix , target.RobTarget.Frame.GlobalMatrix);
Example
This example provides information on re-associating targets with respect to another workobject without repositioning.
private static void TransformTargetUsingSetRelativeTransform(RsTargetCollection targets ,
RsWorkObject newWorkObject)
{
foreach (RsTarget target in targets)
{
//Create a variable to store the target's workobject (say oldWorkObject).
RsWorkObject oldWorkObject = target.WorkObject;
//Assign new workobject to the target.
target.WorkObject = newWorkObject;
//Set relative transform of target to RobTarget's frame
//global matrix relative to oldWorkObject.
target.Transform.SetRelativeTransform(oldWorkObject.ObjectFrame.GlobalMatrix ,
target.RobTarget.Frame.GlobalMatrix);
}
}
Required Namespaces
ABB.