There is a sample in the inventor programming help that might help. I have found these samples to be extremely helpful when getting started.
From the Inventor Programming Help file:
Environments
Environments are a mechanism within Autodesk Inventor that attempt to simplify the user interface so that the user is presented with a limited set of commands that are appropriate for the task at hand. For example, when you activate a sketch within a part, the sketch environment is displayed. This environment provides access to the sketch-related commands. When you finish the sketch and return back to the part, Autodesk Inventor changes the active environment to the part environment.
The implementation of environments within Autodesk Inventor is quite simple. It's important to understand exactly which environments do and do not accomplish. The Environments tab of the Options dialog provides a graphical view of all of the information related to an environment. Using this, the user can customize environments to better suit their specific needs. The API also provides access to this information.
An environment defines five things:
The command bar that is initially displayed within the panel bar.
The command bar that is displayed within the standard toolbar.
The command bar this is displayed as the menu. (This feature is not available through the Customize command, but is available only through the API.)
The list of command bars that you can switch between in the panel bar.
The list of command bars that are displayed when you right-click on any existing tool bar or menu. From this list, you can turn the visibility on or off for any of the command bars listed. When displayed, these command bars behave as custom toolbars.
That's it. That's the extent of what an environment defines. One thing that's important to remember is that custom toolbars are not associated with any particular environment. It's only the list that allows you to easily toggle their visibility that's associated with an environment. Custom toolbars themselves are environment independent and once displayed will remain displayed regardless of how the context changes within Inventor. If you want a command bar to be context sensitive, it should be associated with the panel bar.
The following code demonstrates adding a command bar to the panel bar list of the part environment.
Code:
' Get the part environment.
Dim oPartEnv As Environment
Set oPartEnv = oUIManager.Environments.Item("PMxPartEnvironment")
' Set a reference to the PanelBar object.
Dim oPanelBar As PanelBar
Set oPanelBar = oPartEnv.PanelBar
' Add the command bar to the command bar list of the panel bar.
Call oPanelBar.CommandBarList.Add oCommandBar
The following sample demonstrates most of the concepts discussed so far. It adds a new menu item to the part environment and would be within the Activate method of an Add-In. Notice that it creates two types of controls, buttons and pop-ups. The pop-ups are buttons that don't directly cause any command to run but instead cause a menu to pop-up. All standard menu items are pop-up controls and any fly-out menus are also accessed through a pop-up control.
Code:
' Load an icon from a resource file and create a button definition.
Dim oIcon As IPictureDisp
Set oIcon = LoadResPicture(101, vbResIcon)
Set oButtonDefinition1 = oControlDefinitions.AddButtonDefinition( _
"Button 1", "invrSampleCommand1", _
kQueryOnlyCmdType, "CLSID of the AddIn", _
"This is button 1.", "Button 1", _
oIcon, oIcon)
' Create two more button definitions. One with an icon and one without.
Set oIcon = LoadResPicture(102, vbResIcon)
Set oButtonDefinition2 = oControlDefinitions.AddButtonDefinition( _
"Button 2", "invrSampleCommand2", _
kQueryOnlyCmdType, "CLSID of the AddIn", _
"This is button 2.", "Button 2", _
oIcon, oIcon)
Set oButtonDefinition3 = oControlDefinitions.AddButtonDefinition( _
"Button 3", "invrSampleCommand3", _
kQueryOnlyCmdType, "CLSID of the AddIn", _
"This is button 3.", "Button 3")
' Get the part environment object.
Dim oPartEnv As Environment
Set oPartEnv = oUIManager.Environments.Item("PMxPartEnvironment")
' Get the command bar that is used for the part menu.
Dim oPartMenuCB As CommandBar
Set oPartMenuCB = oPartEnv.DefaultMenuBar
' Create a command bar of a pop-up type for a flyout.
Dim oFlyOutCmdBar As CommandBar
Set oFlyOutCmdBar = oUIManager.CommandBars.Add("More Commands", _
"FlyoutCmdBar", kPopupCommandBar, "CLSID of the AddIn")
' Add two buttons to the fly-out command bar.
Call oFlyOutCmdBar.Controls.AddButton(oButtonDefinition2)
Call oFlyOutCmdBar.Controls.AddButton(oButtonDefinition3)
' Create a command bar of a pop-up type for a menu popup.
Dim oMenuPopupCmdBar As CommandBar
Set oMenuPopupCmdBar = oUIManager.CommandBars.Add("Test", _
"MenuPopupCmdBar", kPopupCommandBar, "CLSID of the AddIn")
' Add a command to the menu pop-up.
Call oMenuPopupCmdBar.Controls.AddButton(oButtonDefinition1)
' Add the fly-out to the menu pop-up.
Call oMenuPopupCmdBar.Controls.AddPopup(oFlyOutCmdBar)
' Get the index of the Help control.
Dim HelpIndex As Long
HelpIndex = oPartMenuCB.Controls.Item("AppHelpMenu").Index
' Add the menu popup to part menu before the Help control.
Call oPartMenuCB.Controls.AddPopup(oMenuPopupCmdBar, HelpIndex)