├── Images ├── B1.png ├── B2.png └── B3.png ├── LICENSE.md ├── README.md ├── rvt2023 ├── optionsbarcombined.gif └── optionsbarsingle.gif └── rvt2024 ├── optionsbardark.gif └── optionsbarlight.gif /Images/B1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpeedCAD/SCADtools.Revit.UI.OptionsBar/28386a15637cdc72039ee7d41caba183e983e37b/Images/B1.png -------------------------------------------------------------------------------- /Images/B2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpeedCAD/SCADtools.Revit.UI.OptionsBar/28386a15637cdc72039ee7d41caba183e983e37b/Images/B2.png -------------------------------------------------------------------------------- /Images/B3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpeedCAD/SCADtools.Revit.UI.OptionsBar/28386a15637cdc72039ee7d41caba183e983e37b/Images/B3.png -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License with Restrictions 2 | 3 | Copyright (c) 2023 Mauricio Jorquera Madrid 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | Restrictions: 10 | 11 | You may use this software in commercial projects, but you are not allowed to reverse engineer, decompile, or disassemble the Software. 12 | Any derivative work must also include this license and reproduce the copyright notice. 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SCADtools.Revit.UI.OptionsBar 2 | Represents a custom options bar that will be displayed in the native Revit options bar. 3 | 4 | Its main methods are: **Show()** and **Hide()**. 5 | 6 | The OptionsBar library provides a set of predefined user-friendly controls that can be added to the options bar, such as **Button**, **LabelCheckBox**, **LabelComboBoxImage**, **LabelComboBox**, **LabelTextBox**, and **Separator**. Moreover, for users seeking further customization, the library allows the incorporation of user-defined controls. With these features, you can easily integrate a custom options bar into the Revit interface, allowing the user to access different settings without needing to open often annoying dialog boxes. Additionally, this library supports the integration of the custom options bar in conjunction with the native Revit options bar. Below, you'll find some examples of how this options bar is displayed. 7 | 8 | For more information on **OptionsBar**, please read our [Wiki](https://github.com/SpeedCAD/SCADtools.Revit.UI.OptionsBar/wiki). 9 | 10 | ## OptionsBar in Revit 2023 11 | **Below is the integration of a custom options bar in combination with the native Revit options bar.** 12 | 13 | ![OptionsBarCombined](./rvt2023/optionsbarcombined.gif) 14 | 15 | **Below is the integration of a custom options bar to modify an element.** 16 | 17 | ![OptionsBarSingle](./rvt2023/optionsbarsingle.gif) 18 | 19 | ## OptionsBar in Revit 2024 20 | **Light Theme** 21 | 22 | ![OptionsBarLight](./rvt2024/optionsbarlight.gif) 23 | 24 | **Dark Theme** 25 | 26 | ![OptionsBarDark](./rvt2024/optionsbardark.gif) 27 | 28 | ## :floppy_disk: Download 29 | You can reference the DLL in a Visual Studio project the same way you load any external library. 30 | | Version | DLL File | 31 | |:-----------------------------|:----------------------------------------------------------------------------------------| 32 | | Revit 2023 | [OptionsBar for Revit 2023](https://github.com/SpeedCAD/SCADtools.Revit.UI.OptionsBar/releases/download/v1.1.1/SCADtools.Revit.UI.OptionsBar_1.1.1_rvt2023.zip) | 33 | | Revit 2024 | [OptionsBar for Revit 2024](https://github.com/SpeedCAD/SCADtools.Revit.UI.OptionsBar/releases/download/v1.1.1/SCADtools.Revit.UI.OptionsBar_1.1.1_rvt2024.zip) | 34 | 35 | ## :rocket: Making 36 | - The DLL files are made using [**Visual Studio**](https://github.com/microsoft) 2022. 37 | 38 | ## :keyboard: Code example 39 | ```c# 40 | using Autodesk.Revit.Attributes; 41 | using Autodesk.Revit.DB; 42 | using Autodesk.Revit.UI; 43 | using SCADtools.Revit.UI; 44 | using System; 45 | using System.Collections.Generic; 46 | using System.Windows; 47 | using System.Windows.Controls; 48 | using System.Windows.Media.Imaging; 49 | 50 | namespace SCADtools.OptionsBarSample 51 | { 52 | [TransactionAttribute(TransactionMode.Manual)] 53 | internal class Sample : IExternalCommand 54 | { 55 | private OptionsBar optionsBar; 56 | 57 | public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) 58 | { 59 | UIApplication uiapp = commandData.Application; 60 | UIDocument uidoc = uiapp.ActiveUIDocument; 61 | Document doc = uidoc.Document; 62 | 63 | try 64 | { 65 | //Initialize OptionsBar 66 | optionsBar = new OptionsBar(); 67 | 68 | DisplayOptionsBar(); 69 | 70 | //Some instructions to execute in Revit 71 | IList pickElementsByRectangle = uidoc.Selection.PickElementsByRectangle("Select elements."); 72 | 73 | //Optionally, you can disable the options bar while Revit is working 74 | optionsBar.IsEnabled = false; 75 | 76 | using (Transaction tr = new Transaction(doc, "Transaction name")) 77 | { 78 | tr.Start(); 79 | 80 | foreach (Element element in pickElementsByRectangle) 81 | { 82 | //TODO: Your code logic here 83 | } 84 | 85 | tr.Commit(); 86 | } 87 | 88 | return Result.Succeeded; 89 | } 90 | catch (Exception ex) 91 | { 92 | message = ex.Message; 93 | return Result.Failed; 94 | } 95 | finally 96 | { 97 | //Hide the OptionsBar (IMPORTANT) 98 | optionsBar.Hide(); 99 | } 100 | } 101 | 102 | private void DisplayOptionsBar() 103 | { 104 | //Initialize a TextBlock to display information at the start of the OptionsBar 105 | TextBlock textBlock = new TextBlock() 106 | { 107 | Text = "Create Bending Detail", 108 | VerticalAlignment = VerticalAlignment.Center, 109 | Margin = new Thickness(10, 0, 20, 0) 110 | }; 111 | 112 | //Initialize a LabelComboBoxImage to display a list of bar images 113 | LabelComboBoxImage labelComboBoxImage = new LabelComboBoxImage() 114 | { 115 | ShowLabel = false, 116 | ItemsTextImage = GetRebarImages(), 117 | 118 | //By default the width is 100 119 | ComboBoxWidth = 220 120 | }; 121 | 122 | //Initialize a Button 123 | SCADtools.Revit.UI.Button button = new SCADtools.Revit.UI.Button() 124 | { 125 | Label = "...", 126 | 127 | //To indicate the separation of the Button with some control that is to its left 128 | MarginLeft = 6, 129 | 130 | ControlToolTip = new ControlToolTip() 131 | { 132 | Title = "Rebar Shape Browser", 133 | Content = "Launch/Close Rebar Shape Browser.", 134 | } 135 | }; 136 | 137 | //Initialize some list of diameters 138 | List comboBoxItemsText = new List() 139 | { 140 | new ComboBoxItemText() { ItemText = "8" }, 141 | new ComboBoxItemText() { ItemText = "10" }, 142 | new ComboBoxItemText() { ItemText = "12" }, 143 | new ComboBoxItemText() { ItemText = "16" } 144 | }; 145 | //Initialize a LabelComboBox to display a list of diameters 146 | LabelComboBox labelComboBox = new LabelComboBox() 147 | { 148 | Label = "Diameter:", 149 | ItemsText = comboBoxItemsText, 150 | 151 | //To indicate the separation of the LabelComboBox with some control that is to its left 152 | MarginLeft = 10, 153 | 154 | //By default the width is 100 155 | ComboBoxWidth = 52, 156 | 157 | ControlToolTip = new ControlToolTip() 158 | { 159 | Title = "Bar Diameter", 160 | Content = "Specifies the bar diameter.", 161 | } 162 | }; 163 | //Create some event 164 | labelComboBox.ComboBoxControl.SelectionChanged += ComboBoxControlOnSelectionChanged; 165 | 166 | //Initialize a LabelTextBox to indicate bar spacing 167 | LabelTextBox labelTextBox = new LabelTextBox() 168 | { 169 | Label = "Spacing:", 170 | Text = "20", 171 | 172 | //To indicate the separation of the LabelTextBox with some control that is to its left 173 | MarginLeft = 10, 174 | 175 | //By default the width is 50 176 | TextBoxWidth = 52, 177 | 178 | ControlToolTip = new ControlToolTip() 179 | { 180 | Title = "Reinforcement Spacing", 181 | Content = "Specifies the spacing for rebar.", 182 | } 183 | }; 184 | 185 | LabelCheckBox labelCheckBox = new LabelCheckBox() 186 | { 187 | Label = "Use amount settings", 188 | 189 | //To indicate the separation of the LabelCheckBox with some control that is to its left 190 | MarginLeft = 10, 191 | 192 | //Implement controls to manage the IsChecked property 193 | EnabledElements = new List() { labelComboBox, labelTextBox } 194 | }; 195 | 196 | //Display the OptionsBar 197 | optionsBar.Show(new List() 198 | { 199 | textBlock, 200 | new SCADtools.Revit.UI.Separator(), 201 | labelComboBoxImage, 202 | button, 203 | new SCADtools.Revit.UI.Separator(), 204 | labelComboBox, 205 | labelTextBox, 206 | labelCheckBox 207 | }); 208 | } 209 | 210 | private void ComboBoxControlOnSelectionChanged(object sender, SelectionChangedEventArgs e) 211 | { 212 | System.Windows.Controls.ComboBox comboBox = (System.Windows.Controls.ComboBox)sender; 213 | if (comboBox.SelectedItem != null) 214 | { 215 | ComboBoxItemText comboBoxItemText = (ComboBoxItemText)comboBox.SelectedItem; 216 | MessageBox.Show("Selected item is: " + comboBoxItemText.ItemText); 217 | } 218 | } 219 | 220 | private List GetRebarImages() 221 | { 222 | //Initialize some list of bar images 223 | return new List() 224 | { 225 | new ComboBoxItemTextImage() { ItemTitle = "Rebar Shape : ", ItemText = "B1", 226 | ItemImage = new BitmapImage(new Uri("pack://application:,,,/OptionsBarSample;component/Images/B1.png", UriKind.Absolute)), 227 | IsVisibleImageCollapsed = true }, 228 | new ComboBoxItemTextImage() { ItemTitle = "Rebar Shape : ", ItemText = "B2", 229 | ItemImage = new BitmapImage(new Uri("pack://application:,,,/OptionsBarSample;component/Images/B2.png", UriKind.Absolute)), 230 | IsVisibleImageCollapsed = true }, 231 | new ComboBoxItemTextImage() { ItemTitle = "Rebar Shape : ", ItemText = "B3", 232 | ItemImage = new BitmapImage(new Uri("pack://application:,,,/OptionsBarSample;component/Images/B3.png", UriKind.Absolute)), 233 | IsVisibleImageCollapsed = true } 234 | }; 235 | } 236 | } 237 | } 238 | ``` 239 | -------------------------------------------------------------------------------- /rvt2023/optionsbarcombined.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpeedCAD/SCADtools.Revit.UI.OptionsBar/28386a15637cdc72039ee7d41caba183e983e37b/rvt2023/optionsbarcombined.gif -------------------------------------------------------------------------------- /rvt2023/optionsbarsingle.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpeedCAD/SCADtools.Revit.UI.OptionsBar/28386a15637cdc72039ee7d41caba183e983e37b/rvt2023/optionsbarsingle.gif -------------------------------------------------------------------------------- /rvt2024/optionsbardark.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpeedCAD/SCADtools.Revit.UI.OptionsBar/28386a15637cdc72039ee7d41caba183e983e37b/rvt2024/optionsbardark.gif -------------------------------------------------------------------------------- /rvt2024/optionsbarlight.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpeedCAD/SCADtools.Revit.UI.OptionsBar/28386a15637cdc72039ee7d41caba183e983e37b/rvt2024/optionsbarlight.gif --------------------------------------------------------------------------------