Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Button icon for Net7

wmgshurik
Enthusiast

Button icon for Net7

wmgshurik
Enthusiast
Enthusiast

This code works pretty well for Net Frameork 4.8:

 

Image largeImage = Image.FromFile(pathLarge);
Image smallImage = Image.FromFile(pathSmall);
IconLarge = PictureConverter.ConvertImageToIPictureDisp(largeImage);
IconSmall = PictureConverter.ConvertImageToIPictureDisp(smallImage);


PipeButtonDef = controlDefs.AddButtonDefinition(" Pipeline ", "PipeID", CommandTypesEnum.kNonShapeEditCmdType, "", "", "", IconSmall, IconLarge);

 

private class PictureConverter : System.Windows.Forms.AxHost
{
    PictureConverter() : base("") { }
    public static stdole.IPictureDisp ConvertImageToIPictureDisp(Image Image)
    {
        if (null == Image) return null;
        return (stdole.IPictureDisp)GetIPictureDispFromPicture(Image);
    }
}

 

But on Net7 platform I catch the exception in method "ConvertImageToIPictureDisp". Interface not supported.

Does anybody know alternative way to set an image to buttonDefinition?

0 Likes
Reply
240 Views
2 Replies
Replies (2)

bradeneuropeArthur
Mentor
Mentor
Change the framework to an earlier one like 3.5

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

0 Likes

wmgshurik
Enthusiast
Enthusiast

The problem could not be resolved. I had to work around the problem. One plugin(NetFramework4.8) makes icons, the other(Net7) subscribes to events. 

0 Likes