Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Ralf_Krieg
in reply to: liminma8458

Hello

 

Since Inventor 2022 there are some improvements I found some days ago. You can create a ClientResourceMap and add the different Icons. There is also support for different themes included.

@basautomationservices 

Sorry, found that a while after your threads. But I did not found a solution for transparancy problem somewhere in there.

 

Here's a small VBA sample demonstrating the core functionality. It assumes there are two bitmaps (16x16pixel) in C:\temp and the active theme in Inventor is the dark theme. Otherwise you need to adjust the code.

Select a part in your assembly and run the sample. This override works just for the node of the selected part. If you place another occurrence of the same part, the standard icons are displayed.

 

 

 

Sub modifyIcon()


Dim oApp As Application
Set oApp = ThisApplication

Dim oDoc As AssemblyDocument
Set oDoc = oApp.ActiveDocument

'Get the ClientResourceMap or create a new one
On Error Resume Next
Dim oClientResourceMap As ClientResourceMap
    Set oClientResourceMap = oApp.ClientResourceMaps.ItemById("MyTestResourceMap", 1)
If Err.Number <> 0 Then
    Set oClientResourceMap = oApp.ClientResourceMaps.Add("MyTestResourceMap", 1)

    Dim oIcon_1 As IPictureDisp
    Set oIcon_1 = stdole.LoadPicture("C:\temp\1.bmp")
    
    Dim oIcon_2 As IPictureDisp
    Set oIcon_2 = stdole.LoadPicture("C:\temp\1_gray.bmp")
    
    Dim oNVMap As NameValueMap
    Set oNVMap = oApp.TransientObjects.CreateNameValueMap
    
    Call oNVMap.Add("Icon1", oIcon_1)
    Call oNVMap.Add("Icon2", oIcon_2)
    
    Call oClientResourceMap.SetBrowserIconData(oNVMap, "DarkTheme", True)
End If

On Error GoTo 0

'Get the ClientNodeResource in the actvie BrowserPane or create it
Dim oBP As BrowserPane
Set oBP = oDoc.BrowserPanes.ActivePane

Dim oNode As BrowserNode
Set oNode = oBP.TopNode.BrowserNodes.Item(oBP.TopNode.BrowserNodes.count - 1)

On Error Resume Next
Dim oCNRes As ClientNodeResource
Set oCNRes = oDoc.BrowserPanes.ClientNodeResources.ItemById("MyTestResourceMap", 1)
If Err.Number <> 0 Then
    Set oCNRes = oDoc.BrowserPanes.ClientNodeResources.AddNodeResource("MyTestResourceMap", 1, "Icon1")
End If

oCNRes.InvisibleIconName = "Icon2"

'assign the ClientNodeResource as Override to the selected Browsernode
Dim oBNDef As NativeBrowserNodeDefinition
Set oBNDef = oDoc.BrowserPanes.GetNativeBrowserNodeDefinition(oDoc.SelectSet(1))

oBNDef.OverrideIcon = oCNRes

oApp.ActiveView.Update

End Sub

 

 


R. Krieg
RKW Solutions
www.rkw-solutions.com