Macro to select constraint type

Macro to select constraint type

Anonymous
Not applicable
409 Views
2 Replies
Message 1 of 3

Macro to select constraint type

Anonymous
Not applicable

Hi,

 

I'm very new to VB programming and Inventor's API. One thing that my co workers and I would really like is a macro that would allow us to pre-select what assembly constraint type we want to use, rather than the default mate. We use Insert quite a lot, for instance, and would like to be able to program a keystroke to bring up the constraint dialog with Insert pre-selected. Could anyone give me a little guidance as to whether or not this is possible, and how I would go about accessing that part of the API?

 

Thank you.

0 Likes
410 Views
2 Replies
Replies (2)
Message 2 of 3

philippe.leefsma
Alumni
Alumni

Hi Ekaspar,

 

In most cases the Inventor API allows you to automate workflows but very rarely to control the native dialogs and tools that are used by Inventor.

 

You can programmatically fire the constraint dialog as follow (VBA) but don't have any control over the content of this dialog:

 

Public Sub ExecuteCommand()

ThisApplication.CommandManager.ControlDefinitions.item("AssemblyInsertConstraintCmd").Execute
    
End Sub

 It's theoritically possible to "simulate" user actions on a form by using low level Windows APIs, but achieving this will definitely require a good knowledge of Win32 APIs. If you are interested in the topic, you should take a look over the web for "CBT Hook" for example, then how you can send messages to a specific Windows control.

 

This is clearly a hack, so you will need to research this kind of workaround on your own, we don't directly support such questions.

 

Hope that helps,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 3 of 3

Anonymous
Not applicable

Thanks for the informative answer. I'll maybe look in those directions.

0 Likes