Creating Button
The RobotStudio Development Center offers a description inclusive example source code for creating a button in RS.
http://developercenter.robotstudio.com/Index.aspx?DevCenter=RobotStudio&OpenDocument&Url=html/ad7828b5-c307-4562-905c-ea1981c2bfb8.htm
I copied the code into my VisualStudio 15, but I do not get any result in RobotStudio. I mentioned that the code is not completed.
For example is the command "using System.Drawing" missing.
Can anyone help me to fix this code, so I have something to work with?
Thank you, Sebastian
http://developercenter.robotstudio.com/Index.aspx?DevCenter=RobotStudio&OpenDocument&Url=html/ad7828b5-c307-4562-905c-ea1981c2bfb8.htm
I copied the code into my VisualStudio 15, but I do not get any result in RobotStudio. I mentioned that the code is not completed.
For example is the command "using System.Drawing" missing.
Can anyone help me to fix this code, so I have something to work with?
Thank you, Sebastian
0
Comments
-
You must add 'System.Drawing' dll reference in your visual studio solution.
Something more or less like this: References -> Add Reference -> Framework -> Find and Select 'System.Drawing'
Regards0 -
thank you haryprabs, but I already had the *.Drawing included. I also have the post-build event
XCopy /y "$(TargetPath)" "C:\Program Files (x86)\ABB Industrial IT\Robotics IT\RobotStudio 6.02\Bin\Addins"
implemented. This works fine, the .dll-copy is in the correct folder, but I don't see anything in RobotStudio, which also opens automatically.
Any suggestions?0 -
Have you done this:
Go to add-in tab. Under general folder you will find list of add-in then load or enable autoload.
Otherwise can you share your code snippet. It should look like this:public static void AddinMain() { CreateButton(); }
private void CreateButton() { //Write code to create button as in the example source code }
Regards0 -
my add-in actually doesn't even appear in RobotStudio, although, I have the copy-command in the project-properties.
My code looks like this:using System;using System.Collections.Generic;using System.Text;using System.Drawing;using System.Windows.Forms;using ABB.Robotics.Math;using ABB.Robotics.RobotStudio;using ABB.Robotics.RobotStudio.Environment;using ABB.Robotics.RobotStudio.Stations;namespace Add_Button_RS{public class tab{private void button_ExecuteCommand(object sender, ExecuteCommandEventArgs e){//Perform any action like creating paths and targets}private void button_UpdateCommandUI(object sender, UpdateCommandUIEventArgs e){// This enables the button, instead of "button1.Enabled = true".e.Enabled = true;}private void CreateButton(){//Begin UndoStepProject.UndoContext.BeginUndoStep("Add Buttons");try{// Create a new tab.RibbonTab ribbonTab = new RibbonTab("MyTab", "MyTab");UIEnvironment.RibbonTabs.Add(ribbonTab);//make tab as active tabUIEnvironment.ActiveRibbonTab = ribbonTab;// Create a group for buttonsRibbonGroup ribbonGroup = new RibbonGroup("MyButtons", "MyButton");// Create first small buttonCommandBarButton buttonFirst = new CommandBarButton("MyFirstButton", "MyFirstButton");buttonFirst.HelpText = "Help text for small button";buttonFirst.Image = Image.FromFile(@C:\Users\sebastian\Offline\Programmierung_o\button-test\button.png);buttonFirst.DefaultEnabled = true;ribbonGroup.Controls.Add(buttonFirst);//Include Seperator between buttonsCommandBarSeparator seperator = new CommandBarSeparator();ribbonGroup.Controls.Add(seperator);// Create second button. The largeness of the button is determined by RibbonControlLayoutCommandBarButton buttonSecond = new CommandBarButton("MySecondButton", "MySecondButton");buttonSecond.HelpText = "Help text for large button";// Set the image of the button.buttonSecond.Image = Image.FromFile(@C:\Users\sebastian\Offline\Programmierung_o\button-test\button.png);buttonSecond.DefaultEnabled = true;ribbonGroup.Controls.Add(buttonSecond);// Set the size of the buttons.RibbonControlLayout[] ribbonControlLayout = { RibbonControlLayout.Small, RibbonControlLayout.Large };ribbonGroup.SetControlLayout(buttonFirst, ribbonControlLayout[0]);ribbonGroup.SetControlLayout(buttonSecond, ribbonControlLayout[1]);//Add ribbon group to ribbon tabribbonTab.Groups.Add(ribbonGroup);// Add an event handler.buttonFirst.UpdateCommandUI += new UpdateCommandUIEventHandler(button_UpdateCommandUI);// Add an event handler for pressing the button.buttonFirst.ExecuteCommand += new ExecuteCommandEventHandler(button_ExecuteCommand);}catch (Exception ex){Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);Logger.AddMessage(new LogMessage(ex.Message.ToString()));}finally{Project.UndoContext.EndUndoStep();}}}public class window{internal class Forms{internal class Control{}}private static void AddDocumentWindow(){//Begin UndoStepProject.UndoContext.BeginUndoStep("AddDocumentWindow");try{System.Windows.Forms.Control control = new System.Windows.Forms.Control();DocumentWindow window = new DocumentWindow(Guid.NewGuid(), control, "MyDocumentWindow");UIEnvironment.Windows.Add(window);}catch (Exception ex){Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);Logger.AddMessage(new LogMessage(ex.Message.ToString()));}finally{Project.UndoContext.EndUndoStep();}}}}0 -
Where is 'AddinMain' method? This method is the entry point as stated at point 4 in this tutorial
http://developercenter.robotstudio.com/Index.aspx?DevCenter=RobotStudio&OpenDocument&Title=Creating%20RobotStudio%20Add-in
From this method, call CreateButton() method.
Regards0 -
Thank you! Now I can see my Tab...finally
But shouldn't there also be a RibbonGroup and a Button!?0
Categories
- All Categories
- 5.5K RobotStudio
- 396 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 250 ScreenMaker
- 2.8K Robot Controller
- 316 IRC5
- 61 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 800 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 5 Job listings