I am working on the api of Revit 2019.2 and I can display the text for my stacked ribbon push button. I have looked round for a while and try the Autodesk.Windows.RibbonItem.ShowText as suggested in the following link but it does not work.
https://thebuildingcoder.typepad.com/blog/2013/02/adding-a-button-to-existing-ribbon-panel.html#2
It is quite strange that when I add 3 stacked ribbon items with out defining the Autodesk.Revit.UI.RibbonItem.ItemText property, all of the them do not show text. However, if I define the ItemText property for the first stacked item, only the text for second stacked item is displayed.
Here is my code:
string assembly = GetAssemblyDirectory ();
RibbonPanel panel = AddPanel ();
PushButtonData firstData = new PushButtonData ( "first", "first", assembly, "firstClass" );
PushButtonData secondData = new PushButtonData ( "second", "second", assembly, "secondClass" );
PushButtonData thirdData = new PushButtonData ( "third", "third", assembly, "thirdClass" );
IList<RibbonItem> reinforcementItems = panel.AddStackedItems ( firstData, secondData, thirdData );
PushButton firstButton = reinforcementItems [0] as PushButton;
firstButton.LargeImage = new BitmapImage ( firstLargeSource );
firstButton.Image = new BitmapImage ( firstSmallSource );
firstButton.ToolTip = "tool tips";
// the second text displays if I add this line
firstButton.ItemText = "first item text";
PushButton secondButton = reinforcementItems [1] as PushButton;
secondButton.LargeImage = new BitmapImage ( secondLargeSource );
secondButton.Image = new BitmapImage ( secondSmallSource );
secondButton.ToolTip = "tool tips";
// add rebar for columns
PushButton thirdButton = reinforcementItems [2] as PushButton;
thirdButton.LargeImage = new BitmapImage ( thirdLargeSource ) );
thirdButton.Image = new BitmapImage ( thirdSmallSource );
thirdButton.ToolTip = "tool tips";
Here is what is looks like:
How can I display text for all 3 stacked items? Thank you very much.
Solved! Go to Solution.
Solved by Michel_Alofs. Go to Solution.
Hi,
The buttons you're creating can't interact with the Revit Database!, as stated in Jeremy comments.
Do you want to activate a Revit (you're addin) Command or something else?
- Michel
Actually, I was creating some custom addin command, each of them will be executed when user click on the bound push button. There are 2 things that came across my mind when I try the mentioned solutions:
1. Since Revit and other addin app (Sofistik for example) can create stacked buttons with text, I believe there is a way to achieve the same thing.
2. Aside from the Revit data base interacting, it should be ok if I just want to display the text, yes? After revert back to the original solution (which I added the code) I received the strange result.
Any suggestion is much appreciated.
Hi,
I've been looking closer to the code you posted.
Only thing I do different, is i assign the LargeImage/Image/Tooltip to the PushButtonData object, and never set anything on the PushButton object.
ps. In the panel is enough space for the text? see sample below if panel doesn't have enough space:
- Michel
Hi, nope I was wrong code should work.
See result below, used you're code structure:
- Michel
ps. why is there whitespace rond the text in you're image?
I can assure you the text has enough space to display itself. That is the first thing came to my mind, and I try it with the longer panel title to give the text a more spacious space. Yet, it failed.
I find it strange that when I delete the post code and try it again with the exact step, it works.
P/s: about the white space you were wondering, I just paste some generic text on top of the actual text since I was not allowed to show the detailed information. Sorry for any confusion it might have caused.
Can't find what you're looking for? Ask the community or share your knowledge.