First Add ins DLL not showing in Customize-Ribbon-all commands

First Add ins DLL not showing in Customize-Ribbon-all commands

^_^clovis^_^
Advocate Advocate
863 Views
4 Replies
Message 1 of 5

First Add ins DLL not showing in Customize-Ribbon-all commands

^_^clovis^_^
Advocate
Advocate

hello guys,

 

I have some issue with my first Add ins.

I've already checked several tutorials but when I try them I'm getting some references error.

Or they are too complicated for my first try.

 

I get a DLL

that I put in

C:\Program Files\Autodesk\Inventor 2014\Bin

 

I get a .addin

that I put in

C:\ProgramData\Autodesk\Inventor 2014\Addins

 

When I open Inventor I can find my Addins in the add-in Manager but I can't see it in the

customise -> Ribbon -> all commands

 

Module Module1
    Public Sub SortBom()
        Dim invApp As Application
        invApp = Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application")

        Dim drw As DrawingDocument
        drw = invApp.ActiveDocument

        If drw.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
            MsgBox("Only in Idw..")
            Exit Sub
        End If

        Dim oPartsLists As PartsLists
        oPartsLists = drw.ActiveSheet.PartsLists
        Dim oPartsList As PartsList
        Try
            For Each oPartsList In oPartsLists
                oPartsList.Sort("REFERENCE", True, "DIMENSION", True, "TITLE", True)
                oPartsList.Renumber()
                oPartsList.SaveItemOverridesToBOM()
            Next
        Catch ex As Exception
            MsgBox("No Standard Bom", , "Error")
        End Try
    End Sub
End Module

I've checked this Addin (Thanks to "USTG_ENGGSERV_ACAD")

but it's a bit too much as I don't need the dynamic creation of a button.

 

Is there somewhere a (simple) example as "how to" make an Add-in showing in the customise -> Ribbon -> all commands?

Thanks for any advice

0 Likes
864 Views
4 Replies
Replies (4)
Message 2 of 5

^_^clovis^_^
Advocate
Advocate

I've got this small macro working without problem with VBA but VB.net seems to ask much more.

I forgot to add the pic I wish to use

0 Likes
Message 3 of 5

pball
Mentor
Mentor
I have a home made addin also so I took a look at the customize ribbon options. I see all of the functions that have ribbon buttons added via the addin but the one test function I do not have a button for does not appear in the list.

I'm guessing for addin functions you either have the addin add the button or you can't access it via a button.
Check out my style edits for the Autodesk forums
pball's Autodesk Forum Style
0 Likes
Message 4 of 5

^_^clovis^_^
Advocate
Advocate

Hello Guys,

I think I'm almost finished with the button implementation. When I run to make the dll I get a window "UserControl TestContainer"

What should I do with it?

THanks for any help

Herewith my standardAddInServer.vb for any comment :

 

Imports Inventor
Imports System.Runtime.InteropServices
Imports Microsoft.Win32


Namespace SortBOM
    <ProgIdAttribute("SortBOM.StandardAddInServer"), _
    GuidAttribute("11471b1b-1d49-411b-beeb-b2d0a5068c23")> _
    Public Class StandardAddInServer
        Implements Inventor.ApplicationAddInServer

        ' Inventor application object.
        Private m_inventorApplication As Inventor.Application
#Region "Data Members"

        ' Events
        Private WithEvents m_uiEvents As UserInterfaceEvents
        ' Buttons
        Private WithEvents m_Button_1 As ButtonDefinition

        Private m_AddInCLSIDString As String
        Private oDrwPanel As String = "Drawing"
        Private oCustomPanel As String = "User Commands"
#End Region

#Region "ApplicationAddInServer Members"
        Private Sub AddToUserInterface()
            'Get idw Ribbon
            Dim idwRibbon As Ribbon = m_inventorApplication.UserInterfaceManager.Ribbons.Item("Drawing")

            'get the tools tab
            Dim toolsTab As RibbonTab = idwRibbon.RibbonTabs.Item("id_AddInsTab")
            Dim userPanel As RibbonPanel = toolsTab.RibbonPanels.Item("Drawing.id_AddInsTab.UserCommands")
            userPanel.CommandControls.AddButton(m_Button_1)

        End Sub
        Public Sub Activate(ByVal addInSiteObject As Inventor.ApplicationAddInSite, ByVal firstTime As Boolean) Implements Inventor.ApplicationAddInServer.Activate

            ' This method is called by Inventor when it loads the AddIn.
            ' The AddInSiteObject provides access to the Inventor Application object.
            ' The FirstTime flag indicates if the AddIn is loaded for the first time.

            ' Initialize AddIn members.
            m_inventorApplication = addInSiteObject.Application

            ' TODO:  Add ApplicationAddInServer.Activate implementation.
            ' e.g. event initialization, command creation etc.
            ' Initialize event handlers
            m_uiEvents = m_inventorApplication.UserInterfaceManager.UserInterfaceEvents
            AddHandler m_uiEvents.OnResetCommandBars, AddressOf Me.m_uiEvents.OnResetCommandBars
            AddHandler m_uiEvents.OnResetRibbonInterface, AddressOf Me.m_uiEvents.OnResetRibbonInterface

            ' Retrieve the GUID for this class
            Dim AddInCLSID As GuidAttribute
            AddInCLSID = CType(System.Attribute.GetCustomAttribute(GetType(StandardAddInServer), GetType(GuidAttribute)), GuidAttribute)

            m_AddInCLSIDString = "{" & AddInCLSID.Value & "}"

            ' Create New buttons
            Dim controldefs As Inventor.ControlDefinitions
            controldefs = m_inventorApplication.CommandManager.ControlDefinitions
            m_Button_1 = controldefs.AddButtonDefinition(
                        "SortBOM", _
                        "SortBOM", _
                        CommandTypesEnum.kNonShapeEditCmdType, _
                        m_AddInCLSIDString, _
                        "Sorting the BOM", _
                        "Sorting the BOM", _
                        "SortItemList.large.bmp", _
                        "SortItemList.large.bmp", _
                        ButtonDisplayEnum.kDisplayTextInLearningMode)
            'add to the user interface if it's the first time
            If firstTime Then
                m_Button_1.CreateButton()
                AddToUserInterface()
            End If

        End Sub
        Private Sub m_uiEvents_onResetRibbonInterface(Context As NameValueMap) Handles m_uiEvents.OnResetRibbonInterface
            'add back the userInterface
            AddToUserInterface()
        End Sub

        'handler for the button
        Private Sub m_button_onExcecute(context As NameValueMap) Handles m_Button_1.OnExecute
            Module1.SortBom()
        End Sub

        Public Sub Deactivate() Implements Inventor.ApplicationAddInServer.Deactivate

            ' This method is called by Inventor when the AddIn is unloaded.
            ' The AddIn will be unloaded either manually by the user or
            ' when the Inventor session is terminated.

            ' TODO:  Add ApplicationAddInServer.Deactivate implementation

            ' Release objects.
            m_inventorApplication = Nothing

            System.GC.Collect()
            System.GC.WaitForPendingFinalizers()
        End Sub

        Public ReadOnly Property Automation() As Object Implements Inventor.ApplicationAddInServer.Automation

            ' This property is provided to allow the AddIn to expose an API 
            ' of its own to other programs. Typically, this  would be done by
            ' implementing the AddIn's API interface in a class and returning 
            ' that class object through this property.

            Get
                Return Nothing
            End Get

        End Property

        Public Sub ExecuteCommand(ByVal commandID As Integer) Implements Inventor.ApplicationAddInServer.ExecuteCommand

            ' Note:this method is now obsolete, you should use the 
            ' ControlDefinition functionality for implementing commands.

        End Sub

#End Region

    End Class

End Namespace

 

0 Likes
Message 5 of 5

^_^clovis^_^
Advocate
Advocate

Hello,

 

I've finally got a button working with a macro.

Would someone be kind to explain me the use of "commandBars" in "inventorApplication.UserInterfaceManager" as I can't find info about it

I also can't find info about CommandBars.Item("PMxPartFeatureCmdBar")?

 

I'd like to put a button in ribbons.item("Drawing").RibbonTabs.Item("id_AddInsTab"). What should I put in "CommandBars.Item("xxxxxx")?

 

Inventor 2014/visual studio express 2010

(I'll update in November to INV2017)

 

Thanks for any help

0 Likes