Markups
Add-Ins and SmartComponents have access to a plethora of options made available by RobotStudio's 3D subsystem. Markups are an useful tool that the developer can use to direct attention to a certain element of the 3D environment. This topic shows how to create and modify several markups in different ways and interact with their properties. A very simple case will be shown first followed by some customization examples.
The steps that will be performed in the topic are:
Assigning the current station as a "Station Entity".
Creating a Markup object and adding it to the Markup
Collection .Changing the position of a Markup by assigning a Vector3 to it.
Change the position of a Markup by individually changing its x,y and z properties.
Add an image to a Markup .
Note
You can easily try out this example using the RobotStudio Empty Add-in template from Visual Studio.
Solution
Assign the current project as a station entity.
Station station = Project.ActiveProject as Station;
Create a Markup object and add it to the Markup
Collection . This will add the markup to the system and RobotStudio will display it in the center of the station.Markup myMarkup = new Markup(); // Default (xyz=[0 0 0]) station.Markups.Add(myMarkup); // Add to the station's Markups
Note
Position-wise, markups are by default initialized in x = 0, y = 0 and z = 0.
One of the most important parameters to modify in a markup is its position. You can specify the position by assigning a Vector3 to the markup's ABB.
Robotics. .Transform property as shown in the following example. Text can be added to the Markup to make it display some useful information to the user. We add the position of the markup to its displayed text.Robot Studio. Stations Markup markupWText = new Markup(); // Move the markup with a new vector: markupWText.Transform.Translation = new Vector3(2, 0, 0); // Write the Markup's position as its display text: markupWText.Text = markupWText.Transform.Translation.ToString(); station.Markups.Add(markupWText);
Here we modify the position of the markup by separately specifying the values of the X and Z properties; A handy alternative to the Vector3 approach. We also modify the size of the text that the markup displays.
Markup markupWBigText = new Markup(); // Move the markup specifying new X Y and Z values: markupWBigText.Transform.X = 1; markupWBigText.Transform.Z = 1; markupWBigText.Text = markupWBigText.Transform.Translation.ToString(); markupWBigText.FontSize = 26; // Set the font size station.Markups.Add(markupWBigText);
An image can also be added to the markup. Here we create a new (120x120) BITMAP instance and assign it to the Image property of a markup. Note that this will only add an empty 120x120 "canvas" to the markup, but the bitmap itself could be modified or even imported from a file as needed by the developer.
Markup markupWImage = new Markup(); markupWImage.Transform.Z = 1; markupWImage.Transform.X = 3; // Create an empty bmp markupWImage.Image = new Bitmap(120,120); station.Markups.Add(markupWImage);
This example is done inside a RobotStudio Add-In. Refer to the corresponding Add-In sections for information about how to Create and Run one.
Example
The complete code for the C# class is shown below:
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
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 VisualSampleAddin
{
public class Class1
{
public static void AddinMain()
{
Station station = Project.ActiveProject as Station;
Markup myMarkup = new Markup(); // Default (xyz=[0 0 0])
station.Markups.Add(myMarkup); // Add to the station's Markups
Markup markupWText = new Markup();
// Move the markup with a new vector:
markupWText.Transform.Translation = new Vector3(2, 0, 0);
// Write the Markup's position as its display text:
markupWText.Text = markupWText.Transform.Translation.ToString();
station.Markups.Add(markupWText);
Markup markupWBigText = new Markup();
// Move the markup specifying new X Y and Z values:
markupWBigText.Transform.X = 1;
markupWBigText.Transform.Z = 1;
markupWBigText.Text = markupWBigText.Transform.Translation.ToString();
markupWBigText.FontSize = 26; // Set the font size
station.Markups.Add(markupWBigText);
Markup markupWImage = new Markup();
markupWImage.Transform.Z = 1;
markupWImage.Transform.X = 3;
// Create an empty bmp
markupWImage.Image = new Bitmap(120,120);
station.Markups.Add(markupWImage);
}
}
}
Required Namespaces
ABB.