ClientResourceMap was introduced in Inventor 2022. This API allows users to set a list of client resources (like icons) for the browser pane for different themes.
Make sure the Autodesk.inventor.interop.dll reference in your add in is the latest dll. You can do this by copying from the C:\Program Files\Autodesk\Inventor 2022\Bin\Public Assemblies to the /bin/debug/ directory of your Add in
Create a NameValueMap variable and a new Icon to it.
oNameValueMap = app.TransientObjects.CreateNameValueMap();
Create a ClientResourceMaps instance and initialize it as below
clientResourceMaps = app.ClientResourceMaps;
NB: app is of type Inventor. Application
Add a new Client resource map through the ClientResourceMap instance and using the add() method
clientResourceMap = clientResourceMaps.Add(clintId, 1);
NB: ClientID is a static string variable. In this case, is the same as the class ID of the Add in. However, It can be any unique string. The next parameter is an integer that will be the ID of the added resource
Use the setBrowserIconData() method to set the browser icon information and theme. Call this method for each Theme to set the icon data for that Theme, and in each browser icon data there should be an item that has the same name but a different icon for that Theme. The first argument is the NameValueMap variable you declared in Step 2, the next is the theme name as a string. The last variable is optional and is Boolean in nature. It specifies if the icon will be used as the default for the other themes if no icon data is provided for that theme. It is null by default.
Create a clientNodeResource object and use the AddNodeResource() method to add a node resource with icon data from your clientResourceMap
oCnrs = oDoc.BrowserPanes.ClientNodeResources;
oCnr = oCnrs.AddNodeResource(clientResourceMap.ClientId, 1, "Icon");
The AddNodeResource() method takes in 3 arguments. First is the ClientID as a string. In this case, I passed the same client ID I used in creating the clientResourceMap, the second is an integer which is the ID of the resource. The third argument is the string value which is the name of the Icon you want to use from your ClientMapResource list.
Override the icon for the client feature and update the view
NativeBrowserNodeDefinition nativeNodeDef = oNode.BrowserNodeDefinition as NativeBrowserNodeDefinition;
if (nativeNodeDef != null)
nativeNodeDef.OverrideIcon = oCnr;
Before running the attached code sample make sure you change the following code to look for the .bmp image file in the right directory.
var image = Image.FromFile(@"C:\temp\clock.bmp");
oIcon = PictureDispConverter.ToIPictureDisp(image);