Hello,
I have a question, i just created a new custom Ribbon where i want to add new panels. I thought let's start with a simple one that contains two buttons. Everything is working, except that is loads the image for the button. What is going wrong? and is this the best method when you want to add more panels to it later?
Thanks!
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Reflection; using Autodesk.Revit.DB; using Autodesk.Revit.UI; using System.Windows.Media.Imaging; namespace BloxzRibbon { class App : IExternalApplication { // define a method that will create our tab and button static void AddRibbonPanel(UIControlledApplication application) { // Create a custom ribbon tab String tabName = "Bloxz"; application.CreateRibbonTab(tabName); // Add a new ribbon panel RibbonPanel ribbonPanel = application.CreateRibbonPanel(tabName, "Select"); // Get dll assembly path string thisAssemblyPath = Assembly.GetExecutingAssembly().Location; // Button maken voor de externe tool shift alt A voor inladen PushButtonData button1 = new PushButtonData( "cmdSetparameter", "Set" + System.Environment.NewLine + " parameter ", thisAssemblyPath, "Elementselecteren.Setparameter"); // Set ToolTip and contextual help button1.ToolTip = "Select something"; // Set the large image shown on button button1.LargeImage = new BitmapImage(new Uri("pack://application:,,,/BloxzRibbon;component/Resources/Bloxz.png")); // Button maken voor de externe tool shift alt A voor inladen PushButtonData button2 = new PushButtonData( "cmdSelectelement", "Select" + System.Environment.NewLine + " element ", thisAssemblyPath, "Elementselecteren.Selectelement"); // Set ToolTip and contextual help button2.ToolTip = "Select something"; // Add the buttons to the panel List<RibbonItem> projectButtons = new List<RibbonItem>(); projectButtons.AddRange(ribbonPanel.AddStackedItems(button1, button2)); } public Result OnShutdown(UIControlledApplication application) { // do nothing return Result.Succeeded; } public Result OnStartup(UIControlledApplication application) { // call our method that will load up our toolbar AddRibbonPanel(application); return Result.Succeeded; } } }
Solved! Go to Solution.
Solved by MvL_WAG. Go to Solution.
Most likely, the problem lies in the resolution of your image, Revit only accept 32x32 pixel image for large icon and 16x16 for smaller one, you need to resize your image. Here is a nice tutorial to show how to create custom ribbon: http://archi-lab.net/create-your-own-tab-and-buttons-in-revit/
Good luck
Hi,
Thanks for the quick response!
I followed the same tutorial, so i already used 32x32 icons.
So that is strange. I will try again to make a new icon to see if something went wrong.
Hello,
Are you sure the image is found in the location you saved it?
In our ribbon application I use the code below:
// ExternalCommands assembly path static string AddInPath = typeof(RibbonWAG).Assembly.Location; static string Hulp = Path.GetDirectoryName(AddInPath); // Command folder static string Command = Path.Combine(Hulp, "Command"); // Hulpfiles Ribbon (Plaatjes/overige) static string ImagesLarge = Path.Combine(Hulp, "Hulp_Files_Ribbon\\Large"); static string ImagesSmall = Path.Combine(Hulp, "Hulp_Files_Ribbon\\Small");
// Wagemaker tools paneel toevoegen
string WAG_Toolsstring = "WAG_Tools";
RibbonPanel WAG_Tools = application.CreateRibbonPanel(tabName, WAG_Toolsstring); // Knop Subcategories PushButtonData WAG_CreateSubCategoriesdata = new PushButtonData("Toevoegen Subcategories", "Toevoegen Subcategories", Path.Combine(Command, "WAG_Create_SubCategories.dll"), "Wagemaker.Revit.Command"); WAG_CreateSubCategoriesdata.AvailabilityClassName = "Wagemaker.Revit.FamilyDocument"; WAG_CreateSubCategoriesdata.Image = new BitmapImage(new Uri(Path.Combine(ImagesSmall, "WAG_Icon.png"), UriKind.Absolute)); WAG_CreateSubCategoriesdata.LargeImage = new BitmapImage(new Uri(Path.Combine(ImagesLarge, "WAG_Icon.png"), UriKind.Absolute)); RibbonItem WAG_CreateSubCategoriesbtn = WAG_Tools.AddItem(WAG_CreateSubCategoriesdata);
I use the assemblies location to determine where it is located on the server.
Relative to that location I have a folder called Commands --> Location of different .dll libraries for every command I use in the ribbon.
Also a folder called Hulp_files_Ribbon --> Location for files needed by the ribbon.
In that folder I have a folder called Large and Small.
Inside that folder I save my png files for the images. See below:
for me a setup like this works fine.
It is all on a network drive so if I update the content of the folder, all our revit users get the updated version of our ribbon.
I hope this helps!
Greetings Maarten
Wagemaker NL
Thanks/ Bedankt,
Your option is also working. Yesterday i rebuild my code again with the help of this information found on this site:
With some little changes i've got everything working with the icons.
Can't find what you're looking for? Ask the community or share your knowledge.