Creating a RobotStudio Add-In
This example provides information on creating a RobotStudio Add-In project using Microsoft Visual Studio. This project can be used to run examples.
The recommended and easiest way of creating a Add-In is by using a Visual Studio template included in the RobotStudio SDK installation.
Creating a RobotStudio Add-In.
Open Visual Studio and select New Project.... From the list of available templates, select RobotStudio <version> Empty Add-in and choose a name for the project.
Add the following line of code in the "AddInMain" method. This will make the Add-In greet the user whenever it is loaded.
using System; using System.Collections.Generic; using System.Text; using ABB.Robotics.Math; using ABB.Robotics.RobotStudio; using ABB.Robotics.RobotStudio.Environment; using ABB.Robotics.RobotStudio.Stations; namespace RobotStudioEmptyAddin { public class Class1 { // This is the entry point which will be called when the Add-in is loaded public static void AddinMain() { Logger.AddMessage(new LogMessage("Hello, I am a RobotStudio Add-In!")); } } }
Execute the Build Solution command in Visual Studio to compile the code and generate a .dll file for the Add-In. The .rsaddin file is responsible for making RobotStudio load the Add-In's assembly (the .dll file).
Open the .rsaddin file and set the path to point at the .dll file, see Creating an Add-In File for more information. The path is only needed during development, and should be removed when distributing the Add-In.
<Assembly> <FileName>RobotStudioEmptyAddin.dll</FileName> <!-- Specify the location of the Add-In .dll file here --> <Path>c:\users\USER_NAME\source\Repos\RobotStudioEmptyAddin\RobotStudioEmptyAddin\bin\Debug</Path> </Assembly>
Copy the .rsaddin file from the project directory to RobotStudio's Add-In folder, by default, this is located in
C:\Program Files (x86)\ABB\RobotStudio version\Bin\Addins
.Load the Add-In in RobotStudio by navigating to the Add-Ins menu. Right-click on your Add-In from the menu in the left panel, and select Load Add-In. You will see your greeting message when the Add-In is loaded.
Creating an Add-In Project manually
Note
If Visual Studio is installed on the computer before installing RobotStudio, or if you have installed the RobotStudio SDK, you will have the RobotStudio Add-In and SmartComponent project templates available in your computer. In this case, it is not necessary to follow these steps. Creating a new New Project and selecting any RobotStudio Add-In/Smart Component template generates the files described in the following steps.
Create a new project with Class Library as your template, and set the framework to .NET Framework 4.8 (or earlier). In Visual Studio 2022, select the Class Library (.Net Framework) template to choose 4.8. In this example, the project will be called "AddIn1".
To use the RobotStudio API you need to reference the ABB.Robotics.*.dll assemblies. These are:
ABB.Robotics.Math
- Vector and matrix math.ABB.Robotics.RobotStudio
- General and top-level (e.g. non-station specific) classes.ABB.Robotics.RobotStudio.Environment
- For manipulating the GUI, e.g. adding menus and buttons etc.ABB.Robotics.RobotStudio.Stations
- For manipulating stations and their contents.ABB.Robotics.RobotStudio.Stations.Forms
- GUI controls used by RobotStudio.
To add references, refer to section Adding references to your code.
Add the following lines to the top of your code:
using ABB.Robotics.Math; using ABB.Robotics.RobotStudio; using ABB.Robotics.RobotStudio.Environment; using ABB.Robotics.RobotStudio.Stations; using ABB.Robotics.RobotStudio.Stations.Forms;
Add the following code to the class:
public static void AddinMain() { // This is where you write your code. }
The
AddinMain()
-method is the entry point for your Add-in.Add an XML file to the project and change the name to AddIn1.rsaddin. For more information on how to create the .rsaddin file, see Creating an Add-In File. The following lines of code provide an example of what the file may look like.
<?xml version="1.0" encoding="utf-8" ?> <RobotStudioAddIn xmlns="urn:abb-robotics-robotstudio-addin" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:abb-robotics-robotstudio-addin file:///C:\Program%20Files%20(x86)\ABB\SDK\RobotStudio%202024%20SDK\RobotStudioAddin.xsd" autoLoad="false"> <!-- Make sure that the ApplicationId is unique --> <ApplicationId>com.mycompany.AddIn1</ApplicationId> <AddInType>General</AddInType> <Assembly> <!-- The name of the dll that contains the Add-In entry point --> <FileName>AddIn1.dll</FileName> <!-- Specify the location of the Add-In .dll file here --> <Path>c:\users\USER_NAME\source\Repos\AddIn1\AddIn1\bin\Debug</Path> </Assembly> <!-- By default, the minimum host version is equal to the SDK version --> <!-- You can change this if your Add-In supports older RobotStudio versions --> <MinimumHostVersion>24.1</MinimumHostVersion> <Dependencies>Station</Dependencies> <Platform>Any</Platform> </RobotStudioAddIn>
Adding references to your code
Some of the examples require you to add a new reference to your Add-in. To do this, right click on "References" in the Project Explorer/Solution Explorer and choose Add Reference.... This will bring up a new window where you can choose which component to add a reference to. If it is a .Net reference, just scroll the first window and select the one you want. Then click on OK to add it. If it is a RobotStudio reference, go to the Browse tab and browse to your RobotStudio SDK directory (normally this is
C:\Program Files (x86)\ABB\SDK\RobotStudio version SDK
) and choose which .dll you want to reference. After that, add a using statement for the namespace used in the referenced assembly in the beginning of your code file. For example:using System.IO;
To use the PCSDK API you need to reference the following assemblies. These are:
using ABB.Robotics; using ABB.Robotics.Controllers;
PCSDK references are normally found in
%ProgramFiles(X86)%\ABB\SDK\PCSDK version
.