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

iLogicMini Toolbar Combo Box List Item Icon from Browser Node

Inventor 2021, latest version:

 

I have a sample of a rule I'm making that uses a Mini Toolbar to allow the user to select component occurrences in an assembly and see them in a combo box.  I see in the API Guide that there's an option to have an icon next to each combo box item.  I'm trying to find the way to grab the icon from the browser node of the selected occurrence (icons for Part, Assembly, Weldment, Sheet Metal, etc.) and use that as the icon in the combo box.

 

When adding the combo box item, it accepts IPictureDisp as an icon input.  I think I found the API to grab the icon from the selected occurrence which results as an IPictureDisp:

ThisDoc.Document.BrowserPanes.GetNativeBrowserNodeDefinition(oEntity).Icon

 

However, when I try to use this to contain the icon in an object I get an error:

Error : Reference required to assembly 'stdole, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' containing the type 'stdole.IPictureDisp'. Add one to your project.

 

I'm not sure how to properly set up "stdole.IPictureDisp" as a reference in iLogic or if it's even possible.

 

Here's my rule sample, the area where the icon needs to be grabbed and used is in subroutine evSelectEvents_OnSelect:

 

Class ThisRule
	Dim bStop As Boolean = False
	Dim cOccs As Inventor.ComponentOccurrences
	Private WithEvents evMiniToolbar As Inventor.MiniToolbar
	Private WithEvents evInteractionEvents As Inventor.InteractionEvents
	Private WithEvents evSelectEvents As Inventor.SelectEvents
	Private WithEvents evKeyboardEvents As Inventor.KeyboardEvents
	Private WithEvents evComboBox As Inventor.MiniToolbarComboBox
	Sub Main
		oApp = ThisApplication
		oDoc = ThisDoc.Document
		If TypeOf oDoc Is AssemblyDocument And Right(oApp.UserInterfaceManager.ActiveEnvironment.DisplayName, 8) = "Assembly" Then
			cOccs = oDoc.ComponentDefinition.Occurrences
			oCommandManager = oApp.CommandManager
			evMiniToolbar = oCommandManager.CreateMiniToolbar
			evInteractionEvents = oCommandManager.CreateInteractionEvents
			evSelectEvents = evInteractionEvents.SelectEvents
			evSelectEvents.AddSelectionFilter(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter)
			evSelectEvents.WindowSelectEnabled = False
			evSelectEvents.Enabled = True
			evMiniToolbarControls = evMiniToolbar.Controls
			oView = oApp.ActiveView
			evMiniToolbar.Position = oApp.TransientGeometry.CreatePoint2d(oView.Left, oView.Top)
			evMiniToolbar.ShowOK = True
			evMiniToolbar.ShowOptionBox = False
			evMiniToolbarControls.AddLabel("MainLabel", "Select occurrences.", "Occurrences")
			evMiniToolbarControls.AddNewLine
			evMiniToolbarControls.AddLabel("Selection:", "Selection", "Select Occurrences.")
			evComboBox = evMiniToolbarControls.AddComboBox("Selection")
			evComboBox.AutoHide = False
			evMiniToolbar.Visible = True
			evInteractionEvents.Start
			Do
				oApp.UserInterfaceManager.DoEvents
			Loop Until bStop = True
			evInteractionEvents.Stop
			evMiniToolbar.Delete
		Else
			MessageBox.Show("This rule must be run in an Assembly Environment.")
		End If
	End Sub
	Sub evMiniToolbar_OnApply() Handles evMiniToolbar.OnApply
		evSelectEvents.ResetSelections
	End Sub
	Sub evMiniToolbar_OnOK() Handles evMiniToolbar.OnOK
		bStop = True
	End Sub
	Sub evMiniToolbar_OnCancel() Handles evMiniToolbar.OnCancel
		bStop = True
	End Sub
	Sub evKeyboardEvents_OnKeyPress(lKey As Long) Handles evKeyboardEvents.OnKeyPress
		If lKey = 27 Then evMiniToolbar_OnCancel
		If lKey = 10 Then evMiniToolbar_OnApply
	End Sub
	Sub evSelectEvents_OnPreSelect(ByRef PreSelectEntity As Object, ByRef DoHighlight As Boolean, ByRef MorePreSelectEntities As Inventor.ObjectCollection, ByVal SelectionDevice As Inventor.SelectionDeviceEnum, ByVal ModelPosition As Inventor.Point, ByVal ViewPosition As Inventor.Point2d, ByVal View As Inventor.View) Handles evSelectEvents.OnPreSelect
		PreSelectEntity = PreSelectEntity.OccurrencePath.Item(1)
	End Sub
	Sub evSelectEvents_OnSelect(ByVal JustSelectedEntities As Inventor.ObjectsEnumerator, ByVal SelectionDevice As Inventor.SelectionDeviceEnum, ByVal ModelPosition As Inventor.Point, ByVal ViewPosition As Inventor.Point2d, ByVal View As Inventor.View) Handles evSelectEvents.OnSelect
		oEntity = JustSelectedEntities.Item(1)
		sEntity = oEntity.Name
		evSelectEvents.AddToSelectedEntities(oEntity)
		oIcon = ThisDoc.Document.BrowserPanes.GetNativeBrowserNodeDefinition(oEntity).Icon
		evComboBox.AddItem(sEntity, "Occurrence", sEntity, True, oIcon)
	End Sub
	Sub evSelectEvents_OnUnSelect(ByVal UnSelectedEntities As Inventor.ObjectsEnumerator, ByVal SelectionDevice As Inventor.SelectionDeviceEnum, ByVal ModelPosition As Inventor.Point, ByVal ViewPosition As Inventor.Point2d, ByVal View As Inventor.View) Handles evSelectEvents.OnUnSelect
		evComboBox.RemoveItem(UnSelectedEntities.Item(1).Name)
	End Sub
	Sub evComboBox_OnItemRemove(ByVal oItem As Inventor.MiniToolbarListItem) Handles evComboBox.OnItemRemove
		evSelectEvents.RemoveFromSelectedEntities(cOccs.ItemByName(oItem.InternalName))
	End Sub
End Class

 

If this is something that's not possible in iLogic by either adding something in the Class or opening the Header and adding Imports or something else along those lines, then let me know and I'll add this to the Ideas forum.

 

Thank you for your help.