Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
JMGunnar
222 Views, 2 Replies

Add button too externales rules

Create Button for externales rules 

how too access defintions too externales rules 

 

Sub Main()
	AddPanelToToolsTab()
End Sub


Sub AddPanelToToolsTab()
    ' Get the ribbon associated with the part document
    Dim oPartRibbon As Ribbon
    oPartRibbon = ThisApplication.UserInterfaceManager.Ribbons.Item("Part")


    ' Get the "Tools" tab
    Dim oTab As RibbonTab
     oTab = oPartRibbon.RibbonTabs.Item("id_TabTools")
	
	 For Each item As RibbonPanel In oTab.RibbonPanels
		
		If item.DisplayName = "Update"
			oTab.RibbonPanels.Item(item.InternalName).Delete

		End If 
		
	 Next 
	 

    ' Create a panel named "Update", positioned after the "Measure" panel in the Tools tab.
    Dim oPanel As RibbonPanel
    oPanel = oTab.RibbonPanels.Add("Update", "ToolsTabUpdatePanel", "SampleClientId", "id_PanelP_ToolsMeasure")
	
	

    ' Get the update commands
    Dim oDef1 As ButtonDefinition
    oDef1 = ThisApplication.CommandManager.ControlDefinitions.Item("AppLocalUpdateCmd")

    Dim oDef2 As ButtonDefinition
     oDef2 = ThisApplication.CommandManager.ControlDefinitions.Item("AppUpdateMassPropertiesCmd")

    Dim oDefs As ObjectCollection
    oDefs = ThisApplication.TransientObjects.CreateObjectCollection

    oDefs.Add(oDef1)
    oDefs.Add(oDef2)

    ' Create a split button control
    Call oPanel.CommandControls.AddSplitButton(oDef1, oDefs, True)
	
	

    ' Get the rebuild command
    Dim oDef3 As ButtonDefinition
    oDef3 = ThisApplication.CommandManager.ControlDefinitions.Item("AppRebuildAllWrapperCmd")

    ' Create a button control
    Call oPanel.CommandControls.AddButton(oDef3, True)
End Sub

 

WCrihfield
in reply to: JMGunnar

Which version of Inventor are you using?  If 2024, then when iterating through the ControlDefinitions, you will see some with the name starts with "iLogic.Rule:", followed by the name of the external rule file, and file extension.  That is the name of the ControlDefinition that the button will execute when clicked.  And if adding the rule as a button using an iLogic rule, it may only stay there for the current session of Inventor, then it will be gone again.  If you want the buttons to stay, you will want to add them manually, or use an add-in which puts them in place when Inventor starts.  And I usually just get the ClientID of he iLogic ApplicationAddIn to use there, instead of "SampleClientID", when it is just for iLogic related stuff.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

JMGunnar
in reply to: WCrihfield

Thanks @WCrihfield