Question about Compiling a DLL for an iLogic Rule

Question about Compiling a DLL for an iLogic Rule

projeto2SGY8C
Participant Participant
896 Views
2 Replies
Message 1 of 3

Question about Compiling a DLL for an iLogic Rule

projeto2SGY8C
Participant
Participant

Good afternoon! I need help with compiling a DLL for iLogic. I created a DLL for a general function, which I will call in several iLogic rules. However, I am unable to identify what I am doing wrong.

Here is the DLL code:

 

 

Imports Inventor

Namespace MedidasLibrary.NameSpace
    Public Class MedidasHelper
        Public Function ObterMedidas(ByVal modelo As String) As Object()
            Select Case modelo
                Case "2 SCH05"
                    Return New Object() {10, 10}
                Case "2 SCH10"
                    Return New Object() {20, 20}
                Case "2 SCH40"
                    Return New Object() {30, 30}
                Case "2 SCH80"
                    Return New Object() {40, 40}
                Case Else
                    Return New Object() {0, "Modelo inválido"}
            End Select
        End Function
    End Class
End Namespace

 


This is the code where I am calling this DLL in the rule within Inventor, in iLogic:

 

 

AddReference "C:\Users\Projeto\source\repos\TesteTubos\bin\x64\Release\TesteTubos.dll"
Imports MedidasLibrary.NameSpace

Sub Main()
    ' Definir os modelos e seus parâmetros
    Dim modelos As New Dictionary(Of String, String) From {
        {"VENT", MODELO_VENT},
        {"COND", MODELO_COND},
        {"NOVO_MODELO", "2 SCH05"} ' Adicione novos modelos aqui
    }

    ' Processar cada modelo
    For Each modelo In modelos
        Dim medidas As Object() = MedidasHelper.ObterMedidas(modelo.Value)
        ApplyModel(modelo.Key, medidas(0), medidas(1))
    Next

End Sub

' Função genérica para aplicar medidas a qualquer modelo
Sub ApplyModel(ByVal modelName As String, ByVal A As Object, ByVal B As Object)
    Select Case modelName
        Case "VENT"
            Param_Vent1 = A ' DIÂMETRO POR EXEMPLO
            Param_Vent2 = B ' ESPESSURA POR EXEMPLO
        Case "COND"
            Param_Cond1 = A
            Param_Cond2 = B
        Case "NOVO_MODELO"
            ' Parâmetros para o novo modelo
            Param_Novo1 = A ' DIÂMETRO POR EXEMPLO
            Param_Novo2 = B ' ESPESSURA POR EXEMPLO
    End Select

    ' Atualizações
    Parameter.UpdateAfterChange = True
    iLogicVb.UpdateWhenDone = True
    InventorVb.DocumentUpdate(True)
End Sub

 

 


When I run this rule, it returns the following error message:
Warning on Line 2: The namespace or type specified in Imports 'MedidasLibrary.NameSpace' does not contain any public members or cannot be found. Check if the namespace or type is defined and contains at least one public member. Verify that the imported element's name does not use aliases.

And

Error on Line 13: 'MedidasHelper' is not declared. It may be inaccessible due to its protection level.


Can someone help me? What am I doing wrong? The file was compiled in VB.NET as a Class Library (.NET Framework) (dll).

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

Michael.Navara
Advisor
Advisor
Accepted solution

Not tested, but the method ObterMedidas(...) needs to be defined as Shared (static in C#). Otherwise you need to create instance of class MediasHelper.

 

Declare method shared (recommended)

Public Shared Function ObterMedidas(ByVal modelo As String) As Object()

 

Use instance method

 Dim medidas As Object() = new MedidasHelper().ObterMedidas(modelo.Value)

 

 

0 Likes
Message 3 of 3

projeto2SGY8C
Participant
Participant

It worked Michael! thanks!

0 Likes