<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Addin Button Icon in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/addin-button-icon/m-p/14110799#M180233</link>
    <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3992253"&gt;@ravindrathorat&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can review the sample provided with the SDK that shows how to do this, update 2026 to the version you are using:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;%PUBLIC%\Documents\Autodesk\Inventor 2026\SDK\DeveloperTools\Samples\VCSharp.NET\AddIns\SimpleAddIn&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;If you don't have the 'Developer Tools' installed, you would run the 'developertools.msi' file, again, update 2026 to the version you are using:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;%PUBLIC%\Documents\Autodesk\Inventor 2026\SDK&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A common error that prevents the image from loading is forgetting to include the 'StandardIcon' or 'LargeIcon' parameter when defining the ControlDefinition.&lt;/P&gt;</description>
    <pubDate>Wed, 29 Apr 2026 16:17:24 GMT</pubDate>
    <dc:creator>TylerWarner33</dc:creator>
    <dc:date>2026-04-29T16:17:24Z</dc:date>
    <item>
      <title>Addin Button Icon</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/addin-button-icon/m-p/14108463#M180202</link>
      <description>&lt;P&gt;Hi Team&lt;/P&gt;&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/532715"&gt;@YuhanZhang&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to crate addin in C#. I have created sample addin. It works too. But I am trying to add icon for button. It not happening. Could you please provide code snippet to add button icon.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Apr 2026 07:14:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/addin-button-icon/m-p/14108463#M180202</guid>
      <dc:creator>ravindrathorat</dc:creator>
      <dc:date>2026-04-28T07:14:12Z</dc:date>
    </item>
    <item>
      <title>Re: Addin Button Icon</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/addin-button-icon/m-p/14108886#M180207</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3992253"&gt;@ravindrathorat&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;You need to convert your Icon to IPictureDisp in the two sizes 32x32 and 16x16. I don't know how you've set it up but I'm guessing you have an ico-file in your resources with these two sizes, or two different files maybe.&lt;BR /&gt;&lt;BR /&gt;I don't typically write in C# but I made an attempt to give you an example here with a converter and how to set a button up:&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;using System.Drawing;
using System.Runtime.InteropServices;
using stdole;

// Step 1: The PictureDispConverter - converts .NET icons to COM IPictureDisp
// Inventor's API is COM-based so it needs IPictureDisp, not System.Drawing.Icon
public sealed class PictureDispConverter
{
    // P/Invoke to OleAut32.dll - this is the Win32 COM function that creates IPictureDisp
    [DllImport("OleAut32.dll", EntryPoint = "OleCreatePictureIndirect", 
               ExactSpelling = true, PreserveSig = false)]
    private static extern IPictureDisp OleCreatePictureIndirect(
        [MarshalAs(UnmanagedType.AsAny)] object picdesc,
        ref Guid iid,
        [MarshalAs(UnmanagedType.Bool)] bool fOwn);

    private static Guid iPictureDispGuid = typeof(IPictureDisp).GUID;

    // PICTDESC structs describe the picture to COM
    private static class PICTDESC
    {
        public const short PICTYPE_ICON = 3;

        [StructLayout(LayoutKind.Sequential)]
        public class Icon
        {
            internal int cbSizeOfStruct = Marshal.SizeOf(typeof(Icon));
            internal int picType = PICTYPE_ICON;
            internal IntPtr hicon = IntPtr.Zero;
            internal int unused1;
            internal int unused2;

            public Icon(System.Drawing.Icon icon)
            {
                // Convert the .NET icon to a Win32 HICON handle
                this.hicon = icon.ToBitmap().GetHicon();
            }
        }
    }

    public static IPictureDisp ToIPictureDisp(System.Drawing.Icon icon)
    {
        var pictIcon = new PICTDESC.Icon(icon);
        return OleCreatePictureIndirect(pictIcon, ref iPictureDispGuid, true);
    }
}

// Step 2: In your Activate method - load the icon and create the button
public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime)
{
    var app = addInSiteObject.Application;

    // Load icon at two sizes - Inventor expects both large (32x32) and small (16x16)
    var largeIcon = new Icon(Properties.Resources.AppIcon, 32, 32);
    var smallIcon = new Icon(Properties.Resources.AppIcon, 16, 16);

    // Convert to COM IPictureDisp that Inventor understands
    IPictureDisp largePicture = PictureDispConverter.ToIPictureDisp(largeIcon);
    IPictureDisp smallPicture = PictureDispConverter.ToIPictureDisp(smallIcon);

    // Create the button definition with both icons
    var controlDefs = app.CommandManager.ControlDefinitions;
    var button = controlDefs.AddButtonDefinition(
        "My Button",                          // Display name
        "cmd_my_button",                      // Internal ID - must be unique
        CommandTypesEnum.kShapeEditCmdType,   // Command type
        "{your-addin-client-id}",             // Your addin's GUID
        "Tooltip text",                       // Short tooltip
        "Longer description tooltip",         // Long tooltip
        smallPicture,                         // 16x16 icon
        largePicture,                         // 32x32 icon
        ButtonDisplayEnum.kDisplayTextInLearningMode
    );

    if (firstTime)
        AddToUserInterface(button);
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;If you don't get it to work - feel free to share more information about your project structure etc. Maybe even share your entire solution. Then I'm sure we'll figure it out&lt;/P&gt;</description>
      <pubDate>Tue, 28 Apr 2026 12:45:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/addin-button-icon/m-p/14108886#M180207</guid>
      <dc:creator>JhoelForshav</dc:creator>
      <dc:date>2026-04-28T12:45:33Z</dc:date>
    </item>
    <item>
      <title>Re: Addin Button Icon</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/addin-button-icon/m-p/14110799#M180233</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3992253"&gt;@ravindrathorat&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can review the sample provided with the SDK that shows how to do this, update 2026 to the version you are using:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;%PUBLIC%\Documents\Autodesk\Inventor 2026\SDK\DeveloperTools\Samples\VCSharp.NET\AddIns\SimpleAddIn&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;If you don't have the 'Developer Tools' installed, you would run the 'developertools.msi' file, again, update 2026 to the version you are using:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;%PUBLIC%\Documents\Autodesk\Inventor 2026\SDK&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A common error that prevents the image from loading is forgetting to include the 'StandardIcon' or 'LargeIcon' parameter when defining the ControlDefinition.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Apr 2026 16:17:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/addin-button-icon/m-p/14110799#M180233</guid>
      <dc:creator>TylerWarner33</dc:creator>
      <dc:date>2026-04-29T16:17:24Z</dc:date>
    </item>
  </channel>
</rss>

