Assign a toolbar icon to the Extension?

Thiago_Sase wrote on 4/26/2025, 6:15 AM

@jetdv Hello, Sir. Please, could you help me? How should I start to write lines of code to assign a toolbar icon, a PNG file, to my extension, just the way that shows up for scripts?

Comments

zzzzzz9125 wrote on 4/26/2025, 7:14 AM

@Thiago_Sase Just use something like:

public static void SetIconFile(CustomCommand cmd, string fileName)
{
    cmd.IconFile = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), fileName);
}

 

For example, use:

SetIconFile(cmd, "iconfilename.png");

This will read the iconfilename.png file in the same folder as the extention dll for this custom command.

Using VEGAS Pro 22 build 248 & VEGAS Pro 21 build 208.

Information about my PC:
Brand Name: HP VICTUS Laptop
System: Windows 11.0 (64-bit) 10.00.22631
CPU: 12th Gen Intel(R) Core(TM) i7-12700H
GPU: NVIDIA GeForce RTX 3050 Laptop GPU
GPU Driver: NVIDIA Studio Driver 560.70

jetdv wrote on 4/26/2025, 10:58 AM

It's set in the custom command itself. I use the "script file" location tell me where it is and put it in the same folder as the custom command.

        string scriptFile = Assembly.GetExecutingAssembly().CodeBase.Substring(8);
        myPI.IconFile = Path.GetDirectoryName(scriptFile) + Path.DirectorySeparatorChar + "MyIcon.png";

 

Thiago_Sase wrote on 4/26/2025, 1:49 PM

@zzzzzz9125 @jetdv Thank you. Both solutions worked perfect. Thank you both very much!