Create Add-In with Visual Studio (Visual Basic)
in my last topic I recognized, that I should prefer an Add-In instead of using VSTA!
But all I tried didnA't work!
So can anybody give me a full instruction how to create an Add-In and how to load and use it?
First I open in Visual Studio a new Add-In project. But what should I do after this? I took the code from the API-help and translated it to VB. But what then? Where to write a working procedure(sub) in the created Add-Inn?
After creating the Add-In, how can I load it and how can I start any procedure, when the Add-In is loaded?
I want to do the following things:
Load a windows form including some windows form buttons. These buttons should start procedures in RobotStudio.
But can anybody tell me how to start the first procedure (starting an empty windows form in Robotstudio).
If I understood this, I think itA's no problem for me to create new modules an classes in the Add-In.
Than you for your help.
Matthias
Comments
-
I will give you short instructions how to do it with C#, but it should be the same way with VisualBasic (a window form is still missing - if its working for you let me know then ill explain the forms).
1. Create a new Project, Visual C#, Class Library, Name "SampleAddin"
2. Create a new empty class called "Class1"
3. Create entry point "AddinMain", fill with code:
static void AddinMain()
{
RibbonTab ribbon = UIEnvironment.RibbonTabs["AddIns"];
RibbonGroup group = ribbon.Groups["MY_ID"];
if (group == null)
{
group = new RibbonGroup("MY_ID", "MyGroup");
ribbon.Groups.Add(group);
}
CommandBarButton button = new CommandBarButton("RS_MYBUTTON_ID", "My Button label...");
button.Enabled = true;
button.ExecuteCommand += new ExecuteCommandEventHandler(button_ExecuteCommand);
group.Controls.Add(button);
}
// the event handler
static void button_ExecuteCommand(object sender, ExecuteCommandEventArgs e)
{
}
4. Add missing referencesMenu "Project->Add Reference", select "Browse",
change location to : %PROGRAMFILES%ABB Industrial ITRobotics ITRobotStudio 5.12Bin
and select:
ABB.Robotics.Math.dll
ABB.Robotics.RobotStudio.dll
ABB.Robotics.RobotStudio.Environment.dll
ABB.Robotics.RobotStudio.Stations.dll
ABB.Robotics.RobotStudio.Stations.Forms.dllSelect "OK"
5. Add missing using directives:using ABB.Robotics.RobotStudio;
6. Copy the generated DLL into %PROGRAMFILES%ABB Industrial ITRobotics ITRobotStudio 5.12BinAddins
using ABB.Robotics.RobotStudio.Environment;
using ABB.Robotics.RobotStudio.Stations;Start RobotStudio, create an empty station, you get a new group and button in the Addins section
0 -
Thank you, your cC# ode works very good!But is there any easier way to load the addin? Because when I change some code in the addin, I have to close RobotStudio and copy the new DLL into %PROGRAMFILES%ABB Industrial ITRobotics ITRobotStudio 5.12BinAddins.Your translated code to VB should look like this:
Imports ABB.Robotics.RobotStudio<?: prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Imports ABB.Robotics.RobotStudio.Environment
Imports ABB.Robotics.RobotStudio.Stations
Public Class Addin
Shared Sub CreateButton()
Dim ribbon As RibbonTab = UIEnvironment.RibbonTabs("AddIns")
Dim group As RibbonGroup = ribbon.Groups("MY_ID")
If group Is Nothing Then
group = New RibbonGroup("MY_ID", "MyGroup")
ribbon.Groups.Add(group)
End If
Dim button As New CommandBarButton("RS_MYBUTTON_ID", "My Button label...")
button.Enabled = True
AddHandler button.ExecuteCommand, AddressOf button_ExecuteCommand
group.Controls.Add(button)
End Sub 'AddinMain
' the event handler
Shared Sub button_ExecuteCommand(ByVal sender As Object, ByVal e As ExecuteCommandEventArgs)
End Sub 'button_ExecuteCommand
End Class
But the VB-addin doesnA't work! RobotStudio doesnA't load it, allthough itA's in the correct folder...0 -
No, as far as i know you have to close RS, change your code, rebuild and start RS.
> End Sub 'AddinMain
There is nothing like Sub AddinMain() in your code? Im not really familiar with VB.
0 -
My main sub is called Shared Sub CreateButton, that should be the same than static void AddinMain in your code!
0 -
The entry point MUST be called "AddinMain"- that is what RS is looking for.
0 -
Thank you very very much!It works! Robotstudio doesnA't even load the Addin if the first sub isnA't called "AddinMain"!!! Then it works!The only thing I regret is, that itA's so uncomfortable, when the code has been changed! If your are not sure, that your addin works and want to test something VSTA is more comfortable!And I still wonder why the proxy reference includes not all classes...But now I can continue doing my work, after I lost 4 days with that problem! Thank you!matz2009-08-07 18:52:420
-
Hi matz,
Just to make sure: Do NOT reference ABB.Robotics.RobotStudio.Proxy.dll in your add-in project! That file is only used by VSTA.
If you neeed to add references manually, use the other files in [Program Files]Common FilesABB Industrial ITRobotics ITRobotStudio5.12 and set "Copy Local" to False on the reference properties.
Also, if you installed RS after Visual Studio there should be a project template that helps you create an add-in project in VS.
Johannes Weiman
Software Engineer
ABB Robotics0 -
Yes, I understood! First I tried to use VSTA and there I have to use the proxy.dll! But tehre are not all types included. For exampe the class "GraphicPicker" is missing... So I switched to an Add-In, that I can use "GraphicPicker".
0 -
Correct, for technical reasons the entire RS API isn't available in VSTA.
Johannes Weiman
Software Engineer
ABB Robotics0 -
How can i know how to do thinks in RobotStudio with visual basic? For example, i want to create a form with a button that turns onoff a system output and i don't have a clue what is the wright command to manipulate a output. I know how to create a button in Add-In because there is a example already done but other things that aren't in the example i don't know how to do it or where i can get information.0
-
Hi,
did you noticed the examples in the API doc?
(location (e.g.) C:Program Files (x86)ABB Industrial ITRobotics ITRobotStudio 5.13HelpenAPIDocumentation.chm)
Open it, goto Examples -> User Interface -> Add ToolWindow
Regards
0 -
Thanks, it helped a lot! Do you know how to create a system signal and put a value on it? Only find how to create a station signal. Thanks a lot for the help! Hugo Mendes2011-01-31 12:09:540
-
Here is a real cheap way in C# - need reference to PC SDK assemblies....shopuld be able to do something in VB similar[CODE]
Controller ctrl;
private void ConnectToController()
{
//Connect to the virtual controller
NetworkScanner scanner = new NetworkScanner();
ControllerInfo[] controllers = scanner.GetControllers (NetworkScannerSearchCriterias.Virtual);
if (controllers.Length > 0)
{
ctrl = ControllerFactory.CreateFrom(controllers[0]);
}
controllers = null;
scanner = null;
}then in your code you can do someithing like this:
private string virtIO()
{
if (ctrl == null) ConnectToController();
while (!ctrl.Connected) { }
if (ctrl.IOSystem.GetSignal("<signal name here>").Value==0.0) {...do something}
Signal mySig = this.ctrl.IOSystem.GetSignal("<signal name here>");
mySig.Value = 1.0;
}
[/CODE]
hope this helps...Thomas J2011-01-27 15:03:25Thomas H. Johnston
PACs Application Engineer0 -
I tried to create a function to make a MoveAbsJ but i get an error: "Object reference not set to an instance of an object. I think its when i do this: rbAxis.Rax_1 = axis(1)Do you got any clew?Private Sub Button1_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseClick
Dim station As Station = TryCast(Project.ActiveProject, Station)
Dim value As Double
value = station.IOSignals("Eixo1").Value
station.IOSignals("Eixo1").Value = CDbl(value + 0.1)
Dim mech As Mechanism = station.ActiveTask.Mechanism
Logger.AddMessage(New LogMessage("E1"))
' Create a WorkObject and add it to the ActiveTask.
Dim myWobj As New RsWorkObject()
myWobj.Name = station.ActiveTask.GetValidRapidName("myWobj", "_", 1)
station.ActiveTask.DataDeclarations.Add(myWobj)
Logger.AddMessage(New LogMessage("E2"))
' Create a ToolData and add it to the ActiveTask.
Dim myTool As New RsToolData()
myTool.Name = station.ActiveTask.GetValidRapidName("myTool", "_", 1)
station.ActiveTask.DataDeclarations.Add(myTool)
Logger.AddMessage(New LogMessage("E3"))
' Create a PathProcedure.
Dim myPath1 As New RsPathProcedure("myPath1")
'station.ActiveTask.PathProcedures.Add(myPath1)
Logger.AddMessage(New LogMessage("E6"))
' Create a joint target to be able to create a MoveAbsJ move instruction.
Dim myJointTarget As New RsJointTarget()
myJointTarget.Name = station.ActiveTask.GetValidRapidName("myJointTarget", "_", 1)
station.ActiveTask.DataDeclarations.Add(myJointTarget)
Logger.AddMessage(New LogMessage("E7"))
' Set the robot axis values.
Dim rbAxis As New RobotAxisValues()
Dim axis(6) As Double
axis(1) = 70.0
Logger.AddMessage(New LogMessage("E7.1"))
axis(2) = CDbl(-30)
axis(3) = CDbl(30)
axis(4) = CDbl(-55.0)
axis(5) = CDbl(40)
axis(6) = CDbl(10)
Logger.AddMessage(New LogMessage("E7.2"))
'RobotAxisValues.SetAxisValues(rbAxis, axis)
Logger.AddMessage(New LogMessage("E7.0"))
rbAxis.Rax_1 = axis(1)
Logger.AddMessage(New LogMessage("E7.1"))
rbAxis.Rax_2 = axis(2)
rbAxis.Rax_3 = axis(3)
rbAxis.Rax_4 = axis(4)
rbAxis.Rax_5 = axis(5)
rbAxis.Rax_6 = axis(6)
myJointTarget.SetRobotAxes(rbAxis, False)
' Create a MoveAbsJ move instruction (this only makes sense if there is a mechanism in the station).
Dim myMoveAbsJ As New RsMoveInstruction(station.ActiveTask, "MoveAbs", "Default", myJointTarget.Name)
myPath1.Instructions.Add(myMoveAbsJ)
Logger.AddMessage(New LogMessage("E9"))0 -
[QUOTE=Thomas J]Here is a real cheap way in C# - need reference to PC SDK assemblies....shopuld be able to do something in VB similar
How do i do the reference do PC SDK? I put the references found in PC SDK 5.13 but still got errors.
I found that we can't use a method that has an array type as parameter. That's a VSTA problem.
Hugo Mendes2011-01-31 13:03:13
Thanks0 -
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