@DRoam wrote:
Haha, thanks a ton, Curtis. What, no cutlery icons for the macro buttons? 😉
Question about this... in this blog post: Rename the "User Commands" panel, Mr. Nagy says that "programmatically added UI elements are not persisted. So you would have to run your command that adds the extra ribbon panel each time Inventor starts."
Hi @DRoam
Ahh, good point here are some links concerning macro button setup for those that might find this in the future and have not done this before:
https://modthemachine.typepad.com/my_weblog/2016/02/creating-a-button-for-a-vba-macro.html
https://modthemachine.typepad.com/my_weblog/2010/03/buttons-for-vba-macros-in-the-ribbon-user-interf...
As for getting the custom ribbon panels to persist, Mr. Nagy is correct. What I have done is to load them using an Event Trigger.
With Inventor 2017 and previous, it's a bit more difficult, but with 2018 and on there is an All Documents event trigger category, that you can use for this:
- Create an external ilogic rule and add this: (where project name, module name, and macro name match)
- InventorVb.RunMacro("ApplicationProject", "Module_CustomRibbon", "Customize_Ribbon")
- Then add this external rule to the All Documents > After Open Document and New Document event triggers
- And then finally you'll likely want to make a modification to the example code I posted yesterday and replace this:
'clean up existing custom panels
'this prevents errors when panels
'already exists
Dim oPanel As RibbonPanel
For Each oPanel In oTab.RibbonPanels
If oPanel.DisplayName = "My Assembly Tools" _
Or oPanel.DisplayName = "My Drawing Tools" _
Or oPanel.DisplayName = "My Part Tools" Then
oPanel.Delete 'remove it
End If
Next
With this:
'check for existing custom panels
'and exit sub when found
'this prevents errors when panels
'already exists
Dim oPanel As RibbonPanel
For Each oPanel In oTab.RibbonPanels
If oPanel.DisplayName = "My Assembly Tools" _
Or oPanel.DisplayName = "My Drawing Tools" _
Or oPanel.DisplayName = "My Part Tools" Then
Exit Sub
End If
Next
This prevents the macro from running fully, when the tool panels already exist.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com