- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @checkcheck_master. Just a quick note about the code you posted. It is trying to use Apprentice, which is used for light weight standalone application type access to Inventor stuff (mostly read-only type stuff), without having to use the Inventor Application itself. It can not be used within iLogic rules, VBA macros, or Inventor Add-ins, just in standalone applications...at least that is my understanding. Here are a couple of links about it (Link1, Link2).
Converting those pesky Inventor.IPictureDisp type images to a more useful format, or trying to use them for something else directly, has been a big pain for a lot of people for a long time. Many wish that they would change this to a different, more user friendly format. Probably one of the only bits of code I think I ever got to work fairly well for converting them into something else more useful was a VBA macro I used to use to help me create new button images, based on existing ones, with slight changes. This macro finds a command in Inventor that has a button in the ribbon for it, then extracts the large and small icons for it, which are Inventor.IPictureDisp format, then uses VBA's version of the 'stdole' (not the same .dll used by vb.net) reference to save them out as BMP files. The reference used by VBA is called "OLE Automation" and the file location is "C:\Windows\System32\stdole2.tlb" file, on my Windows 10 computer. When that reference is turned on, I then have access to 'StdFunctions.SavePicture()' and 'StdFunctions.LoadPicture()' methods.
I don't think I was ever able to do anything like this within an iLogic rule yet though. It won't just convert over, because it won't use that type of reference file. It has to be a .dll file. And the stdole.dll file that iLogic has access to does not provide these same tools.
Here is the fairly simple VBA macro code:
Sub Get_CMD_Icon_As_BMP()
Dim oDef As ButtonDefinition
Set oDef = ThisApplication.CommandManager.ControlDefinitions.Item("PartExtrudeCmd")
Dim oLargeIcon As IPictureDisp
Set oLargeIcon = oDef.LargeIcon
Dim oStandardIcon As IPictureDisp
Set oStandardIcon = oDef.StandardIcon
StdFunctions.SavePicture oLargeIcon, "C:\Temp\PartExtrudeCmd_LargeIcon.bmp"
StdFunctions.SavePicture oStandardIcon, "C:\Temp\PartExtrudeCmd_StandardIcon.bmp"
End Sub
And here is a screen shot image of the References dialog and Object Browser items, and the code, for added clarity. The References dialog is right under the Tools tab in the VBA Editor.
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS)
.
If you want and have time, I would appreciate your Vote(s) for My IDEAS :bulb: or you can Explore My CONTRIBUTIONS
Wesley Crihfield
(Not an Autodesk Employee)