Inventor AIP Samples in the API Help Fail.

Inventor AIP Samples in the API Help Fail.

Anonymous
Not applicable
765 Views
4 Replies
Message 1 of 5

Inventor AIP Samples in the API Help Fail.

Anonymous
Not applicable

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:INV_Demo2.PNG

 

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:

INV_Demo1.PNG

 

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
0 Likes
Accepted solutions (1)
766 Views
4 Replies
Replies (4)
Message 2 of 5

clutsa
Collaborator
Collaborator

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. 

FileView.PNG

If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

Message 3 of 5

Anonymous
Not applicable

@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?

0 Likes
Message 4 of 5

clutsa
Collaborator
Collaborator
Accepted solution

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.

 

 

If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

Message 5 of 5

Anonymous
Not applicable

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!

0 Likes