ok so here is an update
I have figured out how to divide some of these functions into separate
Dim oRibbon As Inventor.Ribbon
Dim oDoc As Document
oDoc = ThisApplication.ActiveEditDocument
If oDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
oRibbon = ThisApplication.UserInterfaceManager.Ribbons.Item("Assembly")
oType = "Assembly"
ElseIf oDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
oRibbon = ThisApplication.UserInterfaceManager.Ribbons.Item("Part")
oType = "Part"
ElseIf oDoc.DocumentType = DocumentTypeEnum.kDrawingDocumentObject Then
oRibbon = ThisApplication.UserInterfaceManager.Ribbons.Item("Drawing")
oType = "Drawing"
Else
oType = "Unknown"
Exit Sub
End If '<-------- if, else if refrences opened file for name nomenclature
oName = "Silent-Aire_" '<---- name nomenclature
Try
oRibbon.RibbonTabs.Item(oName & oType).Delete '<------finds if old tab is present and deletes it
Catch
End Try
Dim oControlDefs As ControlDefinitions
oControlDefs = ThisApplication.CommandManager.ControlDefinitions '<----- tells inventor that comands will be executed on this file
Dim oTab As Inventor.RibbonTab
oTab = oRibbon.RibbonTabs.Add(oName & oType, oName & oType, “Silent-Aire”) '<----- creates ribbon tab
oTab.Active = True
Dim oPanel As RibbonPanel
sPanelName = "Tools"
oPanel = oTab.RibbonPanels.Add(sPanelName, oName & oType, oName & oType) '<----- creates first panel on ribbon tab
Dim aButtonsList As New ArrayList
If oType = "Drawing" Then '<----- this section creates the clickable buttons
aButtonsList.Add("Ribbon_Executables.Reuse_Drawing") '<-----(VBA code name.button name)
aButtonsList.Add("Ribbon_Executables.Center_Dimensions")
aButtonsList.Add("Ribbon_Executables.Missing_Balloons")
aButtonsList.Add("Ribbon_Executables.Sort_and_Hide_Partlist")
Else If oType = "Assembly" Then
aButtonsList.Add("Ribbon_Executables.Open_All_Drawings")
aButtonsList.Add("Ribbon_Executables.Go_To_Working_Folder")
aButtonsList.Add("Ribbon_Executables.Total_Weight")
aButtonsList.Add("Ribbon_Executables.Creat_Part_Drawing")
aButtonsList.Add("Ribbon_Executables.Excel_BOM_Export")
Else If oType = "Part" Then
aButtonsList.Add("Ribbon_Executables.Open_All_Drawings")
aButtonsList.Add("Ribbon_Executables.Go_To_Working_Folder")
aButtonsList.Add("Ribbon_Executables.Density")
aButtonsList.Add("Ribbon_Executables.Creat_Part_Drawing")
aButtonsList.Add("Ribbon_Executables.Copy_Design")
aButtonsList.Add("Ribbon_Executables.Copy_Design")
End If
Dim aMacroDef As MacroControlDefinition
For Each oItem In aButtonsList
aMacroDef = oControlDefs.AddMacroControlDefinition(oItem) '<----- tells inventor that these buttons will execute a command in VBA
oPanel.CommandControls.AddMacro(aMacroDef, False)
Next
Dim oRevisionPanel As RibbonPanel
sRevisionPanelName = "Revision Block"
oRevisionPanel= oTab.RibbonPanels.Add(sRevisionPanelName, orevName & oType, orevName & oType) '<----- creates second panel on ribbon tab
Dim bButtonsList As New ArrayList
If oType = "Drawing" Then '<----- this section creates the clickable buttons
bButtonsList.Add("Ribbon_Executables.Issued_For_Construction")
bButtonsList.Add("Ribbon_Executables.Add_Revision_Row")
bButtonsList.Add("Ribbon_Executables.Hide_Revision_Row")
bButtonsList.Add("Ribbon_Executables.Clear_Revisions_Batch")
bButtonsList.Add("Ribbon_Executables.Clear_Revisions_Single")
End If
Dim bMacroDef As MacroControlDefinition
For Each oItem In bButtonsList
bMacroDef = oControlDefs.AddMacroControlDefinition(oItem) '<----- tells inventor that these buttons will execute a command in VBA
oRevisionPanel.CommandControls.AddMacro(bMacroDef, False)
Next
'Dim oPDFPanel As RibbonPanel
'sPDFPanelName = "PDF Block"
'oPDFPanel= oTab.RibbonPanels.Add(sPDFPanelName, oPDFName & oType, oPDFName & oType) '<----- creates second panel on ribbon tab
'Dim cButtonsList As New ArrayList
'If oType = "Drawing" Then '<----- this section creates the clickable buttons
' cButtonsList.Add("Ribbon_Executables.Batch_Print_to_PDF")
' cButtonsList.Add("Ribbon_Executables.Single_Print_to_PDF")
'End If
'Dim cMacroDef As MacroControlDefinition
'For Each oItem In cButtonsList
'cMacroDef = oControlDefs.AddMacroControlDefinition(oItem) '<----- tells inventor that these buttons will execute a command in VBA
' oPDFPanel.CommandControls.AddMacro(cMacroDef, False)
'Next
panels on the same tab but for some reason I can only create 2 panels. the moment I add the third panel the code errors out. does anyone know anything about this?