- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
how to change custom icon to gray in browser pane when set its visibility to false?
Hi, experts,
I create some custom icon for our part in an assembly as below picture. The way I do it is referring to:
https://adndevblog.typepad.com/manufacturing/2012/08/change-the-browser-node-icon.html
I want to go a little bit further. For a regular part icon, if you right click the part and turn the "visibility" off, the icon will go gray. But for a custom icon, it always stay the same. Is there any way to make custom icon turn gray when the part visibility is false?
Limin
Inventor pro 2023 64 bit update 2.1; Windows 10 pro 64 bit version 21H2; Office 2013 32 bit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi Liminma,
I'm not completely sure, but I'm gonna need this for a tool of myself soon so I looked into it a while ago.
The NativeBrowserNodeDefinition object has three icons you can specify, the OverrideIcon, OverrideExpandedIcon, and OverrideStateIcon. There's another property 'AdditionalDisplayState'. I think you have to play with the AdditionalDisplayState and OverrideStateIcon
I had a problem with my icon getting a black background. I see yours doesn't. Does your icon have a transparent background? Does it also work in dark mode?
Free apps: Smart Leader | Part Visibility Utility | Mate Origins
Paid apps: Frame Stiffener Tool | Constrain Plane Toggle | Property Editor Pro
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Thanks Krieg!! Gonna try it out tonight! Guess its time to install 2022/23..
Free apps: Smart Leader | Part Visibility Utility | Mate Origins
Paid apps: Frame Stiffener Tool | Constrain Plane Toggle | Property Editor Pro
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
basautomationservices and krieg
I use Inventor 2019. The white area of the icon is transparent. I think it should work in dark mode.
I found another article https://adndevblog.typepad.com/manufacturing/2012/12/inventor-displaystate-property-of-browsernodede....
I anticipate the solution for changing icon with respect to adaptive or visibility or transparency hints on how to use something like:
...Set nativeObj = nodeDef.NativeObject
...occ.Adaptive
...oClientFeature.BrowserNode.BrowserNodeDefinition.OverrideIcon = ocnr
There should be solution to stitch them together
Limin
Inventor pro 2023 64 bit update 2.1; Windows 10 pro 64 bit version 21H2; Office 2013 32 bit