RobotStudio event

Add-in for RS 5.07

My RS 5.07 does not offer RS API help. It is grey in the menu.

Need help on how to build Add-in in RS 5.07. What's the difference from RS 3.2?

Comments


  • Hi Alex.

    Documentation of the RobotStudio API will be included in the next release (5.08). For now, I can provide you with some auto-generated documentation. Note that it is unsupported, incomplete and possibly incorrect!

    2006-07-14_110219_APIDoc.zip

    The RobotStudio 5.x API is .NET based and you need Visual Studio 2005 to build an addin. Typically you would program in C# or VB.NET. The requirements for an addin are very simple:
    1) It must contain a public, static and parameterless method called AddinMain


    2) The DLL must be placed in the RobotStudioBinAddins directory

    To use the RS 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 RS

    Below is an example of a basic addin written in C#:

    using System;
    using ABB.Robotics.RobotStudio;
    using ABB.Robotics.RobotStudio.Environment;
    using ABB.Robotics.RobotStudio.Stations;
    using System.Windows.Forms;

    namespace MyAddin
    {
        public class MyAddin
        {
            // This method is called when RS starts
            public static void AddinMain()
            {
                // Create a new command button
                CommandBarButton button = new CommandBarButton("HelloMyAddin", "Hello MyAddin!");
                // Add the button to the "Tools" menu
                // The IDs of predefined menus and commands are found in "RobotStudioIDSummary.html"
                CommandBarPopup.FromID("MenuTools").Controls.Add(button);
                // Connect the command events
                button.UpdateCommandUI += new UpdateCommandUIEventHandler(button_UpdateCommandUI);
                button.ExecuteCommand += new ExecuteCommandEventHandler(button_ExecuteCommand);
            }

            static void button_UpdateCommandUI(object sender, UpdateCommandUIEventArgs e)
            {
                // Enable the button
                e.Enabled = true;
            }

            static void button_ExecuteCommand(object sender, ExecuteCommandEventArgs e)
            {
                // Do something
                MessageBox.Show("Hello MyAddin!");
            }
        }
    }

    regards,
    Johannes

    Johannes Weiman2006-7-14 12:34:40
    Johannes Weiman
    Software Engineer
    ABB Robotics
  • I am trying to use this to build an addin that will update positions of targets.

    When i try to compile

    CommandBarButton buttonGantryUpdate = new CommandBarButton("GantryUpdate", "Gantry Update");
                 buttonGantryUpdate.UpdateCommandUI += new UpdateCommandUIEventHandler(buttonGantryUpdate_UpdateCommand UI);
                 buttonGantryUpdate.ExecuteCommand += new ExecuteCommandEventHandler(buttonGantryUpdate_ExecuteCommand );

    i get
    An Object reference is required for the nostatic field, method or property. I am using all the suggested ABB.Robotics items and have referenced the dll files in the SDK directory

    Any ideas?

  • [QUOTE=mattdavis]
                  buttonGantryUpdate.UpdateCommandUI += new UpdateCommandUIEventHandler(buttonGantryUpdate_UpdateCommand UI);
    [/QUOTE]

    Hi,

    There is a white space in the argumentlist between "UpdateCommand" and "UI". Is that expected?

     

    Henrik Berlin
    ABB
  • thats a weirdness of the forum i think. I cut and paste that from my code and theres no space in the code. Thanks for the suggestion and damm good spotting.
  • Is buttonGantryUpdate_UpdateCommandUI and buttonGantryUpdate_ExecuteCommand static? Try to make them static, and see if that works.
  • yes that works.

    Thanks alot for that, im confused as to why it works but.. it does.

This discussion has been closed.