Inventor 2019: See API calls equivalent to UI interactions

Inventor 2019: See API calls equivalent to UI interactions

Anonymous
Not applicable
624 Views
7 Replies
Message 1 of 8

Inventor 2019: See API calls equivalent to UI interactions

Anonymous
Not applicable

Hi,

 

Is there a way to see the API calls that correspond to a sequence of clicks in the UI? I'm trying to automate some manual tasks with an Add-In but I can't find the sample code in the documentation for my use cases.

 

I can do what I want via the UI, but it's hard to figure out how to translate that to the C# API.

 

Thanks!

0 Likes
625 Views
7 Replies
Replies (7)
Message 2 of 8

clutsa
Collaborator
Collaborator

From VBA editor you can run. It's not a perfect solution but I've never not found what I was looking for.

Sub LookForControls()
Dim app As Application
Set app = ThisApplication


For Each comm In app.CommandManager.ControlDefinitions
    If comm.InternalName Like "*YourTextHere*" Then Debug.Print (comm.InternalName) 
'just a * will return them all but there are over 1000 so it helps to filter it a bit
'I always capitalize the first letter in the word I search, it seems to help (IE."Zoom" over "zoom") Next End Sub
If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

0 Likes
Message 3 of 8

AlexFielder
Advisor
Advisor

If it's UI Events you're after, you need to look for the "Event Viewer" application that gets installed as part of the SDK.

 

You'll find it here:

 

C:\Users\Public\Documents\Autodesk\Inventor {version}\SDK\DeveloperTools\Tools\EventWatcher\bin\Release

 

Inventor needs to be running and IIRC you'll need to run the .exe as administrator.

0 Likes
Message 4 of 8

Anonymous
Not applicable

Thanks for the reply! My problem is not about finding the commands themselves, but to know the exact API methods I need to use to perform a specific action.

 

For example, if in the UI I just click on a surface and hit the "offset" button, what are the equivalent method calls in the API? Sometimes it's trivial because there are quite a few samples in the help section. But sometimes the API throws exceptions or fails for my use cases and I have no idea what I'm doing wrong.

 

Therefore, I assume there are some undocumented assumptions that are not in the documentation and it would be much easier if I can somehow see how Inventor itself is using its own API, it would be much easier to see how to include these steps as part of my addins.

0 Likes
Message 5 of 8

Anonymous
Not applicable

Yeah I've seen the events viewer but that only registers events related to user interaction, I want to write addins that have minimal user interaction but customize my designs in a sepcific way so I want to go straight to the API calls, not the "Commands".

0 Likes
Message 6 of 8

AlexFielder
Advisor
Advisor

You'll need to search the API documentation then:

 

C:\Users\Public\Documents\Autodesk\Inventor {version}\Local Help\

 

Also, if you look in my signature, there's a link to a forum thread I made that shows how to add a custom search engine in Google Chrome that'll take you straight to the relevant information.

0 Likes
Message 7 of 8

Anonymous
Not applicable

Thanks for your reply.

 

I already have access to the documentation easily with the searchbox. My problem is, after reading the documentation and following all the guideline on how to pass the parameters to API functions, I still get exceptions and errors and I don't know what's wrong.

 

That's why I wanted to see how inventor uses its own API, because there are clearly some undocumented assumptions that I'm not following and the API calls just throw opaque errors so I have no clue what's wrong.

0 Likes
Message 8 of 8

AlexFielder
Advisor
Advisor

"Opaque errors" happens a lot. The thing I've found with the documentation is that quite often, it will say exactly what it needs, but the wording is not perhaps as clear as it could be. This kind of enigma wrapped up in a conundrum can occur when the documentation writer knows the subject so well that it is (unfortunately) assumed that the reader has the same level of understanding.


What the documentation needs is a complete overhaul with working examples provided for ALL of the available functions. Take for instance an issue I'm currently working on regarding Content Centre members:


For reasons known only to the developers themselves, it appears as though ContentTableRows and ContentFamilyIds have a unique {guid} identifier that's visible when you edit a Content Center table in Excel (unhide columns A & B and scroll down) but to Inventor, there's also an added string element that wraps around that same string value. In the case of ContentFamily it's this kind of thing: "v3#" + 5856551f-561e-4115-bc3f-0544a13a4940 + "#" whereas for the ContentTableRow it takes this format: "v3#" + 5856551f-561e-4115-bc3f-0544a13a4940 + "#10" - puzzling to say the least!

 

EDIT: So after stepping through a couple of rows in the ContentTable in question, the second "#string" part actually makes sense- my point about why did family have "v3#" at the beginning stands however- unless it's a versioning thing(?) which seems like a terrible idea, because anyone that hard-codes something to look for this is going to have a bad time if the version ever changes!?

0 Likes