Start an API project. VB.NET

Start an API project. VB.NET

jmmarin
Advocate Advocate
489 Views
2 Replies
Message 1 of 3

Start an API project. VB.NET

jmmarin
Advocate
Advocate

Hi all.

 

I have just started a project with the API. I have been using VBA but this project will be developed using VB.NET. 

 

The query is regarding how to access to the labels. I initialise the class as follows, previous importing RobotOM

 

Imports RobotOM

Public Class FunGen
Private Shared roboApp As New RobotApplication
Private Shared roboPro As RobotProject = roboApp.Project
Private Shared roboStr As RobotStructure = roboPro.Structure

 Public Shared Function ColeccionLabelsLista(ByRef LABEL_TYPE As IRobotLabelType) As List(Of String)

        Dim list As New List(Of String)
        Dim colLabels As RobotLabelCollection

        colLabels = roboStr.Labels.GetAll()

        For i = 0 To colLabels.Count - 1
            list.Add(colLabels.Get(i).ToString)
        Next

        Return list

    End Function
End class

This function returns nothing because "labelCol" is empty. I am debugging with a model that have several labels and therefore, the variable should not be empty.

 

I would appreciate your support to know what is wrong. 

 

Thanks in advance.

 

 

0 Likes
Accepted solutions (1)
490 Views
2 Replies
Replies (2)
Message 2 of 3

Stephane.kapetanovic
Mentor
Mentor
Accepted solution

hi @jmmarin 

here is a code that returns the list of project label names.

Imports RobotOM

Module Module1
    Private RobApp As New RobotApplication
    Private Labels As RobotLabelServer = RobApp.Project.Structure.Labels

    Sub Main()
        Dim LabelNameList As New List(Of String)

        Dim LabelCollection As RobotLabelCollection = Labels.GetAll()

        Dim Label As RobotLabel
        For i = 1 To LabelCollection.Count
            Label = LabelCollection.Get(i)
            LabelNameList.Add(Label.Name)
        Next
    End Sub
End Module

Best Regards

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to accept the solution and leave a < like !
EESignature
Message 3 of 3

jmmarin
Advocate
Advocate

Many thanks Stephane !