Star Wars Day and Add-in button image hack.

By Jaime Rosales (@afrojme)

May the 4th be with all of you, Today is one of my favorite days, As you have seen before I am a huge Star Wars fan and I cannot wait for December for the New Episode 7 movie to come out. Today during my lunch break, I ran into R2-D2 and some Jawas that had him captured in NYC #capturethedroid, after saying the magical phrase of “This is just the droid I was looking for” to the Jawas, they didn’t had any other choice than released him and I myself to scored a couple of nice Star Wars prices in celebration of #Maythe4th.

IMG_8783

Also here is a 3D model of the new little droid for the upcoming Episode VII – BB8 loaded in our A360 viewer for you to play with, trust me you will spend a couple of more minutes here just spinning this little guy around. Enjoy.

 

Also today, I got to help Drew Jarvis from Red Top Training in Canada with a little hack on how to make your plug-in icon pick up the right side of 32×32 pixels and be displayed correctly, It can get sometimes a bit annoying, I don’t know if is Visual Studio the one that has a glitch but after this hack the icon gets displayed in the right size. Here is the question.

Question: I have a button on a ribbon, which I have supplied a 32×32 image for:
http://globaletraining.ca/icon/app_32.png
using the following code:

PushButton Button01 = GeTRibbon.AddItem(new     PushButtonData("GeT", "GeT", assembly,     typeof(LoadDockableDialog).FullName)) as PushButton;  Button01.LargeImage = new BitmapImage(GeT32);        Button01.ToolTipImage = new BitmapImage(GeT32);  Button01.ToolTip = "Load the GeT Help System";       MainDockableWindow.InitiatedText.Content =     "Please Run the GeT" + Environment.NewLine +     "Command on the Revit" + Environment.NewLine +     "Add-Ins Ribbon Tab to" + Environment.NewLine +     "Initialize the Get Addin"; 

However the image is always very small, attached is an example, how does the Dynamo button image look so large and mine looks so tiny? should I be using something other than PushButton?

Answer: Thank you for your query, I have tested it and it works with the following snippet of code, also see attached proof.

 proof image

PushButton pushButton = ribbonPanel.AddItem(buttonData) as PushButton;pushButton.ToolTip = "Your ToolTip Text Here";Uri uriImage = new Uri("C:\app-32.png", UriKind.RelativeOrAbsolute);BitmapImage largeImage = new BitmapImage(uriImage);pushButton.LargeImage = largeImage;

Let me know how it goes ok.

Response: Thanks Jaime, unfortunately this doesn’t seem to work for me, it still gives me a small image, which is odd as I haven’t specified an .Image only a .LargeImage, do you think I should try another image? What is the maximum image size that can be used? Is there a best suggested format?

Answer 2:Thank you for letting me know, as per our phone conversation, You are using the correct format and size of your image in order to be displayed in your plug-in. Like I said try to debug it a couple of times with the code I provided and play a bit with the names of the icon, you can roll it back when the plug-in picks up the right size.

I know it is very strange but that is how I tried it in the past and with your image as well and it worked.

Let me know how it goes ok.

Final Response: Thanks, that worked, I pointed it at a new filename and it worked without issue.Cheers.

Another Happy developer with his case resolved.

Thanks for reading and I hope it helps some of you in the future. Until next time.


Comments

5 responses to “Star Wars Day and Add-in button image hack.”

  1. Matt mason Avatar
    Matt mason

    I feel like this is an issue that Mikako and I ran into some years ago- might even be on the blog somewhere. I feel like the issue was that you have to save the image with a nominal DPI setting that matches Revit’s expectation.

  2. For Revit, you need to supply a 96 dpi image. The app_32.png is at 300 dpi. And you need to always supply a small image because if you don’t and the user move the button to the quick access bar, it will result in a blank icon.

  3. Hi Matt,
    I remember that. Thanks for pointing out. It’s here:
    http://adndevblog.typepad.com/aec/2012/05/ribbon-images-and-resolution.html
    As Maxence rightly pointed out, it uses 96 as the default dpi.

  4. Jaime Rosales Avatar
    Jaime Rosales

    Hi Guys,
    Thank you very much for the point out, I will be updating the post with the information of the right size of the dpi.
    Cheers,

  5. I’d like to thank the author for writing such an insightful and informative blog post about buttons that is not just useful to the readers but also revealing.

Leave a Reply to Technostruct LLCCancel reply

Discover more from Autodesk Developer Blog

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

Continue reading