Enable the buttons and create calls

 

Hello!

 

With this code below I can create 4 buttons and put the pictures in them!

Only that which can not be displayed along with the picture the name or description of the button and other buttons are of Solid Edge.

Nor can leave them enabled, always are in gray and disabled to click.

And finally, I do not know for sure how to add stock when you get clicks!

 

I hope some help and now I am very grateful!

Thanks!The project is attached for those who want to see!

The Code:

Imports System.Runtime.InteropServices

Imports Microsoft.Win32

Imports System.Reflection

Imports System.Collections

Imports

 

ProgIdAttribute(

ComVisible( System.Collections.Generic"40A27375-93E4-4696-9160-E2419C8350A7"), _"IntegraSE.Integra"), _True)> _

Public

 

 

 

 

 

 

 

 

 

 

objAddin = AddInInstance

objApplication =

objenvironmentCommandMap =

objAppEvents =

AddInInstance.GuiVersion = 20

AddInInstance.Description = Class IntegraImplements SolidEdgeFramework.ISolidEdgeAddIn, SolidEdgeFramework.ISEAddInEvents, SolidEdgeFramework.ISEApplicationEventsPrivate objAddin As SolidEdgeFramework.AddInPrivate objApplication As SolidEdgeFramework.ApplicationPrivateWithEvents objAppEvents As SolidEdgeFramework.DISEApplicationEvents_EventFriend objenvironmentCommandMap As System.Collections.Generic.Dictionary(OfString, System.Collections.Generic.Dictionary(OfInteger, Integer))DimWithEvents objButtonEvents1 As SolidEdgeFramework.CommandBarButtonEventsDimWithEvents objButtonEvents2 As SolidEdgeFramework.CommandBarButtonEventsDimWithEvents objButtonEvents3 As SolidEdgeFramework.CommandBarButtonEventsDimWithEvents objButtonEvents4 As SolidEdgeFramework.CommandBarButtonEventsPublicSub OnConnection(ByVal Application AsObject, ByVal ConnectMode As SolidEdgeFramework.SeConnectMode, ByVal AddInInstance As SolidEdgeFramework.AddIn) Implements SolidEdgeFramework.ISolidEdgeAddIn.OnConnectionCType(Application, SolidEdgeFramework.Application)New System.Collections.Generic.Dictionary(OfString, System.Collections.Generic.Dictionary(OfInteger, Integer))CType(objApplication.ApplicationEvents, SolidEdgeFramework.DISEApplicationEvents_Event)"IntegraSE"

 EndSub

 

 PublicSub OnConnectToEnvironment(ByVal EnvCatID AsString, ByVal pEnvironmentDispatch AsObject, ByVal bFirstTime AsBoolean) Implements SolidEdgeFramework.ISolidEdgeAddIn.OnConnectToEnvironmentDim commandNames(3) AsString

 Dim commandIDs(3) AsInteger

 

 Dim dictionary AsNew System.Collections.Generic.Dictionary(OfInteger, Integer)Try

commandNames(0) = (

commandNames(1) = (

commandNames(2) = (

commandNames(3) = (

commandIDs(0) = 1000

commandIDs(1) = 2000

commandIDs(2) = 3000

commandIDs(3) = 4000

 String.Format("Cadastro{0}Cadastro da Pe‡a / Conjunto{1}Cadastro da Pe‡a / Conjunto{2}Cadastro da Pe‡a / Conjunto", ControlChars.Lf, ControlChars.Lf, ControlChars.Lf))String.Format("Visualiza{0}Visualiza‡Æo Conjunto / Montagem{1}Visualiza‡Æo Conjunto / Montagem{2}Visualiza‡Æo Conjunto / Montagem", ControlChars.Lf, ControlChars.Lf, ControlChars.Lf))String.Format("Banco{0}Cadastro do Sistema de GestÆo{1}Cadastro do Sistema de GestÆo{2}Cadastro do Sistema de GestÆo", ControlChars.Lf, ControlChars.Lf, ControlChars.Lf))String.Format("Configura{0}Configura‡äes{1}Configura‡äes{2}Configura‡äes", ControlChars.Lf, ControlChars.Lf, ControlChars.Lf))Dim ToolBarLarge, ToolBarSmall AsInteger

ToolBarLarge = 2

ToolBarSmall = 1

objAddin.AddCommand(EnvCatID, commandNames(0), commandIDs(0))

objAddin.AddCommand(EnvCatID, commandNames(1), commandIDs(1))

objAddin.AddCommand(EnvCatID, commandNames(2), commandIDs(2))

objAddin.AddCommand(EnvCatID, commandNames(3), commandIDs(3))

 

 

objAddin.SetAddInInfo(Marshal.GetHINSTANCE(

 

 

dictionary.Add(commandIDs.GetValue(i), commandIDs.GetValue(i))

 Me.GetType().Module).ToInt32(), EnvCatID, "IntegraSE", ToolBarSmall, ToolBarLarge, ToolBarSmall, ToolBarLarge, commandIDs.Length, commandNames, commandIDs)Dim iFor i = 0 To commandIDs.Length - 1Next

objenvironmentCommandMap.Add(EnvCatID, dictionary)

 

 

ctr1 = objAddin.AddCommandBarButton(EnvCatID,

ctr2 = objAddin.AddCommandBarButton(EnvCatID,

ctr3 = objAddin.AddCommandBarButton(EnvCatID,

ctr4 = objAddin.AddCommandBarButton(EnvCatID,

objButtonEvents1 = ctr1.CommandBarButtonEvents

objButtonEvents2 = ctr2.CommandBarButtonEvents

objButtonEvents3 = ctr3.CommandBarButtonEvents

objButtonEvents4 = ctr4.CommandBarButtonEvents

 

ctr1.Style = SolidEdgeFramework.SeButtonStyle.seButtonIconAndCaption

ctr2.Style = SolidEdgeFramework.SeButtonStyle.seButtonIconAndCaption

ctr3.Style = SolidEdgeFramework.SeButtonStyle.seButtonIconAndCaption

ctr4.Style = SolidEdgeFramework.SeButtonStyle.seButtonIconAndCaption

 

objAddin.Visible =

 Dim ctr3, ctr4 As SolidEdgeFramework.ISECommandBarButtonDim ctr1, ctr2 As SolidEdgeFramework.ISECommandBarButton"IntegraSE", 1000)"IntegraSE", 2000)"IntegraSE", 3000)"IntegraSE", 4000)True

ctr1.LoadFace(

ctr2.LoadFace(

ctr3.LoadFace(

ctr4.LoadFace(

 

 

MsgBox(ex.Message)

 "C:\Arquivos de programas\Solid Edge ST\Program\Cadastro.bmp")"C:\Arquivos de programas\Solid Edge ST\Program\Estrutura.bmp")"C:\Arquivos de programas\Solid Edge ST\Program\Banco.bmp")"C:\Arquivos de programas\Solid Edge ST\Program\Configura.bmp")Catch ex As ExceptionEndTry

 EndSub

 

 PublicSub OnDisconnection(ByVal DisconnectMode As SolidEdgeFramework.SeDisconnectMode) Implements SolidEdgeFramework.ISolidEdgeAddIn.OnDisconnectionIfNot (objAddin IsNothing) Then

objAddin = Nothing

 EndIf

 IfNot (objApplication IsNothing) Then

objApplication = Nothing

 EndIf

 EndSub

_

 

 

 PublicSharedSub RegisterFunction(ByVal t As Type)Dim baseKey As RegistryKey = Nothing

 Dim summaryKey As RegistryKey = Nothing

 

 

 Dim title As AssemblyTitleAttributeDim description As AssemblyDescriptionAttributeTry

baseKey = Registry.ClassesRoot.CreateSubKey(

baseKey.SetValue(

 "CLSID\{" + t.GUID.ToString + "}")"AutoConnect", 1)If t.Assembly.IsDefined(GetType(AssemblyTitleAttribute), True) Then

title = AssemblyTitleAttribute.GetCustomAttribute(t.Assembly,

baseKey.SetValue(

 GetType(AssemblyTitleAttribute))"409", title.Title)EndIf

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

description = AssemblyDefaultAliasAttribute.GetCustomAttribute(t.Assembly,

summaryKey = baseKey.CreateSubKey(

summaryKey.SetValue(

summaryKey.Close()

 GetType(AssemblyDescriptionAttribute))"Summary")"409", description.Description)EndIf

 'Addin

baseKey.CreateSubKey(

 "Implemented Categories\{26B1D2D1-2B03-11d2-B589-080036E8B802}")'Application

baseKey.CreateSubKey(

 "Environment Categories\{26618394-09D6-11d1-BA07-080036230602}")'All Envirenment Documents

baseKey.CreateSubKey(

 

 "Environment Categories\{BAD41B8D-18FF-42c9-9611-8A00E6921AE8}")Catch ex As ExceptionFinally

 IfNot (summaryKey IsNothing) Then

summaryKey.Close()

 EndIf

 IfNot (baseKey IsNothing) Then

baseKey.Close()

 EndIf

 EndTry

 EndSub

_

 

 

 PublicSharedSub UnregisterFunction(ByVal t As Type)Try

Registry.ClassesRoot.DeleteSubKeyTree(

 

 "CLSID\{" + t.GUID.ToString + "}")Catch ex As ExceptionEndTry

 EndSub

 'Addin Events

 

 PublicSub OnCommand(ByVal CommandID AsInteger) Implements SolidEdgeFramework.ISEAddInEvents.OnCommandEndSub

 

 PublicSub OnCommandHelp(ByVal hFrameWnd AsInteger, ByVal HelpCommandID AsInteger, ByVal CommandID AsInteger) Implements SolidEdgeFramework.ISEAddInEvents.OnCommandHelpEndSub

 

 PublicSub OnCommandUpdateUI(ByVal CommandID AsInteger, ByRef CommandFlags AsInteger, ByRef MenuItemText AsString, ByRef BitmapID AsInteger) Implements SolidEdgeFramework.ISEAddInEvents.OnCommandUpdateUIEndSub

 

 PublicSub AfterActiveDocumentChange(ByVal theDocument AsObject) Implements SolidEdgeFramework.ISEApplicationEvents.AfterActiveDocumentChangeEndSub

 

 PublicSub AfterCommandRun(ByVal theCommandID AsInteger) Implements SolidEdgeFramework.ISEApplicationEvents.AfterCommandRunEndSub

 

 PublicSub AfterDocumentOpen(ByVal theDocument AsObject) Implements SolidEdgeFramework.ISEApplicationEvents.AfterDocumentOpenEndSub

 

 PublicSub AfterDocumentPrint(ByVal theDocument AsObject, ByVal hDC AsInteger, ByRef ModelToDC AsDouble, ByRef Rect AsInteger) Implements SolidEdgeFramework.ISEApplicationEvents.AfterDocumentPrintEndSub

 

 PublicSub AfterDocumentSave(ByVal theDocument AsObject) Implements SolidEdgeFramework.ISEApplicationEvents.AfterDocumentSaveEndSub

 

 PublicSub AfterEnvironmentActivate(ByVal theEnvironment AsObject) Implements SolidEdgeFramework.ISEApplicationEvents.AfterEnvironmentActivateEndSub

 

 PublicSub AfterNewDocumentOpen(ByVal theDocument AsObject) Implements SolidEdgeFramework.ISEApplicationEvents.AfterNewDocumentOpenEndSub

 

 PublicSub AfterNewWindow(ByVal theWindow AsObject) Implements SolidEdgeFramework.ISEApplicationEvents.AfterNewWindowEndSub

 

 PublicSub AfterWindowActivate(ByVal theWindow AsObject) Implements SolidEdgeFramework.ISEApplicationEvents.AfterWindowActivateEndSub

 

 PublicSub BeforeCommandRun(ByVal theCommandID AsInteger) Implements SolidEdgeFramework.ISEApplicationEvents.BeforeCommandRunEndSub

 

 PublicSub BeforeDocumentClose(ByVal theDocument AsObject) Implements SolidEdgeFramework.ISEApplicationEvents.BeforeDocumentCloseEndSub

 

 PublicSub BeforeDocumentPrint(ByVal theDocument AsObject, ByVal hDC AsInteger, ByRef ModelToDC AsDouble, ByRef Rect AsInteger) Implements SolidEdgeFramework.ISEApplicationEvents.BeforeDocumentPrintEndSub

 

 PublicSub BeforeDocumentSave(ByVal theDocument AsObject) Implements SolidEdgeFramework.ISEApplicationEvents.BeforeDocumentSaveEndSub

 

 PublicSub BeforeEnvironmentDeactivate(ByVal theEnvironment AsObject) Implements SolidEdgeFramework.ISEApplicationEvents.BeforeEnvironmentDeactivateEndSub

 

 PublicSub BeforeQuit() Implements SolidEdgeFramework.ISEApplicationEvents.BeforeQuitEndSub

 

 

EndPublicSub BeforeWindowDeactivate(ByVal theWindow AsObject) Implements SolidEdgeFramework.ISEApplicationEvents.BeforeWindowDeactivateEndSubClass

 

Posted by: Fabio Rosa
Post date: 2/19/2009 6:06:11 AM

5 REPLIES

RE: Enable the buttons and create calls

Sorry, the code was messy, but the project is attached ... (VB.NET 2008)

 

Posted by: Fabio Rosa
Post date: 2/19/2009 6:08:50 AM

RE: Enable the buttons and create calls

 

I have having a similar issue where the buttons show up but are never enabled. Has anyone figured out why this can happen? I noticed that the commandBarButton objects returned from my calls to AddCommandBarButton show the buttons with enabled=false so I tried to set them to true with no visible effect.

 

Posted by: Mark Nalevanko
Post date: 6/11/2009 5:11:05 AM

RE: Enable the buttons and create calls

You must sink the ISEAddInEvents for the buttons to be enabled. Solid Edge checks your addin to see if you've sinked the event set. If you haven't, it disables the buttons.

 

Posted by: Jason Newell
Post date: 6/11/2009 5:17:31 AM

RE: Enable the buttons and create calls

 

That makes sense. Is there some sample .NET code out there showing exactly how this should be done. I've seen some for Application and Document events in the .NET programmer's guide for Solid Edge but nothing specific for the Addin Events. Using the other examples as a guideline, I tried the following but it just throws a type cast conversion error (No such interface supported). If I get around the problem by defining AddInCmdEvents as an Object then there's no error but the buttons are still disabled. I must not be misunderstanding something.

 

 

Public Class ExSolidEdgeAddin

    Implements ISolidEdgeAddIn, ISEAddInEvents

 

 

#Region "ISolidEdgeAddIn Member Variables"

 

    Private SolidEdgeAddin As SolidEdgeFramework.AddIn

    Private SolidEdgeApp As SolidEdgeFramework.Application

    Private AddInCmdIDs As Dictionary(Of Integer, Integer)

    Private WithEvents AddInCmdEvents As SolidEdgeFrameWork.ISEAddinEvents

 

#End Region

 

#Region "ISolidEdgeAddIn Methods"

 

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

        SolidEdgeAddin = AddInInstance

        SolidEdgeApp = Application

 

        If SupportedVersion(SolidEdgeApp) Then

 

        End If

        Try

            AddInCmdEvents = AddInInstance.AddInEvents

 

        Catch ex As Exception

 

        End Try

 

        AddInInstance.GuiVersion = 1

    End Sub

 

 

 

Thanks!

 

 

 

 

Posted by: Mark Nalevanko
Post date: 6/11/2009 6:35:28 AM

RE: Enable the buttons and create calls

Well, I figured out my problem. For anyone else that runs into this, be sure to specify the "_Event" part when defining your events object. For example in my case:

 

Private WithEvents AddInCmdEvents As SolidEdgeFrameWork.ISEAddingEvents_Event

 

Then create methods to handle each AddInEvent (OnCommand, etc..)

 

Posted by: Mark Nalevanko
Post date: 6/11/2009 7:06:34 AM