jpoeske
2009-05-19, 07:49 PM
I have created an add in for Inventor 2009. For reference I followed the "SimpleAddIn" included in the SDK. My program works fine other than one glitch and I have searched high and low on the internet to find an answer. I am running 32bit Vista, Inventor 2009 SP2, Coding in Visual Studio 2008.
In the program I create a toolbar with a single button that is to be added to the Part, Drawing, Presentation, and Assembly enviroments. On the first run, the add in shows as "Startup/Loaded" in the add in manager. The toolbar also shows up in the customize dialog box under the "enviroments" tab in the "Available toolbars" panel. It also shows on the "toolbars" tab. If I open any of the above four enviroments it is available to use in the panel bar and works as intended.
On the second or any later run of the program the add in shows as "Startup/Loaded" in the add in manager. But in the Customize dialog box it does not show in the "enviroments" tab in the "Available toolbars" panel or in the "toolbars" tab. It also does not show the toolbar in any of the forementioned enviroments.
I did a little digging and found that in the "HKEY_CURRENT_USER\Software\Autodesk\Inventor\RegistryVersion13.0\UI Customization VS\Command Owner ID's" the GUID is there and so is the GUID for the SimpleAddIn.
Under the GUID for the SimpleAddIn there is an Items folder that contans the reference to the Toolbar and the buttons created for that program. Under the GUID for my program the Items folder does not exist.
It looks as if the created items (toolbar, and button) are not getting added to the registry on the first run.
if I explicitly create the toolbar and add it to the selected enviroments each time it works fine(like below). But if I change (firstTime==true) it wont have them in the registry to recreate. It is fairly obvious that it is not registering correctly, but I cannot see why.
Any directions to look in would be appreciated.
if (firstTime == false)
{
UserInterfaceManager m_userInterfaceManager;
m_userInterfaceManager = m_inventorApplication.UserInterfaceManager;
//create toolbar
CommandBar KolbePublishCmdbar;
KolbePublishCmdbar = m_userInterfaceManager.CommandBars.Add("Kolbe Property Wizard", "Autodesk:KolbePropertyWiz:KolbePropertyToolbar", CommandBarTypeEnum.kRegularCommandBar, sAddInCLSID);
// add the button to the toolbar
KolbePublishCmdbar.Controls.AddButton(m_publishButton.ButtonDefinition, 0);
//get the IDWEnviroment and add the command bar
Inventor.Environment IDWEnviroment;
IDWEnviroment = m_userInterfaceManager.Environments["DLxDrawingEnvironment"];
IDWEnviroment.PanelBar.CommandBarList.Add(KolbePublishCmdbar);
//get the IPTEnviroment and add the command bar
Inventor.Environment IPTEnviroment;
IPTEnviroment = m_userInterfaceManager.Environments["PMxPartEnvironment"];
IPTEnviroment.PanelBar.CommandBarList.Add(KolbePublishCmdbar);
//get the IAMEnviroment and add the commad bar
Inventor.Environment IAMEnviroment;
IAMEnviroment = m_userInterfaceManager.Environments["AMxAssemblyEnvironment"];
IAMEnviroment.PanelBar.CommandBarList.Add(KolbePublishCmdbar);
//get the IPNEnviroment and add the command bar
Inventor.Environment IPNEnviroment;
IPNEnviroment = m_userInterfaceManager.Environments["DXxPresentationEnvironment"];
IPNEnviroment.PanelBar.CommandBarList.Add(KolbePublishCmdbar);
}
Thanks,
Jason
In the program I create a toolbar with a single button that is to be added to the Part, Drawing, Presentation, and Assembly enviroments. On the first run, the add in shows as "Startup/Loaded" in the add in manager. The toolbar also shows up in the customize dialog box under the "enviroments" tab in the "Available toolbars" panel. It also shows on the "toolbars" tab. If I open any of the above four enviroments it is available to use in the panel bar and works as intended.
On the second or any later run of the program the add in shows as "Startup/Loaded" in the add in manager. But in the Customize dialog box it does not show in the "enviroments" tab in the "Available toolbars" panel or in the "toolbars" tab. It also does not show the toolbar in any of the forementioned enviroments.
I did a little digging and found that in the "HKEY_CURRENT_USER\Software\Autodesk\Inventor\RegistryVersion13.0\UI Customization VS\Command Owner ID's" the GUID is there and so is the GUID for the SimpleAddIn.
Under the GUID for the SimpleAddIn there is an Items folder that contans the reference to the Toolbar and the buttons created for that program. Under the GUID for my program the Items folder does not exist.
It looks as if the created items (toolbar, and button) are not getting added to the registry on the first run.
if I explicitly create the toolbar and add it to the selected enviroments each time it works fine(like below). But if I change (firstTime==true) it wont have them in the registry to recreate. It is fairly obvious that it is not registering correctly, but I cannot see why.
Any directions to look in would be appreciated.
if (firstTime == false)
{
UserInterfaceManager m_userInterfaceManager;
m_userInterfaceManager = m_inventorApplication.UserInterfaceManager;
//create toolbar
CommandBar KolbePublishCmdbar;
KolbePublishCmdbar = m_userInterfaceManager.CommandBars.Add("Kolbe Property Wizard", "Autodesk:KolbePropertyWiz:KolbePropertyToolbar", CommandBarTypeEnum.kRegularCommandBar, sAddInCLSID);
// add the button to the toolbar
KolbePublishCmdbar.Controls.AddButton(m_publishButton.ButtonDefinition, 0);
//get the IDWEnviroment and add the command bar
Inventor.Environment IDWEnviroment;
IDWEnviroment = m_userInterfaceManager.Environments["DLxDrawingEnvironment"];
IDWEnviroment.PanelBar.CommandBarList.Add(KolbePublishCmdbar);
//get the IPTEnviroment and add the command bar
Inventor.Environment IPTEnviroment;
IPTEnviroment = m_userInterfaceManager.Environments["PMxPartEnvironment"];
IPTEnviroment.PanelBar.CommandBarList.Add(KolbePublishCmdbar);
//get the IAMEnviroment and add the commad bar
Inventor.Environment IAMEnviroment;
IAMEnviroment = m_userInterfaceManager.Environments["AMxAssemblyEnvironment"];
IAMEnviroment.PanelBar.CommandBarList.Add(KolbePublishCmdbar);
//get the IPNEnviroment and add the command bar
Inventor.Environment IPNEnviroment;
IPNEnviroment = m_userInterfaceManager.Environments["DXxPresentationEnvironment"];
IPNEnviroment.PanelBar.CommandBarList.Add(KolbePublishCmdbar);
}
Thanks,
Jason