Take coordinates from clicked position
Hi, I come from <?: prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />Germany and I?_Tm just making my degree dissertation. My subject is to program some tools in VSTA with VB.NET (RobotStudio 5.11).<?: prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Now I have a problem: I want to create a target with the coordinates of the clicked position in the graphic. So I want to create some targets only by mouse click and a self created accept button. Creating the target is no problem, but I don?_Tt know how to get the coordinates of the clicked position?
I looked in the API-Help and there I found in the namespace ABB.Robotics.RobotStudio.Stations.Forms the type ?_oGraphicpicker?__ and there the member ?_oMarkerPosition?__. Maybe I can use this?
But there is the next problem: In the namespace ABB.Robotics.RobotStudio.Stations.Form there is no type ?_oGraphicpicker?__ allthought I imported the reference ABB.Robotics.RobotStudio.Stations.Forms.
And itA's similar with the other namespaces! In VSTA, there are not all the types, that are listed in the help in the accordant namespace!
So maybe you can help me with both problems.
Thank you
Matthias
Comments
-
Perhaps you should use an addin instead of vsta. Here is some working code to pick a position (of course, its not complete, you need to stop the listener and so on):
using System;
using System.Collections.Generic;
using System.Text;
using ABB.Robotics.RobotStudio;
using ABB.Robotics.Math;
using ABB.Robotics.RobotStudio.Environment;
using ABB.Robotics.RobotStudio.Stations;
using ABB.Robotics.RobotStudio.Stations.Forms;
namespace MousePicker
{
public class Main
{
static void AddinMain()
{
RibbonTab ribbon = UIEnvironment.RibbonTabs["AddIns"];
RibbonGroup group = ribbon.Groups["SOMEID"];
if (group == null)
{
group = new RibbonGroup("SOMEID", "PickerGroup");
ribbon.Groups.Add(group);
}
CommandBarButton button = new CommandBarButton("RS_MOUSEPICK_ID", "Start MousePicker");
button.Enabled = true;
button.ExecuteCommand += new ExecuteCommandEventHandler(button_ExecuteCommand);
group.Controls.Add(button);
}
static void button_ExecuteCommand(object sender, ExecuteCommandEventArgs e)
{
Station station = Project.ActiveProject as Station;
GraphicPicker.GraphicPick += new GraphicPickEventHandler(Pick);
}
static void Pick(object sender, GraphicPickEventArgs e)
{
Vector3 pos = e.PickedPosition;
Logger.AddMessage(new LogMessage("Picked pos: " + pos.ToString()));
}
}
}
Hope it hels - let me know if you need the library/project files.
apox2009-08-04 12:03:020 -
Thank you for your answer.Is it able to use an VisualStudio-Addin with VisualBasic? Or only with C#? Because in the API documentation it is only illustrated for C#.Thank you for your code, iA'll test it soon. But first I have to translate it to VB.But I think in my references there is no graphicpicker namespace...are those types i miss available for download? What are those library files you offered to me?0
-
[QUOTE=matz]
Is it able to use an VisualStudio-Addin with VisualBasic? Or only with C#? Because in the API documentation it is only illustrated for C#.[/QUOTE]
Yes, that is possible. You can use C#, VisualBasic in VSTA or in an Addin (dll).
[QUOTE=matz]Thank you for your code, iA'll test it soon. But first I have to translate it to VB.But I think in my references there is no graphicpicker namespace...are those types i miss available for download? What are those library files you offered to me?[/QUOTE]
In case of an addin you need to refernence some abb libraries which are located in the installation folder of robotstudio and named ABB.Robotics.***.dll
0 -
Hello again,I just tried to run your code in vsta. There is the same mistake...some types are unknown, allthough i use the correct refferences. Maybe there was a mistake in the installation of ronotstudio??Tomorrow I will try to create an abbin with Visual Basic 2008 Express. But IA'm not sure how to make this? There is no possibility to create any new addin when I click on new project in Visual Basic 2008 Express...In the API help itA's shown how to do this manually for C#, but not for VB...0
-
Hello,
my code ist not for VSTA. The code is for an Addin, which is a DLL (dynamic link library). You need Visual Studio to create a C# or VisualBasic DLL project, copy this code and add the abb references. You will get a DLL which you must copy into robotstudio installation folder -> BinAddins.
0 -
Ok thank you, now I understand! IA'll try it.So I have still a fundamental question: Do you advise to use an Addin? Why are the codes for Addin and VSTA different (when I use the same references)?0
-
As far as i know not everything was supported in vsta - perhaps it changed. i prefer to use Addins
apox2009-08-05 10:02:460 -
Ok thank you!But also with an Addin, my problem is not solved! The following problem is with VSTA and Visual Studio 2008!Those ABB-References are imported:ABB.Robotics.RobotStudio.ProxyABB.Robotics.RobotStudio.Stations.FormsSo, the Class Graphicpicker is not available!If I import in addition ABB.Robotics.RobotStudio.Stations, the Class Graphicpicker is available!In ABB.Robotics.RobotStudio.Proxy, many references are contained! So there is also one called ABB.Robotics.RobotStudio.Stations!But the types in ABB.Robotics.RobotStudio.Stations (from ABB.Robotics.RobotStudio.Proxy.dll) are different to the types in ABB.Robotics.RobotStudio.Stations (from ABB.Robotics.RobotStudio.Stations.dll)!!!I get the following error message by creating a new object of the type station (Dim test as New Station):"Station" is ambiguous in the namespace "ABB.Robotics.RobotStudio.Stations"This is because the type Station exists in both references called ABB.Robotics.RobotStudio.Stations! So the Software does not know which one to use.After deleting the reference ABB.Robotics.RobotStudio.Stations (from ABB.Robotics.RobotStudio.Stations.dll) the error message is gone, but the type graphicpicker is no longer available!What can I do to solve this? I think thatA's the reason of my problem!0
-
Hi,
if you use VSTA, you need the proxy reference. If you use an Addin (dll), you need all other ABB....dll references without the proxy reference!
0 -
Thank you, I think that is my problem.
But I have some problems to create working Add-Ins, so IA'll start a new topic!
But thank you for your help so far!
0 -
Ok, this code works!Is it possible to take also the orientation from the clicked position? I need a 4x4 matrix to position a target. I want the target on the clicked position, with its z-axis in the direction of the normal from the clicked surface. This addin should work like the function "Create Move Instruction" with the option "Align Target with closest part" in RS (without creating the target, I only need the 4x4 matrix).Thank youMatz0
-
A clicked position does not have a orientation. You have to calculate the orientation (as you wrote "Align Target with closest part").
Perhaps you could use the function
GetNormalToSurface(Vector3, Vector3%, Vector3%, Face%)
found in the class "Part".
0 -
Thanks, works very good!With GetNormalToSurface(Vector3, Vector3%, Vector3%, Face%) I get the vector of the normal from the surface. Then I had to create 2 Vectors that are perpendicularly on this normal (by cross product). These 3 Vectors I could send to the matrix of a target, and so I had the orientation I want!0
Categories
- All Categories
- 5.5K RobotStudio
- 396 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 249 ScreenMaker
- 2.7K Robot Controller
- 310 IRC5
- 59 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 786 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 5 Job listings