Reply

AddCommandBarButton !!!! how???

[ Edited ]

 

Hello staff,

I am new in programming for Solid Edge and am having problems to get include a button on the command bar that could create tab of Solid Edge Addin .... I'm sending attached files of my test project ...

I'm using VB.NET 2008 Express and Solid Edge ST ....

 

Much as I try to add the command only appears as a toolbar is attached .... I can not put buttons. How?

 

ps.: I am Brazilian and I am using translator, so I apologize for a mistake of language.

 

Thanks already!

 

The Code:

 

Imports System.Runtime.InteropServices

Imports Microsoft.Win32

Imports System.Reflection

Imports System.Collections

Imports System.Collections.Generic

 

ProgIdAttribute("IntegraSE.Integra"), _

ComVisible(True)> _

Public Class Integra

    Implements SolidEdgeFramework.ISolidEdgeAddIn, SolidEdgeFramework.ISEAddInEvents

    Private objAddin As SolidEdgeFramework.AddIn

    Private objApplication As SolidEdgeFramework.Application  

    Public Sub OnConnection(ByVal Application As Object, ByVal ConnectMode As SolidEdgeFramework.SeConnectMode, ByVal AddInInstance As SolidEdgeFramework.AddIn) Implements SolidEdgeFramework.ISolidEdgeAddIn.OnConnection

        objAddin = AddInInstance

        objApplication = Application

        AddInInstance.GuiVersion = 1

        AddInInstance.Description = "Integração com Forwood / Fabril / SIG"

    End Sub

    Public Sub OnConnectToEnvironment(ByVal EnvCatID As String, ByVal pEnvironmentDispatch As Object, ByVal bFirstTime As Boolean) Implements SolidEdgeFramework.ISolidEdgeAddIn.OnConnectToEnvironment

        Dim commandNames As Array = Array.CreateInstance(GetType(String), 2)

        Dim commandIDs As Array = Array.CreateInstance(GetType(Integer), 2)

        commandNames.SetValue(String.Format("Integração{0}Integração CAD{1}Integração com Softwares de Gestão{2}Integração com Softwares de Gestão", ControlChars.Lf, ControlChars.Lf, ControlChars.Lf), 0)

        commandIDs.SetValue(1, 0)       

        objAddin.SetAddInInfo(Marshal.GetHINSTANCE(Me.GetType().Module).ToInt32(), EnvCatID, "IntegraSE", 1, 2, 1, 2, commandIDs.Length, commandNames, commandIDs)

        If bFirstTime Then

            objAddin.AddCommandBarButton(EnvCatID, "Integração", 1)

        End If

    End Sub

 

    Public Sub OnDisconnection(ByVal DisconnectMode As SolidEdgeFramework.SeDisconnectMode) Implements SolidEdgeFramework.ISolidEdgeAddIn.OnDisconnection

        If Not (objAddin Is Nothing) Then

            objAddin = Nothing

        End If

        If Not (objApplication Is Nothing) Then

            objApplication = Nothing

        End If

    End Sub

    _

    Public Shared Sub RegisterFunction(ByVal t As Type)

        Dim baseKey As RegistryKey = Nothing

        Dim summaryKey As RegistryKey = Nothing

        Dim title As AssemblyTitleAttribute

        Dim description As AssemblyDescriptionAttribute

        Try

            baseKey = Registry.ClassesRoot.CreateSubKey("CLSID\{" + t.GUID.ToString + "}")

            baseKey.SetValue("AutoConnect", 1)

            If t.Assembly.IsDefined(GetType(AssemblyTitleAttribute), True) Then

                title = AssemblyTitleAttribute.GetCustomAttribute(t.Assembly, GetType(AssemblyTitleAttribute))

                baseKey.SetValue("409", title.Title)

            End If

            If t.Assembly.IsDefined(GetType(AssemblyDescriptionAttribute), True) Then

                description = AssemblyDefaultAliasAttribute.GetCustomAttribute(t.Assembly, GetType(AssemblyDescriptionAttribute))

                summaryKey = baseKey.CreateSubKey("Summary")

                summaryKey.SetValue("409", description.Description)

                summaryKey.Close()

            End If

            'Addin

            baseKey.CreateSubKey("Implemented Categories\{26B1D2D1-2B03-11d2-B589-080036E8B802}")

            'All Envirenment Documents

            baseKey.CreateSubKey("Environment Categories\{BAD41B8D-18FF-42c9-9611-8A00E6921AE8}")

        Catch ex As Exception

 

        Finally

            If Not (summaryKey Is Nothing) Then

                summaryKey.Close()

            End If

            If Not (baseKey Is Nothing) Then

                baseKey.Close()

            End If

        End Try

    End Sub

    _

    Public Shared Sub UnregisterFunction(ByVal t As Type)

        Try

            Registry.ClassesRoot.DeleteSubKeyTree("CLSID\{" + t.GUID.ToString + "}")

        Catch ex As Exception

        End Try

    End Sub

    'Addin Events

    Public Sub OnCommand(ByVal CommandID As Integer) Implements SolidEdgeFramework.ISEAddInEvents.OnCommand

        Select Case CommandID

            Case 1

                MsgBox("Teste de Comando 1")

        End Select

    End Sub

 

    Public Sub OnCommandHelp(ByVal hFrameWnd As Integer, ByVal HelpCommandID As Integer, ByVal CommandID As Integer) Implements SolidEdgeFramework.ISEAddInEvents.OnCommandHelp

 

    End Sub

 

    Public Sub OnCommandUpdateUI(ByVal CommandID As Integer, ByRef CommandFlags As Integer, ByRef MenuItemText As String, ByRef BitmapID As Integer) Implements SolidEdgeFramework.ISEAddInEvents.OnCommandUpdateUI

 

    End Sub

End Class

 

 

Posted by: Fabio Rosa
Post date: 2/16/2009 1:09:07 AM

2 REPLIES

RE: AddCommandBarButton !!!! how???

[ Edited ]

 

Fabio,

 

It looks like you're using a really old template that I've previously supplied. I have abandoned support for those templates because of .NET issues that I don't care to deal with anymore, like this one. I suggest that you download my VS.NET 2005 AddIn Demo in the Downloads\Programming Examples section and take a look at that. That demo uses a C++ addin shim to load a .NET addin. In my opinion, it's a much better solution than a pure .NET addin. The demo should compile as-is and will demonstrate to you how to add the buttons.

 

Posted by: Jason Newell
Post date: 2/17/2009 1:48:40 PM

RE: AddCommandBarButton !!!! how???

[ Edited ]

 

Hello Jason,

 

I did a test in C # using the same steps you did to create your Addin which I spoke, but when I run Solid Edge, it is marked by the box of Addins that not only carries nothing ...

 

Is there something wrong in my code?

 

I'm sending it attached, you can take a look at me?

 

thanks.

 

Posted by: Fabio Rosa
Post date: 2/18/2009 2:30:05 AM