VBA Commands Resource

VBA Commands Resource

emailY6U9U
Contributor Contributor
799 Views
3 Replies
Message 1 of 4

VBA Commands Resource

emailY6U9U
Contributor
Contributor

Starting to dig into macro creation for a couple of different things, but the one resource I can't seem to find that I would really like to have is a list of 'Commands' (for lack of a better term.)

 

I.e. I want to switch between Component and Part Level priority selection in assemblies with a hotkey, and haven't found a way to do that within Inventor. So I'll make a macro and tie it to a hotkey.

 

BUT I don't know what commands to use within VBA, even though I understand the programming language itself. 

 

For those of you doing macro/other design, where are you finding these? Are you starting with the 'record' took? (Is there one?)

 

Is there a reference book somewhere?

 

Thanks!

0 Likes
Accepted solutions (3)
800 Views
3 Replies
Replies (3)
Message 2 of 4

WCrihfield
Mentor
Mentor
Accepted solution

You said you know the VBA programming language OK, so I'm assuming the 'commands' you are looking for are ones related to Inventor specifically.  Here is a link to one of Inventor's online sample VBA macros that will print out a list of Inventor command names.  This is a fairly useful list for reference, and many of us have also written these out to a text file for quick reference.  If you are familiar with iLogic (which uses vb.net) these are useful there too.  And there are also several other variations of the code in that link (iLogic & VBA) which directly store data about the commands out to a text file.  Is this what you wanted?

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.

If you want and have time, I would appreciate your Vote(s) for My IDEAS 💡or you can Explore My CONTRIBUTIONS

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 4

WCrihfield
Mentor
Mentor
Accepted solution

Hi @emailY6U9U .  I still don't know if that list of commands was what you were looking for, but here is a link to another similar resource I just created, that also writes out all Inventor command (ControlDefinition) data out, but the codes at this link write the data out to a new Excel spreadsheet, instead of a text file.  It also includes all other available data (property values) about each command, not just DisplayName & Description.  I've included both VBA and iLogic versions of the codes to write out that data.  If these aren't the commands or types of commands you were looking for, or if you are looking for something completely different, I, or someone else here on the forums may still be able to help you out with it.  Just let us know.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 4 of 4

WCrihfield
Mentor
Mentor
Accepted solution

As far as switching selection priority between Component and Part, I don't think there is a built-in command just  specifically for that, but as you said, it can definitely be done with a macro, and macros show up in the list of commands in the Customize dialog > Keyboard tab, so this definitely sounds doable.  If all you need is the VBA macro code to accomplish this, here is something that works for me.

 

 

Sub ToggleAsmSelectionPriority()
    If ThisApplication.ActiveDocumentType <> kAssemblyDocumentObject Then
        Call MsgBox("An Assembly document must be active for this macro to work.  Exiting.", , "")
        Exit Sub
    End If
    Dim oADoc As AssemblyDocument
    Set oADoc = ThisApplication.ActiveDocument
    Dim oCurSelPriority As SelectionPriorityEnum
    oCurSelPriority = oADoc.SelectionPriority
    If oCurSelPriority = SelectionPriorityEnum.kPartSelectionPriority Then
        oADoc.SelectionPriority = SelectionPriorityEnum.kComponentSelectionPriority
    ElseIf oCurSelPriority = SelectionPriorityEnum.kComponentSelectionPriority Then
        oADoc.SelectionPriority = SelectionPriorityEnum.kPartSelectionPriority
    Else
        oADoc.SelectionPriority = SelectionPriorityEnum.kComponentSelectionPriority
    End If
End Sub

 

 

Setting up the shortcut thing can also very likely be set-up by code, but I doubt it would be a good idea to include that as part of the macro itself.

Is this what you were looking for?

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.

If you want and have time, I would appreciate your Vote(s) for My IDEAS 💡or you can Explore My CONTRIBUTIONS

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes