Exporting XML source from RobotStudio
Learn how to export a SmartComponent from a RobotStudio station and continue development in Visual Studio where you can implement behaviour using Code Behind. The exported .rsxml file will be added to a new VisualStudio project based on the SmartComponent project template where it will be built by the LibraryCompiler using a Post-build step.
You can benefit from development in Visual Studio when:
You need the flexibility of implementing behaviour using .NET and Code Behind.
You want to build from the command line.
Your component has many child components and complex connections and bindings.
Instructions
Open RobotStudio and create an empty station.
Load the SmartComponent library file (.rslib). Lets assume it's named "MyComponent". Locate it in the Layout Browser and select Disconnect Library from the context menu.
Right-click the SmartComponent and select Edit Component. The SmartComponent Editor window will open.
Select the Export to Xml... option, located in the far-right section of the window and specify a file name and location. Lets use ExportFolder\"MyComponent".rsxml. Besides the expected .rsxml file you will also find the folder .\ExportFolder\"MyComponent"_Files, which contains additional assets of the library, for example geometry files.
Open Visual Studio and select New Project... Use one of the SmartComponent templates from RobotStudio SDK to create a new project. For simplicity, name the project after the SmartComponent.
Note
In cases where Visual Studio is installed after RobotStudio or the RobotStudio SDK, the SmartComponent template will not be available. Reinstalling the RobotStudio SDK solves this issue.
Open the "MyComponent".rsxml file and copy its entire content. Open the file "MyComponent".xml from the Visual Studio project and locate the
<SmartComponent>
element. Replace this element with the<SmartComponent>
element from the clipboard. Do the same with the "MyComponent".Resources.en.xml file. Replace the<SmartComponent>
in the file in the Visual Studio with the content from the exported file.Modify the
<Assets>
element to point to the "MyComponent".en.xml instead of the "MyComponent".Resources.en.xml.At this stage is possible to compile the component using Visual Studio. Now you can modify and add more functionality by editing the "CodeBehind.cs" file in the Visual Studio project.