# VSTA Target Coordinates

**URL:** <https://tech-community.robotics.abb.com/t/vsta-target-coordinates/1873>\
**Category:** RobotStudio\
**Created:** [May 23, 2008, 6:40am UTC](https://tech-community.robotics.abb.com/t/vsta-target-coordinates/1873 "2008-05-23T06:40:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mattdavis](https://avatars.discourse-cdn.com/v4/letter/m/8e7dd6/32.png) [@mattdavis](https://tech-community.robotics.abb.com/u/mattdavis)\
**Post date:** [May 23, 2008, 6:40am UTC](https://tech-community.robotics.abb.com/t/vsta-target-coordinates/1873/1 "2008-05-23T06:40:05Z")

</div>

Hi,  
I am trying to write a vsta macro to simplify program with a gantry robot. The macro just takes the selected point and updates the gantry (external axis) to be within a certain distance of the target.

The trouble im having is i want to get the targets coordinates in the world coordinate system.

ProjectObject selObject = Project.ActiveProject.Selection.SingleSelectedObject as ProjectObject;  
RsTarget Target = selObject as RsTarget;  
Double TargetX = Target.RobTarget.Frame.X;

this is the code im using to extra the selected targets coordinates. This and a number of other items will give me the targets coordinates in the parent coordinate system. Is there a simple way to get it in the world coordinate system?

Thanks

---

<div class="post-metadata">

**Author:** ![Niklas\_Skoglund](https://avatars.discourse-cdn.com/v4/letter/n/5fc32e/32.png) [@Niklas\_Skoglund](https://tech-community.robotics.abb.com/u/Niklas_Skoglund)\
**Post date:** [May 23, 2008, 9:56am UTC](https://tech-community.robotics.abb.com/t/vsta-target-coordinates/1873/2 "2008-05-23T09:56:38Z")

</div>

Hi,

as in RAPID, a robtarget is used together with a workobject.

The coordinates of the robtarget is relative the workobject.

In RobotStudio the object RsTarget represents the combination of a robtarget and a workobject.

The following sample logs out a targets translation in parent and world coordinate systems.

_This sample does not use the Transform.GlobalMatrix of the RsRobtarget, because it is not defined. (The RsRobtarget must be used together with a RsWorkobject in order to have a global transform.)_

```auto

public void Macro_Sample1()

{

Station s = Project.ActiveProject as Station;

RsTask task = s.ActiveTask;

RsTarget t = task.Targets[0];

Vector3 parentTranslation = t.Transform.Matrix.Translation;

Logger.AddMessage(new LogMessage("xyz in parent: " + parentTranslation.ToString()));

Vector3 worldTranslation = t.Transform.GlobalMatrix.Translation;

Logger.AddMessage(new LogMessage("xyz in world: " + worldTranslation.ToString()));

}

```

In my station I got this output (coordinates in meters):

xyz in parent: [2 0.5 1.5]

xyz in world: [2.5 1 2]

The RAPID code for my robtarget and workobject that gives the above result looks like this:[CODE]

CONST robtarget Target\_10:=[[2000,500,1500],[1,0,0,0],[0,0,0,0],[0,9E9,9E9,9E9,9E9,9E9]]; TASK PERS wobjdata Workobject\_1:=[FALSE,TRUE,“”,[[0,0,0],[1,0,0,0]],[[500,500,500],[1,0,0,0]]];

[/CODE]

---

<div class="post-metadata">

**Author:** ![mattdavis](https://avatars.discourse-cdn.com/v4/letter/m/8e7dd6/32.png) [@mattdavis](https://tech-community.robotics.abb.com/u/mattdavis)\
**Post date:** [May 30, 2008, 8:07am UTC](https://tech-community.robotics.abb.com/t/vsta-target-coordinates/1873/3 "2008-05-30T08:07:08Z")

</div>

seems i actually need

to add an extra .x on the end of that to get a double..

but then i get an error say i am improperly using an rstarget.

# RobotStudio .NET exception dump

Base exception:  
System.Reflection.TargetInvocationException, mscorlib  
System.NotSupportedException, mscorlib

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —\> System.NotSupportedException: Use RsTarget object!  
at ABB.Robotics.RobotStudio.Stations.RsRobTarget.InternalGetGlo balFrame()  
at ABB.Robotics.RobotStudio.Stations.Transform.get\_GlobalMatrix ()  
— End of inner exception stack trace —  
at System.RuntimeMethodHandle.\_InvokeMethodFast(Object target, Object arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)  
at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)  
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean skipVisibilityChecks)  
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture)  
at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object index, CultureInfo culture)  
at Microsoft.VisualStudio.Tools.Applications.RemotePropertyInfo Adapter.System.AddIn.Contract.Automation.IRemotePropertyInfo Contract.GetValue(IRemoteObjectContract target, BindingFlags bindingFlags, IRemoteArgumentArrayContract index, Int32 lcid)

Server stack trace:  
at Microsoft.VisualStudio.Tools.Applications.RemoteMethodInfoAd apter.System.AddIn.Contract.Automation.IRemoteMethodInfoCont ract.Invoke(IRemoteObjectContract target, BindingFlags bindingFlags, IRemoteArgumentArrayContract arguments, Int32 lcid)  
at System.Runtime.Remoting.Messaging.StackBuilderSink.\_PrivateP rocessMessage(IntPtr md, Object args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object& outArgs)  
at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivatePr ocessMessage(RuntimeMethodHandle md, Object args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object& outArgs)  
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProce ssMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)

Exception rethrown at [0]:  
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessag e(IMessage reqMsg, IMessage retMsg)  
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(Mess ageData& msgData, Int32 type)  
at System.AddIn.Contract.Automation.IRemoteMethodInfoContract.I nvoke(IRemoteObjectContract target, BindingFlags bindingFlags, IRemoteArgumentArrayContract parameters, Int32 localeId)  
at ABBInternal.VstaServices.VstaMacro.Execute()

---

<div class="post-metadata">

**Author:** ![mattdavis](https://avatars.discourse-cdn.com/v4/letter/m/8e7dd6/32.png) [@mattdavis](https://tech-community.robotics.abb.com/u/mattdavis)\
**Post date:** [June 5, 2008, 4:12am UTC](https://tech-community.robotics.abb.com/t/vsta-target-coordinates/1873/4 "2008-06-05T04:12:59Z")

</div>

is there a manual or webpage with information about all the objects available throught the vsta interface?

Any other ideas on how to get the global xyz position of a target, i can only succesfully get parent coordinates even though the other appear to be there.

---

<div class="post-metadata">

**Author:** ![Niklas\_Skoglund](https://avatars.discourse-cdn.com/v4/letter/n/5fc32e/32.png) [@Niklas\_Skoglund](https://tech-community.robotics.abb.com/u/Niklas_Skoglund)\
**Post date:** [June 10, 2008, 9:31pm UTC](https://tech-community.robotics.abb.com/t/vsta-target-coordinates/1873/5 "2008-06-10T21:31:35Z")

</div>

Most methods in the namespaces ABB.Robotics.RobotStudio and ABB.Robotics.RobotStudio.Stations are supported by VSTA.

If not, it should be documented in the API documentation, which is available from Help-\>RobotStudio API Help (Alt+F1).

---

<div class="post-metadata">

**Author:** ![mattdavis](https://avatars.discourse-cdn.com/v4/letter/m/8e7dd6/32.png) [@mattdavis](https://tech-community.robotics.abb.com/u/mattdavis)\
**Post date:** [June 11, 2008, 2:49am UTC](https://tech-community.robotics.abb.com/t/vsta-target-coordinates/1873/6 "2008-06-11T02:49:46Z")

</div>

thanks very much for that.

works perfectly.
