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: 

A StackButton can be a PushButton with options

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
570 Views, 3 Replies

A StackButton can be a PushButton with options

Perhaps this idea might be usable for others.

 

The StackButton ribbon control is a stack of different PushButtons where the last used PushButton remains visible to be used again. That visible button is the stack button's currentbutton property. Imagine if that StackButton control always shows the first button in the stack and the other button(s) in the StackButton are secondary to the first button's purpose.

 

Using the callback concept described in Jeremy Tammik's http://thebuildingcoder.typepad.com/blog/2012/11/roll-your-own-toggle-button.html you can have the second Pushbutton in a two button Stackbutton reset the Stackbutton's current button property back to that of the first button. Therefore this StackButton item always shows and activates the first button's action on its button face but also has a secondary option to invoke a settings manager activated by the second button.

 

Set the first button in the button stack set to your add-in command of choice. Set the second button in the button stack to show a Window Form or WPF Window to be the first button's settings manager. Have the settings communicated through the Add-in's Properties.Settings. The first button's command reads the current settings prior to acting. The second button's actions reads, sets and saves the settings the first button uses. It ends with a call back function that resets the StackButton's currentbutton to the first button in the stack. These settings would also persist between Revit sessions.

 

For example this is what a second button might invoke.

 

[Transaction(TransactionMode.Manual)]
    class SectionFarClipResetOptions : IExternalCommand {
        public Result Execute(ExternalCommandData commandData,
                              ref string message,
                              ElementSet elements) {

            FarClipSettingWPF settingWPF = new FarClipSettingWPF();
            settingWPF.ShowDialog();
            AppWTA.Instance.SetSplitButtonFarClipToTop();
            return Result.Succeeded;
        }
    }

This is what the callback function might be in a hardcoded style.

 

public void SetSplitButtonFarClipToTop() {
            IList<PushButton> sbList = sbFarClip.GetItems();
            sbFarClip.CurrentButton = sbList[0];
        }

sbFarClip is a public SplitButton in this case.

 

 

3 REPLIES 3
Message 2 of 4
jeremytammik
in reply to: Anonymous

Dear Aksaks,

 

I like your idea very much!

 

Would you like to provide a full minimal reproducible sample to demonstrate it?

 

I would love to try it out and share it in a more readable and future-proof fashion for you, e.g. on The Building Coder.

 

Thank you!

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 4
Anonymous
in reply to: jeremytammik

Yes I can provide but the easiest thing for me to do is send you the entire project folder. You would have to sort out all the other items not related, including what embarrassing junk has been left sitting around.  

Message 4 of 4
jeremytammik
in reply to: Anonymous

Sure, can do, as long as you provide me with some hints  🙂



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Customer Advisory Groups


Rail Community