See the top rated post in this thread. Click here

Results 1 to 8 of 8

Thread: Inventor macro button

  1. #1
    Active Member
    Join Date
    2008-12
    Posts
    75
    Login to Give a bone
    0

    Default Inventor macro button

    Hi all,

    I'm trying to figure out how to make an expandable macro button like the one used for center lines (see attached image). but so far i've found nothing... anyone know if this is possible? if so, any information would be greatly appreciated.

    using IV2008 sp3,

    Cheers
    Attached Images Attached Images

  2. #2
    Active Member
    Join Date
    2008-12
    Posts
    75
    Login to Give a bone
    0

    Default Re: Inventor macro button

    Anyone have any ideas?

  3. #3
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,420
    Login to Give a bone
    1

    Default Re: Inventor macro button

    I don't think many of the vba'ers here use Inventor. However, perhaps using the correct terminology will help you in your search. That feature is called a toolbar flyout and would be part of the application object's api.
    C:> ED WORKING....


    LinkedIn

  4. #4
    Active Member
    Join Date
    2008-12
    Posts
    75
    Login to Give a bone
    0

    Default Re: Inventor macro button

    Cool, Thanks for that tip, There's some help in the inventor help files, but it applies to command menus, rather then toolbar buttons, but i'll investigate to see if I can make it work...

    And yes, I apologise for the lack of terminology, I'm just beginning to learn this vba stuff...

    Cheers

  5. #5
    Active Member
    Join Date
    2008-02
    Location
    Central IL
    Posts
    53
    Login to Give a bone
    0

    Default Re: Inventor macro button

    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)

  6. #6
    Active Member
    Join Date
    2008-12
    Posts
    75
    Login to Give a bone
    0

    Default Re: Inventor macro button

    Yep, that's the one I found in the help files, Will have a good look through when i get a chance, Thanks for the help... Always appreciated.

  7. #7
    Active Member
    Join Date
    2008-02
    Location
    Central IL
    Posts
    53
    Login to Give a bone
    0

    Default Re: Inventor macro button

    I assume that you were trying to build a flyout button programatically. I tried to do it manually in the toolbar customization, but was unsuccessful in my attempt. I have several macros that I have written that would be nice to embed in a flyout button, but I don't have the need to make software to do it for me.

  8. #8
    Active Member
    Join Date
    2008-12
    Posts
    75
    Login to Give a bone
    0

    Default Re: Inventor macro button

    ed - That's exactly what i'm trying to do, basically because I'm not aware of any other way. You say you were unsuccessful at doing it manually? is that because there is no way? or because you found a way, but it didn't work as planned?

    If i get it sorted i'll let you know.

    Cheers

Similar Threads

  1. Display from button macro
    By Liamnacuac in forum AutoCAD CUI Menus
    Replies: 2
    Last Post: 2011-05-23, 09:27 PM
  2. macro print button
    By sigmaman88 in forum AutoLISP
    Replies: 1
    Last Post: 2010-06-14, 05:29 AM
  3. Button macro
    By thomas.stright in forum AutoLISP
    Replies: 1
    Last Post: 2009-09-23, 01:45 PM
  4. Button Macro Help
    By ahefner in forum AutoLISP
    Replies: 5
    Last Post: 2007-07-17, 05:10 PM
  5. VBA button macro won't run
    By CADKitty in forum VBA/COM Interop
    Replies: 10
    Last Post: 2006-05-25, 07:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •