RobotStudio event

RSSDK: How to use New/Open/Close events (sample)



This is a RobotStudio addin made with Visual Studio 2010 in C#. Its made for RobotStudio 5.15.
 
 
To debug [F5] you need to run Visuals Studio as Administrator, or remove the post-build xcopy command. And if you are not using RobotStudio 5.15 you need to change the debug>start external program path.
 
I made this on a request by Lin, and Lin I made some clarification to it from the example I sent you.
 
This is how you test it:
[code]Start RobotStudio
Home - check out the output window "MySample info - AddinMain"
File > New >Empty Station
Home - check out the output window "MySample info - Project_ActiveProjectChanged event triggered - New Empty Station opened"
File > Save > "SampleStation"
Home - check out the output window "MySample info - myStation_Saved event triggered"
File > Close
Home - check out the output window "MySample info - Project_ActiveProjectChanged event triggered - Closed the project"
Home - check out the output window "MySample info - myStation_Closed event triggered"
File > Open > "SampleStation"
Home - check out the output window "MySample info - Project_ActiveProjectChanged event triggered - Station opened: SampleStation"
File > Close
Home - check out the output window "MySample info - Project_ActiveProjectChanged event triggered - Closed the project"
Home - check out the output window "MySample info - myStation_Closed event triggered"[/code]
This is the code itself:
[code]    public class Class1
    {
        public static void AddinMain()
        {
            Logger.AddMessage("MySample info - AddinMain");
            Project.ActiveProjectChanged += new EventHandler(Project_ActiveProjectChanged);
        }
        static void Project_ActiveProjectChanged(object sender, EventArgs e)
        {
            if (Project.ActiveProject != null)
            {
                Station myStation = Project.ActiveProject as Station;
                myStation.Closed += new EventHandler(myStation_Closed);
                myStation.Saved += new EventHandler(myStation_Saved);
                if (myStation.Name == "")
                {
                    Logger.AddMessage("MySample info - Project_ActiveProjectChanged event triggered - New Empty Station opened");
                }
                else
                {
                    Logger.AddMessage("MySample info - Project_ActiveProjectChanged event triggered - Station opened: " + myStation.Name);
                }
            }
            else
            {
                Logger.AddMessage("MySample info - Project_ActiveProjectChanged event triggered - Closed the project");
            }
        }
        static void myStation_Closed(object sender, EventArgs e)
        {
            Logger.AddMessage("MySample info - myStation_Closed event triggered");
        }
        static void myStation_Saved(object sender, EventArgs e)
        {
            Logger.AddMessage("MySample info - myStation_Saved event triggered");
        }
    }[/code]

Comments

  • Dear John, I have started to develop add-in for Robotstudio, in particular what I would like to do is to automatically create a station with a IRB 6640 robot and IRC5 controller and to add some CAD model of the object to be operated. I tried to write my first code for doing this, but during debugging robot studio start but nothing else happen and it seems that the code is not ruined (the breakpoints don't work). In order to be sure I downloaded and tested your code, but I got the same result, Robotstudio start but nothing else happens. Could you help me in solving this issue? there is something that I am missing? (note that the dll is correctly saved in the Addin folder of robot studio and the version that I use is a Robotstudio 6.0 64bit ). Thank you so much in advance for your help. Cheers, Perla