Addin will not load

Addin will not load

mowag
Enthusiast Enthusiast
1,384 Views
10 Replies
Message 1 of 11

Addin will not load

mowag
Enthusiast
Enthusiast

I've build the addin with the C# Autodesk Addin template.

I've set the build output path to C:\ProgramData\Autodesk\ApplicationPlugins

 

When i run my addin in Visual Studio in debug mode, everything is  fine.

Starting Inventor normally, the addin is not loaded ?

 

I've also changed the path of the addin to C:\Users\UserName\AppData\Roaming\Autodesk\Inventor2021\Addins but still no joy !!

 

Where must the addin files be placed ?

 

Addin.png

 

 

0 Likes
Accepted solutions (1)
1,385 Views
10 Replies
Replies (10)
Message 2 of 11

bradeneuropeArthur
Mentor
Mentor

Could you share the *.addin file

What version of inventor are you using?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


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:
My 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 !


 


EESignature

0 Likes
Message 3 of 11

mowag
Enthusiast
Enthusiast

Hi,

 

I'm using Inventor 2021

 

Addin.png

Kind Regards

 

Johan

0 Likes
Message 4 of 11

bradeneuropeArthur
Mentor
Mentor

Could you make a screenshot from the standard add-in module?

Or send it as file?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


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:
My 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 !


 


EESignature

0 Likes
Message 5 of 11

mowag
Enthusiast
Enthusiast

Hi,

I tried to send my whole VS solution, but the majority of files are not 'supported', even .cs files !

I can WeTransfer it if neccessary !

 

PictureDispConverter is for converting a bmp into a IPictureDisp

 

StandardAddInServer.cs

 

mowag_1-1645533755884.png

My Function1

mowag_2-1645533978517.png

 

Solution Explorer

mowag_3-1645534068520.png

 

 

 

0 Likes
Message 6 of 11

yan.gauthier
Advocate
Advocate

When I get this type of erreor, it's almost always related to the icons...

 

Sometimes its because I forgot to set my files as embeded.

 

my go to is simply to convert any images to .ico file. I either use GIMP to generate .ico file or convert to .ico with FFMPEG (Download FFMPEG, start powershell from the folder where ffmpeg.exe is and use this command .\ffmpeg -i img.png -vf scale=32:32 img.ico)

0 Likes
Message 7 of 11

mowag
Enthusiast
Enthusiast

Hi Yan,

 

You're right about the icons !

When i comment out the icon related code, it works ( addin gets loaded !)

I've made the ico's with GIMP

 

But it's still not loading ( just works fine in VS in DEBUG mode)

 

This is my code

mowag_1-1645628756582.png

 

This code comes from Philippe Leefsma (Manufacturing DevBlog)

 

mowag_0-1645628419157.png

 

0 Likes
Message 8 of 11

yan.gauthier
Advocate
Advocate

Hi, All you need to do is something like this

 

 

 

 

 

Icon sensorIcon = new Icon(new Icon(this.GetType(), "Sensor.ico"), new System.Drawing.Size(16, 16));

//Use a class based on AxHost to get the converter and use it in your button builder

//get IPictureDisp for icons
stdole.IPictureDisp standardIconIPictureDisp;
standardIconIPictureDisp = AxHostConverter.ImageToPictureDisp(sensorIcon.ToBitmap());

//Create a class that is based on AxHost

  internal class AxHostConverter : AxHost
    {
        private AxHostConverter() : base("") { }

        static public stdole.IPictureDisp ImageToPictureDisp(Image image)
        {
            return (stdole.IPictureDisp)GetIPictureDispFromPicture(image);
        }
        static public Image PictureDispToImage(stdole.IPictureDisp pictureDisp)
        {
            return GetPictureFromIPicture(pictureDisp);
        }
    }

 

 

 

 

 

 

in my case, Sensor.ico had BuildAction set to Embedded Ressource

0 Likes
Message 9 of 11

mowag
Enthusiast
Enthusiast

Yan,

 

I followed your approach this time, but still no joy !

Checked Build Action was Embedded Resource.

Now tried Size(16,16) instead of Size(32,32) (icon stays the same size in the ribbonpanel !!)

works only  in debug mode !

 

But thanks for informing me the icons were the culprit !

 

Icon icon1 = new Icon(new Icon("./Resources/BlockSelection.ico"), new System.Drawing.Size(16, 16));
IPictureDisp largeicon1 = AxHostConverter.ImageToPictureDisp(icon1.ToBitmap());

Icon icon2 = new Icon(new Icon("./Resources/Builder.ico"), new System.Drawing.Size(16, 16))
IPictureDisp largeicon2 = AxHostConverter.ImageToPictureDisp(icon2.ToBitmap());


button1 = inventor.CommandManager.ControlDefinitions.AddButtonDefinition(
                    "Client Name", "InternalClient Name",
                    CommandTypesEnum.kSchemaChangeCmdType, GUID,
                    "DescriptionText", "Sets the ClientName in the\nCompany Property",largeicon1);
            button1.OnExecute += onClickButton1;

button2 = inventor.CommandManager.ControlDefinitions.AddButtonDefinition(
                     "Builder", "InternalBuilder",
                     CommandTypesEnum.kSchemaChangeCmdType, GUID,
                     "DescriptionText", "Builder van wat ?\njah, Joost mag het\nweten",largeicon2);

 

 

0 Likes
Message 10 of 11

yan.gauthier
Advocate
Advocate
Accepted solution

Sorry, I should have mentionned. An .ico file may hold several image in it. When you call an .ico file like this, you refer to the image with that resolution. If you file holds a 32x32 image, then you should call it like that.

 

the only thing I can see is that your code knows where to find your icons when in debug mode, but does not have access to them when in release mode. I once had issues with ressources file. To fix that I simply moved my icon file in the root folder and refered to them with their file name

0 Likes
Message 11 of 11

mowag
Enthusiast
Enthusiast

Yan,

 

you were correct, didn't find the icons in release mode !!

Put them in the Properties.Resources , and all went fine !!

Thanks alot to direct me to the solution  !!!

 

mowag_0-1645781607847.png

 

 

Icon icon1 = new Icon(Properties.Resources.BlockSelection, new System.Drawing.Size(32, 32));
            IPictureDisp largeicon1 = AxHostConverter.ImageToPictureDisp(icon1.ToBitmap());

Icon icon2 = new Icon(Properties.Resources.Builder, new System.Drawing.Size(32, 32));
            IPictureDisp largeicon2 = AxHostConverter.ImageToPictureDisp(icon2.ToBitmap());