Call a productivity routine with VBA

Call a productivity routine with VBA

Patrick1323
Enthusiast Enthusiast
601 Views
1 Reply
Message 1 of 2

Call a productivity routine with VBA

Patrick1323
Enthusiast
Enthusiast
Hello, can I acess a Productivity rotine for example "apha sort component" using vba? regards Patrick
0 Likes
Accepted solutions (1)
602 Views
1 Reply
Reply (1)
Message 2 of 2

pball
Mentor
Mentor
Accepted solution

I found the command name which will let you run it from a script.

 

You can run any command in Inventor using the code below if you have the name of the command.

 

Function Run_CMD(ByVal cmd As String) As Boolean
    ThisApplication.CommandManager.ControlDefinitions.item(cmd).Execute
End Function

'Running the Assembly Productivity Alpha Sort Component command
run_cmd("AssemblyBonusTools_AlphaSortComponentsCmd")

Full list of productivity commands and their command name.

 

AssemblyBonusTools_AddAssemblyCmd                     Inserts a new sub-assembly in the assembly
AssemblyBonusTools_AddPartCmd                         Inserts a new part in the assembly
AssemblyBonusTools_AlphaSortComponentsCmd             Alpha Sort Components
AssemblyBonusTools_CreateSubstitutesCmd               Create Substitutes
AssemblyBonusTools_DeriveComponentCmd                 Derives part from selected base component using default options
AssemblyBonusTools_DOFAnalysisCmd                     Degree of Freedom Analysis
AssemblyBonusTools_GroundAndRootComponentCmd          Grounds component and roots it at origin
AssemblyBonusTools_LinkLODsCmd                        Activates all first-level LODs of same name
AssemblyBonusTools_PlaceAtComponentOriginCmd          Adds new component and fixes it at the origin of selected existing component
AssemblyBonusTools_RenameBrowserNodesCmd              Rename assembly browser nodes
AssemblyBonusTools_SaveAndReplaceComponentCmd         Saves copy of component and replaces existing component in assembly with saved one
AssemblyBonusTools_UpdateSubstitutesCmd               Update All Substitutes

 

Edit:

You can also use this bit of code from the api help to list all commands.

 

Sub PrintCommandNames()
    Dim oControlDefs As ControlDefinitions
    Set oControlDefs = ThisApplication.CommandManager.ControlDefinitions

    Dim oControlDef As ControlDefinition
    
    Open "C:\Users\Greg Fletcher\OneDrive - Motion Controls Robotics, Inc-\Inventor\Scripting\Misc\Command Names.txt" For Output As #1

    Print #1, Tab(10); "Command Name"; Tab(75); "Description"; vbNewLine
    
    For Each oControlDef In oControlDefs
        Print #1, oControlDef.InternalName; Tab(55); oControlDef.DescriptionText
    Next
    Close #1
End Sub
Check out my style edits for the Autodesk forums
pball's Autodesk Forum Style