RobotStudio event

Creating add-in using Visual Studio

Options
Hi,
 

I have tried to run some of the examples from the RobotStudio API documentation, but can't get any of them to work when I build them in Visual Studio. I can build them, but when I import the add-in in a Robot Studio station nothing happens. How do I get the Add-In-programs to execute?

 

Could anyone give a complete, working, example code of an add-in built in Visual Studio C#, and instructions of how to get it running in Robot Studio? I have tried to follow the instructions in the documentation, but maybe I have misunderstood something, or there is some essential information missing out.

 

I use the RobotStudio 5.12 release.

 

/Daniel

Comments

  • danwa
    Options

    For example, if I would like to test the Logger-example in the API documentation - is this what the complete Visual Studio C#-code should look like?:

    __________________________________________________

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using ABB.Robotics.Math;
    using ABB.Robotics.RobotStudio;
    using ABB.Robotics.RobotStudio.Environment;
    using ABB.Robotics.RobotStudio.Stations;
    using ABB.Robotics.RobotStudio.Stations.Forms;

    namespace Addin1
    {
       public class Class1
       {

           public static void AddinMain()
           {
               Project.UndoContext.BeginUndoStep("Logger");
               try
               {
                   // How to add categories to the Logger!
                   // Add two categories.
                   Logger.CategoryCaptions.Add("MyKey", "My Category");
                   Logger.CategoryCaptions.Add("AnotherKey", "Another Category");

                   // Print a message in different categories.
                   Logger.AddMessage(new LogMessage("This is just a test
    message!", "MyKey"));
                   Logger.AddMessage(new LogMessage("This is just a test
    message!", "AnotherKey"));
               }
               catch (Exception e)
               {
                   Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
                   throw e;
               }
               finally
               {
                   Project.UndoContext.EndUndoStep();
               }

           }
       }
    }

    __________________________________________________
  • danwa
    Options

    When i Debug the program above I get the following message from Visual Studio:

    "A project with an Output Type of Class Library cannot be started directly.

    ..."

     

    Should this be the case?

     

    EDIT:

    I found the following:
    http://msdn.microsoft.com/en-us/library/68c8335t(VS.80).aspx

    This states that Start external program is not available in Visual Studio Express. Is this function necessary to be able to build applications for RobotStudio?
    danwa2009-05-03 15:56:14

  • Hello danwa,

    I found this which explains how to debug a DLL in Visual Studio Express. In short, your MyProjectName.csproj.user should look something like this:
    [code]<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
        <StartAction>Program</StartAction>
        <StartProgram>C:Program FilesABB Industrial ITRobotics ITRobotStudio 5.12BinRobotStudio.exe</StartProgram>
      </PropertyGroup>
    </Project>
    [/code]
    Your code looks correct. Note that the UndoContext statements aren't strictly necessary in this case since you only call logger methods. Only methods that somehow modify the station data are undoable.

    regards,
    Johannes

    Johannes Weiman
    Software Engineer
    ABB Robotics