- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Good morning all, I'm trying to learn the AIP. Going through some of the example in the API help section, there are several samples (about every other one) that fail when I run them. I have tried running them in a ZeroDocument/part/assembly environment and with no changes to the code or outcome.
For example, when I try to run the "Add commands to the application menu API Sample" (shown at the end), here is what I see:
Placing a watch on oFileBrowserControls agrees with the error that the .AddButton command isn't found.
However, when I check with Intelisense, it does show up as an available method:
The API samples inside the API help documentation are meant to be stand-alone subs, right?
What am I missing?
Sub AddCommandsToFileBrowser()
' Get the application menu controls collection
Dim oFileBrowserControls As CommandControls
Set oFileBrowserControls = ThisApplication.UserInterfaceManager.FileBrowserControls
' Get the "Zoom All" and "Home View" commands
Dim oDef1 As ButtonDefinition
Set oDef1 = ThisApplication.CommandManager.ControlDefinitions.Item("AppZoomAllCmd")
Dim oDef2 As ButtonDefinition
Set oDef2 = ThisApplication.CommandManager.ControlDefinitions.Item("AppIsometricViewCmd")
' Create button controls, positioned before the "Manage" control
Call oFileBrowserControls.AddButton(oDef1, True, True, "Manage", True)
Call oFileBrowserControls.AddButton(oDef2, True, True, "Manage", True)
Call oFileBrowserControls.AddSeparator("Manage", True)
End Sub
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
The trick here is "Fails every other one" The code worked the first time and fails the second because it can't add the button again. Do you have the buttons below? Those aren't standard (in that location) if those are there the code worked.
Mass Override for Each Model State
Custom Glyph Icon for iMates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
@clutsa, thanks for the quick response.
Yes, those two buttons did show up in the File Browser, I was thinking they would be added to the top ribbon instead.
What I just tried was closing the Inventor session (not saving the AppProject) and started a new Inventor session. After verifying I did not have the buttons in the File Browser, I re-ran the Sub with breakstops on oFileBrowserControls looking for the .AddButton command. There still isn't the command listed in Watches panel.
If .AddButton is available for the API to call, why isn't it shown in a Watch?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm kind of confused what you're asking but I think the answer you're looking for is... AddButton() is a method(rule/action) of oFileBrowserControls object, not a variable. So in the watch window you wouldn't see the methods available but you could find them in the object browser. The screen-cast below was for someone else but you'll get the idea.
Mass Override for Each Model State
Custom Glyph Icon for iMates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Light bulb moment!
Yes, you are exactly right.
I've been learning vb.net using Visual Studio, and grew accustomed and spoiled on being able to watch for methods and variables inside the watch window. Like you stated, VBA does not support watching methods.
Thanks for the assistance!