MacroControlDefinition does not work in 2014
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I wrote an addin for Inventor 2013. It works properly.
Added the same adding for Inventor 2014 and it creates the buttons,
but does not launch the macros as it did in 2013.
Nothing happens when you click on the buttons.
*** What has changed? ***
As I have to install every Inventor seat in the company I want keep the customization as easy as possible.
I have about twelve critical macros that the users want to see at all times.
Since Autodesk took away toolbars after version 2011 I had to come up with something else.
I settled on using the Quick Access Toolbar as it is displayed at all times.
The code in my addin opens a file at a fixed location and automatically populates the Quick Access Toolbar with my macros for each environment.
[code]
Namespace LoadVbaMacros
<ProgIdAttribute("LoadVbaMacros.StandardAddInServer"), _
GuidAttribute("80678e4b-8fd4-4bd5-a920-2ca75174f845")> _
Public Class StandardAddInServer
Implements Inventor.ApplicationAddInServer
' Inventor application object.
Private m_inventorApplication As Inventor.Application
#Region "ApplicationAddInServer Members"
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
Dim ZeroDocQAControls As Inventor.CommandControls = m_inventorApplication.UserInterfaceManager.Ribbons.Item("ZeroDoc").QuickAccessControls
Dim PrtQAControls As Inventor.CommandControls = m_inventorApplication.UserInterfaceManager.Ribbons.Item("Part").QuickAccessControls
Dim AssyQAControls As Inventor.CommandControls = m_inventorApplication.UserInterfaceManager.Ribbons.Item("Assembly").QuickAccessControls
Dim DwgQAControls As Inventor.CommandControls = m_inventorApplication.UserInterfaceManager.Ribbons.Item("Drawing").QuickAccessControls
' Add macrobuttons to the Quick Access Toolbar.
Dim sMacros() As String = IO.File.ReadAllLines("C:\Dim_Power\Local DB\PSPMacroBar.txt")
For Each sMacro As String In sMacros
If Not sMacro.Contains(":") Then sMacro = ""
If sMacro.Trim.StartsWith("'") Then sMacro = ""
If sMacro <> "" Then
Dim sSeg() As String = sMacro.Split(":"c)
Dim sEnviron As String = sSeg(0).Trim.ToLower
Dim sMacroName = sSeg(1).Trim
sMacroName = "macro:basLaunch." & sMacroName
Dim myMacro As Inventor.MacroControlDefinition = CType(m_inventorApplication.CommandManager.ControlDefinitions.Item(sMacroName), MacroControlDefinition)
Select Case sEnviron
Case "zerodoc"
ZeroDocQAControls.AddMacro(myMacro)
Case "part"
PrtQAControls.AddMacro(myMacro)
Case "assembly"
AssyQAControls.AddMacro(myMacro)
Case "drawing"
DwgQAControls.AddMacro(myMacro)
End Select
End If
End if
End if
Next
ZeroDocQAControls = Nothing
PrtQAControls = Nothing
AssyQAControls = Nothing
DwgQAControls = Nothing
End Sub
...
[/code]
