Autodesk Inventor Customization
- Start Article
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Inventor 2013 addin Icons displays too large
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I have an addin which has an icon for a button. In Inventor 2012 it displays fine. In Inventor 2013 the icon appears to be enlarged by about 4x, and only the top left corner of the icon is visible. The api clearly states that Inventor will scale the image to size.
Does anyone else have this problem?
This is the C# code I'm using to load the icon. The icon is in my resources file.
object LookupIcon = Microsoft.VisualBasic.Compatibility.VB6.Support.Ic
Edit: See attached pics.
Win7 x64 - 16gb ram
i7 3610qm
FirePro M4000
Inventor 2013
ETO 6.1
Solved! Go to Solution.
Re: Inventor 2013 addin Icons displays too large
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi,
I am not sure what the problem is, could you take a look at this post if it helps? The 6th message of the post provides another way to convert icon to iPicture.
If it is still no helpful. Please share an icon file for diagnose.
Xiaodong Liang
Developer Technical Services
Autodesk Developer Network
Re: Inventor 2013 addin Icons displays too large
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Same problem here!
We switched our addin from framework 3.5 (2012) to framework 4.0 (2013)
When using Ribbon appearance :Compact in 2013 -> all our icons are enlarged by about 4x
Our icons contains 16x16, 32x32, 48x48
of course we could change all of our icons to only 16x16 but that's not a proper solotion.
Is this problem solved yet?
regards,
Geert
Remark: Attachment DataLINK.ico renamed to DataLINK.ico.txt
Code used:
Dim objNaarDataLINKCmdPicture AsIPictureDisp = clsPictureConverter.IconToIPictureDisp(My.Resources.DataLINK)
Class clsPictureConverter:
Option Strict Off
Option Explicit On
Imports System.Runtime.InteropServices
Public ClassclsPictureConverter
Inherits System.Windows.Forms.AxHost
SubNew()
MyBase.New(Nothing)
EndSub
PublicSharedFunction ImageToIPictureDisp(ByVal image As System.Drawing.Image) As stdole.IPictureDisp
ReturnAxHost.GetIPictureDispFromPicture(image)
EndFunction
PublicSharedFunction IPictureDisptoImage(ByVal ipicturedisp As stdole.IPictureDisp) As System.Drawing.Image
ReturnAxHost.GetPictureFromIPicture(ipicturedisp)
EndFunction
'*** icon and bitmap through OLE **************************************************
PublicSharedFunction IconToIPictureDisp(ByVal icon As System.Drawing.Icon) As stdole.IPictureDisp
Dim pictIcon AsNewPICTDESC.Icon(icon)
Return OleCreatePictureIndirect(pictIcon, iPictureDispGuid, True)
EndFunction
PublicSharedFunction BitmapToIPictureDisp(ByVal bmp As System.Drawing.Bitmap) As stdole.IPictureDisp
Dim pictBmp AsNewPICTDESC.Bitmap(bmp)
Return OleCreatePictureIndirect(pictBmp, iPictureDispGuid, True)
EndFunction
'Definitions
<
DllImport("OleAut32.dll", EntryPoint:="OleCreatePictureIndirect", ExactSpelling:=True, PreserveSig:=False)> _
PrivateSharedFunction OleCreatePictureIndirect(<MarshalAs(UnmanagedType.AsAny)> _
ByVal picdesc AsObject, ByRef iid AsGuid, <MarshalAs(UnmanagedType.Bool)> ByVal fOwn AsBoolean) As stdole.IPictureDisp
EndFunction
PrivateShared iPictureDispGuid AsGuid = GetType(stdole.IPictureDisp).GUID
PrivateNotInheritableClassPICTDESC
PrivateSubNew()
EndSub
'Picture Types
PublicConst PICTYPE_UNINITIALIZED AsShort = -1
PublicConst PICTYPE_NONE AsShort = 0
PublicConst PICTYPE_BITMAP AsShort = 1
PublicConst PICTYPE_METAFILE AsShort = 2
PublicConst PICTYPE_ICON AsShort = 3
PublicConst PICTYPE_ENHMETAFILE AsShort = 4
<
StructLayout(LayoutKind.Sequential)> _
PublicClassIcon
Friend cbSizeOfStruct AsInteger = Marshal.SizeOf(GetType(PICTDESC.Icon))
Friend picType AsInteger = PICTDESC.PICTYPE_ICON
Friend hicon AsIntPtr = IntPtr.Zero
Friend unused1 AsInteger
Friend unused2 AsInteger
FriendSubNew(ByVal icon As System.Drawing.Icon)
Me.hicon = icon.ToBitmap().GetHicon()
EndSub
EndClass
<
StructLayout(LayoutKind.Sequential)> _
PublicClassBitmap
Friend cbSizeOfStruct AsInteger = Marshal.SizeOf(GetType(PICTDESC.Bitmap))
Friend picType AsInteger = PICTDESC.PICTYPE_BITMAP
Friend hbitmap AsIntPtr = IntPtr.Zero
Friend hpal AsIntPtr = IntPtr.Zero
Friend unused AsInteger
FriendSubNew(ByVal bitmap As System.Drawing.Bitmap)
Me.hbitmap = bitmap.GetHbitmap()
EndSub
EndClass
EndClass
End
Class
Re: Inventor 2013 addin Icons displays too large
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I didn't realize Autodesk had given an answer here. In short, they claimed the previous automatic scaling of pictures(which I found very convenient) was an accidental feature, and was not intended to work that way.
For icon files that contain multiple sizes, this was their recommendation:
"I think you should be able to get the correct size from a multi-size icon like this, and then convert that to IPictureDisp:http://stackoverflow.com/questions/616500/windows-
I have not tested the above method. I chose to make 2 separate icons, one small and one large for each button used in my addins. It seemed like a simpler approach to the problem.
In short, I see it as a bug, Autodesk does not.
Win7 x64 - 16gb ram
i7 3610qm
FirePro M4000
Inventor 2013
ETO 6.1
Re: Inventor 2013 addin Icons displays too large
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi,
I'm not sure why the change in behaviour appeared in this area, but it is logged in our system.
Even if it turns out to be an issue that needs fixing, you'd need a workaround in the meantime.
If your icon files contain the specific size you want then the solution should be quite easy - as pointed out in the previous reply.
E.g. in case of the SimpleAddIn VB.NET sample, you'd need to change this line:
Dim addSlotOptionIcon As Icon = New Icon(addSlotOptionImageStream)
to this:
Dim addSlotOptionIcon As Icon = New Icon(addSlotOptionImageStream, 16, 16)
It seemed to work fine when I tested it.

Adam Nagy
Developer Technical Services
Autodesk Developer Network
Re: Inventor 2013 addin Icons displays too large
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi,
First we could use 1 IPictureDisp with 1 icon with multiple formats:
Dim objNaarDataLINKCmdPicture As IPictureDisp = clsPictureConverter.IconToIPictureDisp(My.Resource
Private WithEvents mobjNaarDataLINKCmd As Inventor.ButtonDefinition
mobjNaarDataLINKCmd = objControlDefs.AddButtonDefinition("", "NaarDataLINKCmd", Inventor.CommandTypesEnum.kQueryOnlyCmdType, m_ClientID, , "Ga naar DataLINK", objNaarDataLINKCmdPicture, objNaarDataLINKCmdPicture, ButtonDisplayEnum.kNoTextWithIcon)
The workaround I use now is to define 2 IPictureDisp with 2 seperate icons: (a lot more of work!)
Dim objNaarDataLINKCmdPicture_16 AsIPictureDisp = clsPictureConverter.IconToIPictureDisp(My.Resources.DataLINK_16)
Dim objNaarDataLINKCmdPicture_32 AsIPictureDisp = clsPictureConverter.IconToIPictureDisp(My.Resources.DataLINK_32)
Private WithEvents mobjNaarDataLINKCmd As Inventor.ButtonDefinition
mobjNaarDataLINKCmd = objControlDefs.AddButtonDefinition("", "NaarDataLINKCmd", Inventor.CommandTypesEnum.kQueryOnlyCmdType, m_ClientID, , "Ga naar DataLINK", objNaarDataLINKCmdPicture_16, objNaarDataLINKCmdPicture_32, ButtonDisplayEnum.kNoTextWithIcon)
It works, but is not so smart!
Glad it is logged.
Geert

