adding panels to custom created ribbon tab help

adding panels to custom created ribbon tab help

bsnyderACLUW
Enthusiast Enthusiast
1,912 Views
6 Replies
Message 1 of 7

adding panels to custom created ribbon tab help

bsnyderACLUW
Enthusiast
Enthusiast

Hi everyone,

 

I have created some code (with the help of others on this forum) that creates a tab on the ribbon (inventor).

So far it works great, I can execute my external rules from my created ribbon tab. 

 

Although this works well, I want to organize it a bit better. i want to split some of the actions listed under drawings into separate panels within the created tab. I cant find any information on this.

 

The code is posted below:

 

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

oName = "Silent-Aire_"

Try
oRibbon.RibbonTabs.Item(oName & oType).Delete
Catch
End Try

Dim oTab As Inventor.RibbonTab
oTab = oRibbon.RibbonTabs.Add(oName & oType, oName & oType, “Silent-Aire”)
oTab.Active = True

Dim oPanel As RibbonPanel
sPanelName = oName & " Tools"
oPanel = oTab.RibbonPanels.Add(sPanelName, oName & oType, oName & oType)

Dim oControlDefs As ControlDefinitions
oControlDefs = ThisApplication.CommandManager.ControlDefinitions

Dim oButtonsList As New ArrayList

If oType = "Drawing" Then	
	
	'first panel (to be made)
	oButtonsList.Add("Ribbon_Executables.Reuse_Drawing")
	oButtonsList.Add("Ribbon_Executables.Center_Dimensions")
	oButtonsList.Add("Ribbon_Executables.Missing_Balloons")
	oButtonsList.Add("Ribbon_Executables.Sort_and_Hide_Partlist")
	
	'second panel (to be made)
	oButtonsList.Add("Ribbon_Executables.Issued_For_Construction")
	oButtonsList.Add("Ribbon_Executables.Add_Revision_Row")
	oButtonsList.Add("Ribbon_Executables.Hide_Revision_Row")
	oButtonsList.Add("Ribbon_Executables.Clear_Revisions_Batch")
	oButtonsList.Add("Ribbon_Executables.Clear_Revisions_Single")
	
	'third panel (to be made)
	oButtonsList.Add("Ribbon_Executables.Batch_Print_to_PDF")
	oButtonsList.Add("Ribbon_Executables.Single_Print_to_PDF")
	oButtonsList.Add("Ribbon_Executables.EDM_Printer_1")
	oButtonsList.Add("Ribbon_Executables.EDM_Printer_2")
	oButtonsList.Add("Ribbon_Executables.EDM_Printer_Crowsnest")
	oButtonsList.Add("Ribbon_Executables.PHX_Printer_Samsungx7600GX")
	oButtonsList.Add("Ribbon_Executables.PHX_Printer_Cannon_iR_ADV_C7260")
	
	
	
Else If oType = "Assembly" Then
	oButtonsList.Add("Ribbon_Executables.Open_All_Drawings")
	oButtonsList.Add("Ribbon_Executables.Go_To_Working_Folder")	
	oButtonsList.Add("Ribbon_Executables.Total_Weight")
	oButtonsList.Add("Ribbon_Executables.Creat_Part_Drawing")
	oButtonsList.Add("Ribbon_Executables.Excel_BOM_Export")
		
Else If oType = "Part" Then
	oButtonsList.Add("Ribbon_Executables.Open_All_Drawings")
	oButtonsList.Add("Ribbon_Executables.Go_To_Working_Folder")	
	oButtonsList.Add("Ribbon_Executables.Density")
	oButtonsList.Add("Ribbon_Executables.Creat_Part_Drawing")
	oButtonsList.Add("Ribbon_Executables.Copy_Design")
	
End If
	
Dim oMacroDef As MacroControlDefinition 
For Each oItem In oButtonsList
oMacroDef = oControlDefs.AddMacroControlDefinition(oItem)	
	oPanel.CommandControls.AddMacro(oMacroDef, False)	
Next



these are the splits i want to make:

	'first panel (to be made)
	oButtonsList.Add("Ribbon_Executables.Reuse_Drawing")
	oButtonsList.Add("Ribbon_Executables.Center_Dimensions")
	oButtonsList.Add("Ribbon_Executables.Missing_Balloons")
	oButtonsList.Add("Ribbon_Executables.Sort_and_Hide_Partlist")
	
	'second panel (to be made)
	oButtonsList.Add("Ribbon_Executables.Issued_For_Construction")
	oButtonsList.Add("Ribbon_Executables.Add_Revision_Row")
	oButtonsList.Add("Ribbon_Executables.Hide_Revision_Row")
	oButtonsList.Add("Ribbon_Executables.Clear_Revisions_Batch")
	oButtonsList.Add("Ribbon_Executables.Clear_Revisions_Single")
	
	'third panel (to be made)
	oButtonsList.Add("Ribbon_Executables.Batch_Print_to_PDF")
	oButtonsList.Add("Ribbon_Executables.Single_Print_to_PDF")
	oButtonsList.Add("Ribbon_Executables.EDM_Printer_1")
	oButtonsList.Add("Ribbon_Executables.EDM_Printer_2")
	oButtonsList.Add("Ribbon_Executables.EDM_Printer_Crowsnest")
	oButtonsList.Add("Ribbon_Executables.PHX_Printer_Samsungx7600GX")
	oButtonsList.Add("Ribbon_Executables.PHX_Printer_Cannon_iR_ADV_C7260")

Thanks everyone,

0 Likes
Accepted solutions (2)
1,913 Views
6 Replies
Replies (6)
Message 2 of 7

bradeneuropeArthur
Mentor
Mentor
Accepted solution
Dim oFirstPanel As RibbonPanel
sFirstPanelName = oFirstName & " FirstPanelName"
oFirstPanel = oTab.RibbonPanels.Add(sFirstPanelName, oFirstName & oType, oFirstName & oType)

Dim oSecondPanel As RibbonPanel
sSecondPanelName = oSecondName & " SecondPanelName"
oSecondPanel = oTab.RibbonPanels.Add(sSecondPanelName, oSecondName & oType, oSecondName & oType)

And so on....

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 7

bsnyderACLUW
Enthusiast
Enthusiast

Thank you so much for your reply

 

I have been fiddling with what you wrote in your post but I'm getting unspecified errors.

I'm assuming that the code you posted would just repeat where the original section was for how many panels I want but, how do I place specific buttons on specific panels? and is there anything else I should address later in the code?

 

Thank you,

 

0 Likes
Message 4 of 7

bsnyderACLUW
Enthusiast
Enthusiast

ok, so this is where I am at:

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 panel on ribbon tab
Dim oButtonsList As New ArrayList
If oType = "Drawing" Then	'<----- this section creates the clickable buttons
	'first panel (to be made)
	oButtonsList.Add("Ribbon_Executables.Reuse_Drawing")                        '<-----(VBA code name.button name)
	oButtonsList.Add("Ribbon_Executables.Center_Dimensions")
	oButtonsList.Add("Ribbon_Executables.Missing_Balloons")
	oButtonsList.Add("Ribbon_Executables.Sort_and_Hide_Partlist")	
Else If oType = "Assembly" Then
	oButtonsList.Add("Ribbon_Executables.Open_All_Drawings")
	oButtonsList.Add("Ribbon_Executables.Go_To_Working_Folder")	
	oButtonsList.Add("Ribbon_Executables.Total_Weight")
	oButtonsList.Add("Ribbon_Executables.Creat_Part_Drawing")
	oButtonsList.Add("Ribbon_Executables.Excel_BOM_Export")	
Else If oType = "Part" Then
	oButtonsList.Add("Ribbon_Executables.Open_All_Drawings")
	oButtonsList.Add("Ribbon_Executables.Go_To_Working_Folder")	
	oButtonsList.Add("Ribbon_Executables.Density")
	oButtonsList.Add("Ribbon_Executables.Creat_Part_Drawing")
	oButtonsList.Add("Ribbon_Executables.Copy_Design")
	oButtonsList.Add("Ribbon_Executables.Copy_Design")
End If
	

Dim oRevisionPanel As RibbonPanel
sRevisionPanelName = "Revision Block"
oRevisionPanel= oTab.RibbonPanels.Add(sRevisionPanelName, oRevisionName & oType, oRevisionName & oType)        '<----- creates panel on ribbon tab
Dim aButtonsList As New ArrayList
If oType = "Drawing" Then	                                                             '<----- this section creates the clickable buttons
	aButtonsList.Add("Ribbon_Executables.Issued_For_Construction")
	aButtonsList.Add("Ribbon_Executables.Add_Revision_Row")
	aButtonsList.Add("Ribbon_Executables.Hide_Revision_Row")
	aButtonsList.Add("Ribbon_Executables.Clear_Revisions_Batch")
	aButtonsList.Add("Ribbon_Executables.Clear_Revisions_Single")
End If
	
	
Dim oPDFPanel As RibbonPanel
sPDFPanelName = "PDF Block"
oPDFPanel= oTab.RibbonPanels.Add(sPDFPanelName, oPDFName & oType, oPDFName & oType)        '<----- creates panel on ribbon tab
Dim bButtonsList As New ArrayList
If oType = "Drawing" Then	                                                                    '<----- this section creates the clickable buttons
	bButtonsList.Add("Ribbon_Executables.Batch_Print_to_PDF")
	bButtonsList.Add("Ribbon_Executables.Single_Print_to_PDF")
End If
Dim oMacroDef As MacroControlDefinition                                        
For Each oItem In oButtonsList
oMacroDef = oControlDefs.AddMacroControlDefinition(oItem)	                   '<----- tells inventor that these buttons will execute a command in VBA
	oPanel.CommandControls.AddMacro(oMacroDef, False)	
Next
Dim oMacroDef2 As MacroControlDefinition      
For Each oItem In aButtonsList
oMacroDef2 = oControlDefs.AddMacroControlDefinition(oItem)	                   '<----- tells inventor that these buttons will execute a command in VBA
	oRevisionPanel.CommandControls.AddMacro(oMacroDef2, False)	
Next
Dim oMacroDef3 As MacroControlDefinition      
For Each oItem In aButtonsList
oMacroDef3 = oControlDefs.AddMacroControlDefinition(oItem)	                   '<----- tells inventor that these buttons will execute a command in VBA
	oPDFPanel.CommandControls.AddMacro(oMacroDef3, False)	
Next

I can get the oPanel and oRevisionPanel to show up but when I add the oPDFPanel it errors out.

am I missing something?

probably something stupid im not seeing 

0 Likes
Message 5 of 7

bsnyderACLUW
Enthusiast
Enthusiast
Accepted solution

for other peoples reference, I have finished the program to include separated sections in the custom ribbon tool bar.  


 

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

oName = "Company Name "

Try
oRibbon.RibbonTabs.Item(oName & oType).Delete
Catch
End Try

Dim oControlDefs As ControlDefinitions
oControlDefs = ThisApplication.CommandManager.ControlDefinitions

If oType = "Drawing" Then
	
	Dim oTab As Inventor.RibbonTab
	oTab = oRibbon.RibbonTabs.Add(oName & oType, oName & oType, “company name”)
        'used to set the created tab as active tab
	'oTab.Active = True 
	
	Dim APanel As RibbonPanel
	APanelName = oName & " Tools"
	APanel = oTab.RibbonPanels.Add(APanelName, oName & "Tools", oName & "Tools")
	Dim AButtonsList As New ArrayList
	
	AButtonsList.Add("Ribbon_Executables.Go To Working Folder")
	AButtonsList.Add("Ribbon_Executables.Reuse Drawing")
	AButtonsList.Add("Ribbon_Executables.Vault Check In")
	AButtonsList.Add("Ribbon_Executables.Precise View")
	AButtonsList.Add("Ribbon_Executables.Center View Labels")
	AButtonsList.Add("Ribbon_Executables.Center Dimensions")
	AButtonsList.Add("Ribbon_Executables.Sort and Hide Partlist")
	AButtonsList.Add("Ribbon_Executables.Missing Balloons")
	AButtonsList.Add("Ribbon_Executables.Update Balloons")
	AButtonsList.Add("Ribbon_Executables.Drawing Notes")
	AButtonsList.Add("Ribbon_Executables.Fastener Details")
	
	Dim BPanel As RibbonPanel
	BPanelName = oName & " Revisions"
	BPanel = oTab.RibbonPanels.Add(BPanelName, oName & "Revisions", oName & "Revisions")
	Dim BButtonsList As New ArrayList
	
	BButtonsList.Add("Ribbon_Executables.Add Revision Row Batch")
	BButtonsList.Add("Ribbon_Executables.Add Revision Row Single")
	BButtonsList.Add("Ribbon_Executables.Hide Revision Rows")
	BButtonsList.Add("Ribbon_Executables.Clear Revisions Batch")
	BButtonsList.Add("Ribbon_Executables.Clear Revisions Single")
	BButtonsList.Add("Ribbon_Executables.Empty  ")
	BButtonsList.Add("Ribbon_Executables.IFC Batch")
	BButtonsList.Add("Ribbon_Executables.IFC Single")
			
	Dim CPanel As RibbonPanel
	CPanelName = oName & " Printing"
	CPanel = oTab.RibbonPanels.Add(CPanelName, oName & "Printers", oName & "Printers")
	Dim CButtonsList As New ArrayList
	
	CButtonsList.Add("Ribbon_Executables.EDM Printer 1")
	CButtonsList.Add("Ribbon_Executables.EDM Printer 2")
	CButtonsList.Add("Ribbon_Executables.EDM Printer Crowsnest")
	CButtonsList.Add("Ribbon_Executables.PHX Printer 1")
	CButtonsList.Add("Ribbon_Executables.PHX Printer 2")
	CButtonsList.Add("Ribbon_Executables.PHX Printer 3")
	CButtonsList.Add("Ribbon_Executables.Single Print to PDF")
	CButtonsList.Add("Ribbon_Executables.Batch Print to PDF")
	
	Dim oMacroDef As MacroControlDefinition 

	For Each oItem In AButtonsList
	oMacroDef = oControlDefs.AddMacroControlDefinition(oItem)	                   
		APanel.CommandControls.AddMacro(oMacroDef, False)	
	Next
 
	For Each oItem In BButtonsList
	oMacroDef = oControlDefs.AddMacroControlDefinition(oItem)	                   
		BPanel.CommandControls.AddMacro(oMacroDef, False)	
	Next

	For Each oItem In CButtonsList
	oMacroDef = oControlDefs.AddMacroControlDefinition(oItem)
		CPanel.CommandControls.AddMacro(oMacroDef, False)	
	Next
	
Else If oType = "Assembly" Then
	
	Dim oTab As Inventor.RibbonTab
	oTab = oRibbon.RibbonTabs.Add(oName & oType, oName & oType, “Silent-Aire”)
	'oTab.Active = True
	
	Dim APanel As RibbonPanel
	APanelName = oName & " Tools"
	APanel = oTab.RibbonPanels.Add(APanelName, oName & "Tools", oName & "Tools")
	Dim AButtonsList As New ArrayList
	
	AButtonsList.Add("Ribbon_Executables.Remove Mass Prompt Assy")
	AButtonsList.Add("Ribbon_Executables.Go To Working Folder")	
	AButtonsList.Add("Ribbon_Executables.Open All Drawings")
	AButtonsList.Add("Ribbon_Executables.Batch Print All Drawings")
	AButtonsList.Add("Ribbon_Executables.Total Weight")
	AButtonsList.Add("Ribbon_Executables.Excel BOM Export")
	AButtonsList.Add("Ribbon_Executables.Set Designer Properties")
	AButtonsList.Add("Ribbon_Executables.Lazy Eye")
	
	Dim oMacroDef As MacroControlDefinition 

	For Each oItem In AButtonsList
	oMacroDef = oControlDefs.AddMacroControlDefinition(oItem)	                 
		APanel.CommandControls.AddMacro(oMacroDef, False)	
	Next
	
Else If oType = "Part" Then
	
	Dim oTab As Inventor.RibbonTab
	oTab = oRibbon.RibbonTabs.Add(oName & oType, oName & oType, “Silent-Aire”)
	'oTab.Active = True
	
	Dim APanel As RibbonPanel
	APanelName = oName & " Tools"
	APanel = oTab.RibbonPanels.Add(APanelName, oName & "Tools", oName & "Tools")
	Dim AButtonsList As New ArrayList
	
	AButtonsList.Add("Ribbon_Executables.Remove Mass Prompt")
	AButtonsList.Add("Ribbon_Executables.Go To Working Folder")		
	AButtonsList.Add("Ribbon_Executables.Density")
	AButtonsList.Add("Ribbon_Executables.Create Part Drawing")
	AButtonsList.Add("Ribbon_Executables.Copy Design")
	AButtonsList.Add("Ribbon_Executables.Pilot Holes")
	
	Dim oMacroDef As MacroControlDefinition 

	For Each oItem In AButtonsList
	oMacroDef = oControlDefs.AddMacroControlDefinition(oItem)	                 
		APanel.CommandControls.AddMacro(oMacroDef, False)	
	Next
	
End If

​

 

0 Likes
Message 6 of 7

mgFNR8M
Contributor
Contributor

Hi.

 

Great code.

 

I've used your latest code on Inventor 2022.

 

How are you making the ribbon tabs visible automatically?

 

Does it need to be run on every file (open or new) with iTrigger?

 

 

EDIT: and how can I call iLogic rules from the new buttons?

0 Likes
Message 7 of 7

bsnyderACLUW
Enthusiast
Enthusiast

yes, i am using triggers to run the code when i open a new file

bsnyderACLUW_0-1695137222541.png

 

0 Likes