Change Icon of Client Feature via API

Change Icon of Client Feature via API

Anonymous
Not applicable
662 Views
3 Replies
Message 1 of 4

Change Icon of Client Feature via API

Anonymous
Not applicable

Hi everyone,

 

I've created a Client Feature containing tons of other Features, so far so good.

 

Now, I have this Client Feature, with a Client Feature name, but only with the standard Client Feature Icon (<x> with a blue square body).

 

I want to change this icon to something more specific 🙂

 

The resources I found on the internet are not working (don't know why).

 

(https://adndevblog.typepad.com/manufacturing/2015/01/change-icon-of-clientfeature-node-in-built-in-b...)

(https://adndevblog.typepad.com/manufacturing/2012/08/change-the-browser-node-icon.html)

 

I got multiple exceptions if I try.

 

So, has someone a simple example? (Override Icon etc.)

 

This is the current status:

 

 Railing.JPG

 

Greetings to all.

0 Likes
663 Views
3 Replies
Replies (3)
Message 2 of 4

etaCAD
Advocate
Advocate

Hi,

here are some parts of my code to change the icon of the client feature. This works only as add-in.

 ' Try to find an existing resource.
                Dim oCnr As ClientNodeResource = Nothing
                Dim oCheckResource As ClientNodeResource
                For Each oCheckResource In mPartDocument.BrowserPanes.ClientNodeResources
                    If oCheckResource.ClientId = "FeatureClientID" Then
                        ' Save a reference to the existing client node resource.
                        oCnr = oCheckResource
                        Exit For
                    End If
                Next

                ' Create the resource if it doesn't already exist.
                If oCnr Is Nothing Then
                    Dim oIcon As IPictureDisp
                    oIcon = mBrowserIcons.RBfeatureBrowser  ' Das geht nur als Addin
                   ' Create a client node resource.
                    oCnr = mPartDocument.BrowserPanes.ClientNodeResources.Add("FeatureClientID", -1, oIcon)
                End If
' Get the browser node definition associated with the client feature.
Dim oNativeBrowserNodeDef As NativeBrowserNodeDefinition
oNativeBrowserNodeDef = mPartDocument.BrowserPanes.GetNativeBrowserNodeDefinition(oClientFeature)

' Override the icon for the client feature.
oNativeBrowserNodeDef.OverrideIcon = oCnr

Andreas
etaCAD

0 Likes
Message 3 of 4

chandra.shekar.g
Autodesk Support
Autodesk Support

@Anonymous ,

 

Hoping that suggestions in the below link may be helpful.

 

https://blogs.msdn.microsoft.com/andreww/2007/07/30/converting-between-ipicturedisp-and-system-drawing-image

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 4 of 4

Passi10
Enthusiast
Enthusiast

Hi Andreas,

 

first of all, thanks for your reply.

 

This line here:

 

                    oCnr = mPartDocument.BrowserPanes.ClientNodeResources.Add("FeatureClientID", -1, oIcon)

 

Creates an exception. The problem is, the exception is not very specific 🙂

What I know is: I took the correct Feature Client ID

The oIcon is only the picture data. I also got that correctly.

 

So, there are only 2 possibilities existing:

 

1. The Id Integer is not correct (-1)

2. The line is not working here because of a reason I didn't know. (Write protection of the specific Clientnoderesources?!?!

 

I have nooo idea.

 

(By the way, this line was also the reason, I didn't get the other examples working.)

 

Greetings

0 Likes