Announcements
Due to scheduled maintenance, the Autodesk Community will be inaccessible from 10:00PM PDT on Oct 16th for approximately 1 hour. We appreciate your patience during this time.
Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Stacked Ribbon item text does not display

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
longt61
1005 Views, 5 Replies

Stacked Ribbon item text does not display

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:

ribbon.png

How can I display text for all 3 stacked items? Thank you very much.

5 REPLIES 5
Message 2 of 6
TripleM-Dev.net
in reply to: longt61

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

Message 3 of 6
longt61
in reply to: TripleM-Dev.net

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.

Message 4 of 6
TripleM-Dev.net
in reply to: longt61

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:

 

Ribbon panel large / smallRibbon panel large / small

- Michel

Message 5 of 6
Michel_Alofs
in reply to: longt61

Hi, nope I was wrong code should work.

See result below, used you're code structure:

 

Ribbon MyPanelRibbon MyPanel

- Michel

ps. why is there whitespace rond the text in you're image?

Message 6 of 6
longt61
in reply to: Michel_Alofs

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.

Post to forums  

Rail Community


Autodesk Design & Make Report