Introduction to Inventor.IPictureDisp Interface in Inventor 2026 API

The Inventor.IPictureDisp interface is a COM-based image representation used in the Inventor 2026 API for assigning images to user interface elements. It plays an important role in the development of Inventor add-ins, particularly when creating custom commands and ribbon controls that require button icons.

When defining custom commands in Inventor add-ins, developers typically create buttons using the ButtonDefinition object. The SmallIcon and LargeIcon parameters of a ButtonDefinition must be supplied as Inventor.IPictureDisp objects. Standard .NET image types such as System.Drawing.Image or Bitmap cannot be used directly and must first be converted into the IPictureDisp format before being passed to the Inventor API.

The Inventor.IPictureDisp interface serves as a bridge between managed .NET images and the COM-based Inventor API, ensuring that images are correctly interpreted and displayed within the Inventor user interface.

In Inventor 2026, Inventor.IPictureDisp remains the standard and recommended mechanism for assigning images to UI elements, including:

  • ButtonDefinition icons (SmallIcon and LargeIcon)
  • Ribbon buttons
  • Custom command controls

Providing images in the correct IPictureDisp format is essential for reliable add-in behavior. Incorrect image conversion or incompatible interop usage may lead to missing icons or add-in loading failures.

Note: The Inventor.IPictureDisp interface is specifically intended for assigning images to user interface elements, such as ButtonDefinition icons and other custom command controls. It is not suitable for retrieving document thumbnails. The Document.Thumbnail property returns a thumbnail object that must be processed using an appropriate method and should not be directly treated or cast as an stdole.IPictureDisp object.


Safe Image Conversion Using IPictureDisp

To reliably load images in Inventor 2026 and later, icons should be converted to Inventor.IPictureDisp using a safe helper method that leverages a hidden AxHost wrapper. This approach ensures compatibility with .NET 8–based Inventor add-ins and avoids add-in loading failures caused by improper image conversion.

Below is the recommended utility method for converting images to IPictureDisp.

Utility Class: Image → IPictureDisp Conversion


using stdole;
using System.Drawing;
using System.Windows.Forms;

public static class ImageConverterUtil
{
    public static IPictureDisp ConvertImageToPictureDisp(Image image)
    {
        return (IPictureDisp)AxHostWrapper.GetIPictureDispFromPicture(image);
    }

    private class AxHostWrapper : AxHost
    {
        private AxHostWrapper() : base("") { }

        public static object GetIPictureDispFromPicture(Image image)
        {
            return GetIPictureDispFromPicture(image);
        }
    }
}

Usage Example — Creating a ButtonDefinition

The following example demonstrates how to use the conversion utility when creating a ButtonDefinition with custom icons:


var icon = Properties.Resources.MyCustomIcon; // .png or .ico

var largeIcon = ImageConverterUtil.ConvertImageToPictureDisp(icon);
var smallIcon = ImageConverterUtil.ConvertImageToPictureDisp(icon);

_buttonDef = invApp.CommandManager.ControlDefinitions.AddButtonDefinition(
    "MyDrawingDocButton",
    "MyCompany.DrawingDocButton",
    CommandTypesEnum.kShapeEditCmdType,
    "{YOUR-GUID-HERE}",
    "Button tooltip text",
    "Button description",
    smallIcon,
    largeIcon,
    ButtonDisplayEnum.kAlwaysDisplayText
);

Benefits of Using the Recommended Conversion Method

✔ Icons load correctly in Inventor
✔ Add-ins load reliably during startup
✔ Compatible with Inventor 2026 and .NET 8
✔ Suitable for future Inventor releases

By using the recommended IPictureDisp conversion approach, developers can ensure stable add-in behavior and consistent icon rendering in Inventor 2026 and later versions.


Comments

2 responses to “Introduction to Inventor.IPictureDisp Interface in Inventor 2026 API”

  1. MacKenzie Avatar
    MacKenzie

    Is there anything here that is not applicable in Inventor 2025?

    1. Adam Nagy Avatar
      Adam Nagy

      Don’t think so. Should be the same in Inventor 2025.

Leave a Reply to Adam NagyCancel reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading