Image Not Loading Onto PushButtonData

Image Not Loading Onto PushButtonData

mhillis
Advocate Advocate
966 Views
1 Reply
Message 1 of 2

Image Not Loading Onto PushButtonData

mhillis
Advocate
Advocate

I am having a slight issue trying to utilize the PushButtonData.LargeImage functionality in Revit 2018.  When making UI elements for a Ribbon tab that I have created, I am attempting to load an image from an external library onto the button for my UI element; however, it does not seem to be working.  The code I am currently trying to use is as follows

PushButtonData ductPushButtonData = new PushButtonData("Duct", "Duct", ExecutingAssemblyPath,
                "MyDuctUI.Commands.Duct.DuctStartCommand");
ductPushButtonData.LargeImage = new BitmapImage(new Uri(@"pack://application:,,,/ImgResMan;component/Images/RectDuct.png"));

My first assessment of this matter was that maybe the 'LargeImage' or the 'BitmapImage' calls were not liking the fact I was using a .png.  I did switch over to a .bmp and attempt this; however, no change.  If I take the BitmapImage call and try something like..

BitmapImage bmp = new BitmapImage(new Uri(@"pack://application:,,,/ImgResMan;component/Images/RectDuct.png"));

...I can see that the `bmp` variable has a value with width, height, and data behind it.  Indicating that it is successfully creating a BitmapImage object.  The image itself is attached to this post.   This tells me, at least, that A) my Assembly is being loaded and is accessible to my Plugin and B) there is valid image data being created.  For reference, I am utilizing the System.Reflection.Assembly.LoadFrom() routine to load up my library with images/icons. 

 

Can anyone help me fathom why my image is not loading onto my UI element?  It does appear that the UI element is adjusting for an image being there, but alas, no image.  Are there any particular parameters regarding the utilization of PushButtonData.LargeImage that I may not be aware of such as size maximum, transparency limitations, etc. etc?

0 Likes
967 Views
1 Reply
Reply (1)
Message 2 of 2

Sean_Page
Collaborator
Collaborator

1. First, make sure it is no larger than 100x100 pixels. When I downloaded your image it is 200x200.

2. Since you are using PushButtonData I am assuming you then create a new PushButton with it. If that is the case, the image needs to be associated with the PushButton item, not the PushButtonData.

 

See the following example.

BitmapImage HostWallImage = new BitmapImage(new Uri("pack://application:,,,/RDGRevit;component/Resources/HostWall100x100.png"));
PushButtonData pbdDoorHost = new PushButtonData("cmdDoorHost", "Host" + Environment.NewLine + "Wall", thisAssemblyPath, "RDGRevit.Commands.HostWall");
PushButton pbDoorHost = ribbonPanelDoor.AddItem(pbdDoorHost) as PushButton;
pbDoorHost.ToolTip = "Sets the Host wall parameter of the Door based the the Wall Type hosting it for the Door Schedule";
pbDoorHost.LargeImage = HostWallImage;
Sean Page, AIA, NCARB, LEED AP
Partner, Computational Designer, Architect