public static void CreateUI(RibbonPanel ribbonPanel) { var items = ribbonPanel.AddStackedItems ( new ComboBoxData("Category"), NewPushButtonData <CommandGrasshopperBake, Availability>("Bake Selected") ); if (items[0] is ComboBox comboBox) { categoriesComboBox = comboBox; EventHandler <IdlingEventArgs> BuildDirectShapeCategoryList = null; Revit.ApplicationUI.Idling += BuildDirectShapeCategoryList = (sender, args) => { var doc = (sender as UIApplication)?.ActiveUIDocument.Document; if (doc == null) { return; } var directShapeCategories = Enum.GetValues(typeof(BuiltInCategory)).Cast <BuiltInCategory>(). Where(categoryId => DirectShape.IsValidCategoryId(new ElementId(categoryId), doc)). Select(categoryId => Autodesk.Revit.DB.Category.GetCategory(doc, categoryId)); foreach (var group in directShapeCategories.GroupBy(x => x.CategoryType).OrderBy(x => x.Key.ToString())) { foreach (var category in group.OrderBy(x => x.Name)) { var comboBoxMemberData = new ComboBoxMemberData(((BuiltInCategory)category.Id.IntegerValue).ToString(), category.Name) { GroupName = group.Key.ToString() }; var item = categoriesComboBox.AddItem(comboBoxMemberData); if ((BuiltInCategory)category.Id.IntegerValue == BuiltInCategory.OST_GenericModel) { categoriesComboBox.Current = item; } } } Revit.ApplicationUI.Idling -= BuildDirectShapeCategoryList; }; } if (items[1] is PushButton bakeButton) { bakeButton.ToolTip = "Bake geometry in all selected objects"; bakeButton.Image = ImageBuilder.LoadBitmapImage("RhinoInside.Resources.GH.Toolbar.Bake_24x24.png", true); bakeButton.LargeImage = ImageBuilder.LoadBitmapImage("RhinoInside.Resources.GH.Toolbar.Bake_24x24.png"); bakeButton.Visible = PlugIn.PlugInExists(PluginId, out bool loaded, out bool loadProtected); } }
/// <summary> /// Combo box - 5 items in 2 groups. /// Combo box is used in conjunction with event. We'll come back later. /// For now, just demonstrates how to make a combo box. /// </summary> public void AddComboBox(RibbonPanel panel) { // Create five combo box members with two groups // #1 ComboBoxMemberData comboBoxMemberData1 = new ComboBoxMemberData("ComboCommandData", "Command Data"); comboBoxMemberData1.Image = NewBitmapImage("Basics.ico"); comboBoxMemberData1.GroupName = "DB Basics"; // #2 ComboBoxMemberData comboBoxMemberData2 = new ComboBoxMemberData("ComboDbElement", "DB Element"); comboBoxMemberData2.Image = NewBitmapImage("Basics.ico"); comboBoxMemberData2.GroupName = "DB Basics"; // #3 ComboBoxMemberData comboBoxMemberData3 = new ComboBoxMemberData("ComboElementFiltering", "Filtering"); comboBoxMemberData3.Image = NewBitmapImage("Basics.ico"); comboBoxMemberData3.GroupName = "DB Basics"; // #4 ComboBoxMemberData comboBoxMemberData4 = new ComboBoxMemberData("ComboElementModification", "Modify"); comboBoxMemberData4.Image = NewBitmapImage("Basics.ico"); comboBoxMemberData4.GroupName = "Modeling"; // #5 ComboBoxMemberData comboBoxMemberData5 = new ComboBoxMemberData("ComboModelCreation", "Create"); comboBoxMemberData5.Image = NewBitmapImage("Basics.ico"); comboBoxMemberData5.GroupName = "Modeling"; // Make a combo box now ComboBoxData comboBxData = new ComboBoxData("ComboBox"); ComboBox comboBx = panel.AddItem(comboBxData) as ComboBox; comboBx.ToolTip = "Select an Option"; comboBx.LongDescription = "select a command you want to run"; comboBx.AddItem(comboBoxMemberData1); comboBx.AddItem(comboBoxMemberData2); comboBx.AddItem(comboBoxMemberData3); comboBx.AddItem(comboBoxMemberData4); comboBx.AddItem(comboBoxMemberData5); comboBx.CurrentChanged += new EventHandler <Autodesk.Revit.UI.Events.ComboBoxCurrentChangedEventArgs>(comboBx_CurrentChanged); }
public Result OnStartup(UIControlledApplication application) { application.CreateRibbonTab("UCD场地工具"); RibbonPanel panel1 = application.CreateRibbonPanel("UCD场地工具", "欢迎页"); PushButtonData pbd = new PushButtonData("UCD场地工具", "欢迎使用", @"D:\Studay\CSharp\Work\Revit\HelloRevit\bin\Debug\HelloRevit.dll", "HelloRevit.Class1"); PushButton pb = panel1.AddItem(pbd) as PushButton; RibbonPanel panel2 = application.CreateRibbonPanel("UCD场地工具", "工具"); SplitButtonData splitData = new SplitButtonData("我的集合", "创建工具"); SplitButton sb = panel2.AddItem(splitData) as SplitButton; PushButtonData spd = new PushButtonData("UCD场地工具", "创建", @"D:\Studay\CSharp\Work\Revit\Create2\bin\Debug\Create2.dll", "Create2.CreateBox") { LargeImage = new BitmapImage(new Uri(@"D:\Studay\CSharp\Work\Revit\Ribbon1\img\sign_road.png")) }; sb.AddPushButton(spd); panel2.AddSeparator(); PulldownButtonData pdbd = new PulldownButtonData("UCD场地工具", "检查"); PushButtonData pushbtn = new PushButtonData("UCD场地工具", "碰撞检查", @"D:\Studay\CSharp\Work\Revit\Collision\bin\Debug\Collision.dll", "Collision.Class1"); PulldownButton btn = panel2.AddItem(pushbtn) as PulldownButton; btn.LongDescription = "检查当前物体是否碰撞"; btn.AddPushButton(pushbtn); RibbonPanel panel3 = application.CreateRibbonPanel("UCD场地工具", "文件"); ComboBoxData cbd = new ComboBoxData("选项"); ComboBox cBox = panel3.AddItem(cbd) as ComboBox; if (cBox != null) { cBox.ItemText = "选择操作"; cBox.ToolTip = "请选择想要进行的操作"; cBox.LongDescription = "选择一直接关闭,选择二关闭并修改"; ComboBoxMemberData cbmd = new ComboBoxMemberData("A", "关闭"); ComboBoxMemberData cbmd2 = new ComboBoxMemberData("B", "关闭并修改"); cbmd.GroupName = "编辑操作"; cBox.AddItem(cbmd); cBox.AddItem(cbmd2); } cBox.CurrentChanged += Change; cBox.CurrentChanged += Closed; return(Result.Succeeded); }
//public void application_Sync(object sender, DocumentSynchronizingWithCentralEventArgs args) //{ // Document doc = args.Document; //progress.Report(doc); //} public void getdoc(object sender, ViewActivatedEventArgs args) { doc = args.Document; ComboBoxMemberData Range1 = new ComboBoxMemberData("0", "1/2\""); ComboBoxMemberData Range2 = new ComboBoxMemberData("1", "1\""); ComboBoxMemberData Range3 = new ComboBoxMemberData("2", "3\""); ComboBoxMemberData Range4 = new ComboBoxMemberData("3", "1' 0\""); ComboBoxMemberData Range5 = new ComboBoxMemberData("4", "3' 0\""); ComboBoxMemberData Range6 = new ComboBoxMemberData("5", "10' 0\""); if (doc.DisplayUnitSystem == DisplayUnit.IMPERIAL) { UnitFormatUtils.TryParse(doc.GetUnits(), UnitType.UT_Length, "1/2\"", out StoreExp.vrOpt1); UnitFormatUtils.TryParse(doc.GetUnits(), UnitType.UT_Length, "1\"", out StoreExp.vrOpt2); UnitFormatUtils.TryParse(doc.GetUnits(), UnitType.UT_Length, "3\"", out StoreExp.vrOpt3); UnitFormatUtils.TryParse(doc.GetUnits(), UnitType.UT_Length, "1'0\"", out StoreExp.vrOpt4); UnitFormatUtils.TryParse(doc.GetUnits(), UnitType.UT_Length, "3'0\"", out StoreExp.vrOpt5); UnitFormatUtils.TryParse(doc.GetUnits(), UnitType.UT_Length, "10'0\"", out StoreExp.vrOpt6); } else { UnitFormatUtils.TryParse(doc.GetUnits(), UnitType.UT_Length, "1 cm", out StoreExp.vrOpt1); UnitFormatUtils.TryParse(doc.GetUnits(), UnitType.UT_Length, "2 cm", out StoreExp.vrOpt2); UnitFormatUtils.TryParse(doc.GetUnits(), UnitType.UT_Length, "10 cm", out StoreExp.vrOpt3); UnitFormatUtils.TryParse(doc.GetUnits(), UnitType.UT_Length, "30 cm", out StoreExp.vrOpt4); UnitFormatUtils.TryParse(doc.GetUnits(), UnitType.UT_Length, "90 cm", out StoreExp.vrOpt5); UnitFormatUtils.TryParse(doc.GetUnits(), UnitType.UT_Length, "300 cm", out StoreExp.vrOpt6); Range1.Text = "1 cm"; Range2.Text = "2 cm"; Range3.Text = "10 cm"; Range4.Text = "30 cm"; Range5.Text = "90 cm"; Range6.Text = "300 cm"; } UiCtrApp.ViewActivated -= getdoc; foreach (RibbonItem item in panel_ViewSetup.GetItems()) { if (item.Name == "ShiftRange") { ComboBox ShiftRange_CB = (ComboBox)item; ShiftRange_CB.AddItem(Range1); ShiftRange_CB.AddItem(Range2); ShiftRange_CB.AddItem(Range3); ShiftRange_CB.AddItem(Range4); ShiftRange_CB.AddItem(Range5); ShiftRange_CB.AddItem(Range6); } } doc = null; }
public Result OnStartup(UIControlledApplication application) { var tabName = "BIMBOX"; application.CreateRibbonTab(tabName); var panel = application.CreateRibbonPanel(tabName, "小工具"); var assemblyType = new Face2Face().GetType(); var location = assemblyType.Assembly.Location; var className = assemblyType.FullName; var pushButtonData = new PushButtonData("tool", "面生面", location, className); var imageSource = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"\Images\tools.png"; pushButtonData.LargeImage = new BitmapImage(new Uri(imageSource)); var pushButton = panel.AddItem(pushButtonData) as PushButton; panel.AddSeparator(); var assemblyType1 = new GeometryCalculation().GetType(); var location1 = assemblyType1.Assembly.Location; var className1 = assemblyType1.FullName; var pushButtonData1 = new PushButtonData("tool1", "创建几何体", location1, className1); var imageSource1 = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"\Images\3D.png"; pushButtonData1.LargeImage = new BitmapImage(new Uri(imageSource1)); var pushButton1 = panel.AddItem(pushButtonData1) as PushButton; pushButton1.AvailabilityClassName = className1; var comboBoxData = new ComboBoxData("选项"); var comboBox = panel.AddItem(comboBoxData) as ComboBox; comboBox.ItemText = "选择操作"; comboBox.ToolTip = "请选择想要进行的操作"; var comboBox1 = new ComboBoxMemberData("A", "关闭"); var comboBox2 = new ComboBoxMemberData("B", "关闭并修改"); comboBox1.GroupName = "编辑操作"; comboBox.AddItem(comboBox1); comboBox.AddItem(comboBox2); comboBox.CurrentChanged += change; comboBox.DropDownClosed += closed; return(Result.Succeeded); }
/// <summary> /// Adds a drop down menu for selection of a type of prism. This four types /// correspond to 4 family symbols already loaded in the working Revit document. /// </summary> /// <param name="panel">the RibbonPanel where the UI element is added</param> private void AddPrismComboBox(RibbonPanel panel) { // create a four members combo box for family instance selection //Family instance #1 ComboBoxMemberData comboBoxMemberData1 = new ComboBoxMemberData("cylinder", "cylinder prism"); //Family instance #2 ComboBoxMemberData comboBoxMemberData2 = new ComboBoxMemberData("rectangle", "rectangular prism"); //Family instance #3 ComboBoxMemberData comboBoxMemberData3 = new ComboBoxMemberData("regularpolygon", "regular polygon prism"); //Family instance #4 ComboBoxMemberData comboBoxMemberData4 = new ComboBoxMemberData("isotriangle", "isotriangle prism"); //make a combo box group group ComboBoxData comboBxData = new ComboBoxData("ComboBox"); prismComboBox = panel.AddItem(comboBxData) as ComboBox; prismComboBox.ToolTip = "select a prism to array on a curve"; prismComboBox.AddItem(comboBoxMemberData1); prismComboBox.AddItem(comboBoxMemberData2); prismComboBox.AddItem(comboBoxMemberData3); prismComboBox.AddItem(comboBoxMemberData4); }
/// <summary> /// Insert Level into ComboBox - LevelsSelector /// </summary> /// <param name="evnetArgs">Autodesk.Revit.DB.Events.DocumentCreatedEventArgs</param> public void DocumentCreated(object sender, Autodesk.Revit.DB.Events.DocumentCreatedEventArgs e) { uiApplication = new UIApplication(e.Document.Application); List <RibbonPanel> myPanels = uiApplication.GetRibbonPanels(); Autodesk.Revit.UI.ComboBox comboboxLevel = (Autodesk.Revit.UI.ComboBox)(myPanels[0].GetItems()[2]); if (null == comboboxLevel) { return; } FilteredElementCollector collector = new FilteredElementCollector(uiApplication.ActiveUIDocument.Document); ICollection <Element> founds = collector.OfClass(typeof(Level)).ToElements(); foreach (Element elem in founds) { Level level = elem as Level; ComboBoxMemberData comboBoxMemberData = new ComboBoxMemberData(level.Name, level.Name); ComboBoxMember comboboxMember = comboboxLevel.AddItem(comboBoxMemberData); comboboxMember.Image = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "LevelsSelector.png"), UriKind.Absolute)); } //refresh level list (in case user created new level after document created) comboboxLevel.DropDownOpened += new EventHandler <ComboBoxDropDownOpenedEventArgs>(AddNewLevels); }
/// <summary> /// This method is used to create RibbonSample panel, and add wall related command buttons to it: /// 1. contains a SplitButton for user to create Non-Structural or Structural Wall; /// 2. contains a StackedBotton which is consisted with one PushButton and two Comboboxes, /// PushButon is used to reset all the RibbonItem, Comboboxes are use to select Level and WallShape /// 3. contains a RadioButtonGroup for user to select WallType. /// 4. Adds a Slide-Out Panel to existing panel with following functionalities: /// 5. a text box is added to set mark for new wall, mark is a instance parameter for wall, /// Eg: if user set text as "wall", then Mark for each new wall will be "wall1", "wall2", "wall3".... /// 6. a StackedButton which consisted of a PushButton (delete all the walls) and a PulldownButton (move all the walls in X or Y direction) /// </summary> /// <param name="application">An object that is passed to the external application /// which contains the controlled application.</param> private void CreateRibbonSamplePanel(UIControlledApplication application) { // create a Ribbon panel which contains three stackable buttons and one single push button. string firstPanelName = "Ribbon Sample"; RibbonPanel ribbonSamplePanel = application.CreateRibbonPanel(firstPanelName); #region Create a SplitButton for user to create Non-Structural or Structural Wall SplitButtonData splitButtonData = new SplitButtonData("NewWallSplit", "Create Wall"); SplitButton splitButton = ribbonSamplePanel.AddItem(splitButtonData) as SplitButton; PushButton pushButton = splitButton.AddPushButton(new PushButtonData("WallPush", "Wall", AddInPath, "Revit.SDK.Samples.Ribbon.CS.CreateWall")); pushButton.LargeImage = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "CreateWall.png"), UriKind.Absolute)); pushButton.Image = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "CreateWall-S.png"), UriKind.Absolute)); pushButton.ToolTip = "Creates a partition wall in the building model."; pushButton.ToolTipImage = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "CreateWallTooltip.bmp"), UriKind.Absolute)); pushButton = splitButton.AddPushButton(new PushButtonData("StrWallPush", "Structure Wall", AddInPath, "Revit.SDK.Samples.Ribbon.CS.CreateStructureWall")); pushButton.LargeImage = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "StrcturalWall.png"), UriKind.Absolute)); pushButton.Image = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "StrcturalWall-S.png"), UriKind.Absolute)); #endregion ribbonSamplePanel.AddSeparator(); #region Add a StackedButton which is consisted of one PushButton and two Comboboxes PushButtonData pushButtonData = new PushButtonData("Reset", "Reset", AddInPath, "Revit.SDK.Samples.Ribbon.CS.ResetSetting"); ComboBoxData comboBoxDataLevel = new ComboBoxData("LevelsSelector"); ComboBoxData comboBoxDataShape = new ComboBoxData("WallShapeComboBox"); IList <RibbonItem> ribbonItemsStacked = ribbonSamplePanel.AddStackedItems(pushButtonData, comboBoxDataLevel, comboBoxDataShape); ((PushButton)(ribbonItemsStacked[0])).Image = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "Reset.png"), UriKind.Absolute)); //Add options to WallShapeComboBox Autodesk.Revit.UI.ComboBox comboboxWallShape = (Autodesk.Revit.UI.ComboBox)(ribbonItemsStacked[2]); ComboBoxMemberData comboBoxMemberData = new ComboBoxMemberData("RectangleWall", "RectangleWall"); ComboBoxMember comboboxMember = comboboxWallShape.AddItem(comboBoxMemberData); comboboxMember.Image = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "RectangleWall.png"), UriKind.Absolute)); comboBoxMemberData = new ComboBoxMemberData("CircleWall", "CircleWall"); comboboxMember = comboboxWallShape.AddItem(comboBoxMemberData); comboboxMember.Image = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "CircleWall.png"), UriKind.Absolute)); comboBoxMemberData = new ComboBoxMemberData("TriangleWall", "TriangleWall"); comboboxMember = comboboxWallShape.AddItem(comboBoxMemberData); comboboxMember.Image = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "TriangleWall.png"), UriKind.Absolute)); comboBoxMemberData = new ComboBoxMemberData("SquareWall", "SquareWall"); comboboxMember = comboboxWallShape.AddItem(comboBoxMemberData); comboboxMember.Image = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "SquareWall.png"), UriKind.Absolute)); #endregion ribbonSamplePanel.AddSeparator(); #region Add a RadioButtonGroup for user to select WallType RadioButtonGroupData radioButtonGroupData = new RadioButtonGroupData("WallTypeSelector"); RadioButtonGroup radioButtonGroup = (RadioButtonGroup)(ribbonSamplePanel.AddItem(radioButtonGroupData)); ToggleButton toggleButton = radioButtonGroup.AddItem(new ToggleButtonData("Generic8", "Generic - 8\"", AddInPath, "Revit.SDK.Samples.Ribbon.CS.Dummy")); toggleButton.LargeImage = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "Generic8.png"), UriKind.Absolute)); toggleButton.Image = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "Generic8-S.png"), UriKind.Absolute)); toggleButton = radioButtonGroup.AddItem(new ToggleButtonData("ExteriorBrick", "Exterior - Brick", AddInPath, "Revit.SDK.Samples.Ribbon.CS.Dummy")); toggleButton.LargeImage = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "ExteriorBrick.png"), UriKind.Absolute)); toggleButton.Image = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "ExteriorBrick-S.png"), UriKind.Absolute)); #endregion //slide-out panel: ribbonSamplePanel.AddSlideOut(); #region add a Text box to set the mark for new wall TextBoxData testBoxData = new TextBoxData("WallMark"); Autodesk.Revit.UI.TextBox textBox = (Autodesk.Revit.UI.TextBox)(ribbonSamplePanel.AddItem(testBoxData)); textBox.Value = "new wall"; //default wall mark textBox.Image = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "WallMark.png"), UriKind.Absolute)); textBox.ToolTip = "Set the mark for new wall"; textBox.ShowImageAsButton = true; textBox.EnterPressed += new EventHandler <Autodesk.Revit.UI.Events.TextBoxEnterPressedEventArgs>(SetTextBoxValue); #endregion ribbonSamplePanel.AddSeparator(); #region Create a StackedButton which consisted of a PushButton (delete all the walls) and a PulldownButton (move all the walls in X or Y direction) PushButtonData deleteWallsButtonData = new PushButtonData("deleteWalls", "Delete Walls", AddInPath, "Revit.SDK.Samples.Ribbon.CS.DeleteWalls"); deleteWallsButtonData.ToolTip = "Delete all the walls created by the Create Wall tool."; deleteWallsButtonData.Image = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "DeleteWalls.png"), UriKind.Absolute)); PulldownButtonData moveWallsButtonData = new PulldownButtonData("moveWalls", "Move Walls"); moveWallsButtonData.ToolTip = "Move all the walls in X or Y direction"; moveWallsButtonData.Image = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "MoveWalls.png"), UriKind.Absolute)); // create stackable buttons IList <RibbonItem> ribbonItems = ribbonSamplePanel.AddStackedItems(deleteWallsButtonData, moveWallsButtonData); // add two push buttons as sub-items of the moveWalls PulldownButton. PulldownButton moveWallItem = ribbonItems[1] as PulldownButton; PushButton moveX = moveWallItem.AddPushButton(new PushButtonData("XDirection", "X Direction", AddInPath, "Revit.SDK.Samples.Ribbon.CS.XMoveWalls")); moveX.ToolTip = "move all walls 10 feet in X direction."; moveX.LargeImage = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "MoveWallsXLarge.png"), UriKind.Absolute)); PushButton moveY = moveWallItem.AddPushButton(new PushButtonData("YDirection", "Y Direction", AddInPath, "Revit.SDK.Samples.Ribbon.CS.YMoveWalls")); moveY.ToolTip = "move all walls 10 feet in Y direction."; moveY.LargeImage = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "MoveWallsYLarge.png"), UriKind.Absolute)); #endregion ribbonSamplePanel.AddSeparator(); application.ControlledApplication.DocumentCreated += new EventHandler <Autodesk.Revit.DB.Events.DocumentCreatedEventArgs>(DocumentCreated); }
/// <summary> /// Combo box - 5 items in 2 groups. /// Combo box is used in conjunction with event. We'll come back later. /// For now, just demonstrates how to make a combo box. /// </summary> public void AddComboBox(RibbonPanel panel) { // Create five combo box members with two groups // #1 ComboBoxMemberData comboBoxMemberData1 = new ComboBoxMemberData("ComboCommandData", "Command Data"); comboBoxMemberData1.Image = NewBitmapImage("Basics.ico"); comboBoxMemberData1.GroupName = "DB Basics"; // #2 ComboBoxMemberData comboBoxMemberData2 = new ComboBoxMemberData("ComboDbElement", "DB Element"); comboBoxMemberData2.Image = NewBitmapImage("Basics.ico"); comboBoxMemberData2.GroupName = "DB Basics"; // #3 ComboBoxMemberData comboBoxMemberData3 = new ComboBoxMemberData("ComboElementFiltering", "Filtering"); comboBoxMemberData3.Image = NewBitmapImage("Basics.ico"); comboBoxMemberData3.GroupName = "DB Basics"; // #4 ComboBoxMemberData comboBoxMemberData4 = new ComboBoxMemberData("ComboElementModification", "Modify"); comboBoxMemberData4.Image = NewBitmapImage("Basics.ico"); comboBoxMemberData4.GroupName = "Modeling"; // #5 ComboBoxMemberData comboBoxMemberData5 = new ComboBoxMemberData("ComboModelCreation", "Create"); comboBoxMemberData5.Image = NewBitmapImage("Basics.ico"); comboBoxMemberData5.GroupName = "Modeling"; // Make a combo box now ComboBoxData comboBxData = new ComboBoxData("ComboBox"); ComboBox comboBx = panel.AddItem(comboBxData) as ComboBox; comboBx.ToolTip = "Select an Option"; comboBx.LongDescription = "select a command you want to run"; comboBx.AddItem(comboBoxMemberData1); comboBx.AddItem(comboBoxMemberData2); comboBx.AddItem(comboBoxMemberData3); comboBx.AddItem(comboBoxMemberData4); comboBx.AddItem(comboBoxMemberData5); comboBx.CurrentChanged += new EventHandler<Autodesk.Revit.UI.Events.ComboBoxCurrentChangedEventArgs>(comboBx_CurrentChanged); }
private void AddStackedButtons(RibbonPanel panel) { ComboBoxData cbData = new ComboBoxData("comboBox"); TextBoxData textData = new TextBoxData("Text Box"); textData.Image = new System.Windows.Media.Imaging.BitmapImage(new Uri(@"D:\Sample\HelloWorld\bin\Debug\39-Globe_16x16.png")); textData.Name = "Text Box"; textData.ToolTip = "Enter some text here"; textData.LongDescription = "This is text that will appear next to the image" + "when the user hovers the mouse over the control"; textData.ToolTipImage = new System.Windows.Media.Imaging.BitmapImage(new Uri(@"D:\Sample\HelloWorld\bin\Debug\39-Globe_32x32.png")); IList <RibbonItem> stackedItems = panel.AddStackedItems(textData, cbData); if (stackedItems.Count > 1) { TextBox tBox = stackedItems[0] as TextBox; if (tBox != null) { tBox.PromptText = "Enter a comment"; tBox.ShowImageAsButton = true; tBox.ToolTip = "Enter some text"; // Register event handler ProcessText tBox.EnterPressed += new EventHandler <Autodesk.Revit.UI.Events.TextBoxEnterPressedEventArgs>(ProcessText); } ComboBox cBox = stackedItems[1] as ComboBox; if (cBox != null) { cBox.ItemText = "ComboBox"; cBox.ToolTip = "Select an Option"; cBox.LongDescription = "Select a number or letter"; ComboBoxMemberData cboxMemDataA = new ComboBoxMemberData("A", "Option A"); cboxMemDataA.Image = new System.Windows.Media.Imaging.BitmapImage(new Uri(@"D:\Sample\HelloWorld\bin\Debug\A.bmp")); cboxMemDataA.GroupName = "Letters"; cBox.AddItem(cboxMemDataA); ComboBoxMemberData cboxMemDataB = new ComboBoxMemberData("B", "Option B"); cboxMemDataB.Image = new System.Windows.Media.Imaging.BitmapImage(new Uri(@"D:\Sample\HelloWorld\bin\Debug\B.bmp")); cboxMemDataB.GroupName = "Letters"; cBox.AddItem(cboxMemDataB); ComboBoxMemberData cboxMemData = new ComboBoxMemberData("One", "Option 1"); cboxMemData.Image = new System.Windows.Media.Imaging.BitmapImage(new Uri(@"D:\Sample\HelloWorld\bin\Debug\One.bmp")); cboxMemData.GroupName = "Numbers"; cBox.AddItem(cboxMemData); ComboBoxMemberData cboxMemData2 = new ComboBoxMemberData("Two", "Option 2"); cboxMemData2.Image = new System.Windows.Media.Imaging.BitmapImage(new Uri(@"D:\Sample\HelloWorld\bin\Debug\Two.bmp")); cboxMemData2.GroupName = "Numbers"; cBox.AddItem(cboxMemData2); ComboBoxMemberData cboxMemData3 = new ComboBoxMemberData("Three", "Option 3"); cboxMemData3.Image = new System.Windows.Media.Imaging.BitmapImage(new Uri(@"D:\Sample\HelloWorld\bin\Debug\Three.bmp")); cboxMemData3.GroupName = "Numbers"; cBox.AddItem(cboxMemData3); } } }
public static void DBPanel(UIControlledApplication uiApp, string tabname) { RibbonPanel Panel = uiApp.CreateRibbonPanel(tabname, "Database"); PushButtonData Analysis = new PushButtonData( "Run Fixture Calcs", "Run Fixture Calcs", dllpath(), "CC_Events.RunCodeAnalysis"); Analysis.ToolTip = "Run plumbing fixture calcs for all rooms in the project."; PushButton AnalysisButton = Panel.AddItem(Analysis) as PushButton; Panel.AddSeparator(); PushButtonData Notes = new PushButtonData( "Notes", "Notes", @dllpath(), "CC_Events.RevitNotes"); PushButton NoteButton = Panel.AddItem(Notes) as PushButton; Panel.AddSeparator(); PushButtonData AddParameters = new PushButtonData( "Add Parameters", "Add Parameters", @dllpath(), "CC_Events.AddParameters"); PushButtonData ResetParameters = new PushButtonData( "Reset Paraeters", "Reset Parameters", @dllpath(), "CC_Events.ResetParams"); ComboBoxData DatabaseOptionData = new ComboBoxData("Database Options"); IList <RibbonItem> Basics = Panel.AddStackedItems(AddParameters, ResetParameters, DatabaseOptionData); if (Basics.Count > 1) { ComboBox dbBox = Basics[2] as ComboBox; if (dbBox != null) { ComboBoxMemberData MaterialOption = new ComboBoxMemberData("Materials", "Materials"); MaterialOption.GroupName = "Database"; dbBox.AddItem(MaterialOption); ComboBoxMemberData EquipmentOption = new ComboBoxMemberData("Equipment", "Equipment"); EquipmentOption.GroupName = "Database"; dbBox.AddItem(EquipmentOption); ComboBoxMemberData StaffOption = new ComboBoxMemberData("Facilities", "Facilities"); StaffOption.GroupName = "Database"; dbBox.AddItem(StaffOption); ComboBoxMemberData DoorsOption = new ComboBoxMemberData("Doors", "Doors"); DoorsOption.GroupName = "Database"; dbBox.AddItem(DoorsOption); ComboBoxMemberData ProjectOption = new ComboBoxMemberData("Project", "Project"); ProjectOption.GroupName = "Database"; dbBox.AddItem(ProjectOption); dbBox.CurrentChanged += new EventHandler <Autodesk.Revit.UI.Events.ComboBoxCurrentChangedEventArgs>(RegenComboBox); } PushButtonData B1Data = new PushButtonData( "Import Data", "Import Data", @dllpath(), "CC_Events.ReadDatabase"); PushButtonData B2Data = new PushButtonData( "Export Data", "Export Data", @dllpath(), "CC_Events.WriteDatabase"); List <RibbonItem> MatDBButtons = new List <RibbonItem>(); MatDBButtons.AddRange(Panel.AddStackedItems(B1Data, B2Data)); } }
public void AddCustomRibbon(UIControlledApplication app) { app.CreateRibbonTab("DEI"); RibbonPanel panel = app.CreateRibbonPanel("DEI", "Custom Commands"); RibbonPanel devices = app.CreateRibbonPanel("DEI", "Systems Devices"); ////DBElement button //PushButtonData buttonDataDB = new PushButtonData("PushButtonDB", "DB Element", _path, "DEIMod.DBElement"); //PushButton buttonDB = panel.AddItem(buttonDataDB) as PushButton; //buttonDB.ToolTip = "Displays basic info of a selected element"; //ElementFiltering button PushButtonData buttonDataFilter = new PushButtonData("PushButtonFilter", "Element Filtering", _path, "DEIMod.ElementFiltering"); PushButton buttonFilter = panel.AddItem(buttonDataFilter) as PushButton; buttonFilter.ToolTip = "Lists elements of the Electrical Fixtures Category"; //BuiltInCategory. //OST_ElectricalFixtures //OST_CommunicationDevices //OST_DataDevices //OST_FireAlarmDevices //OST_LightingDevices //OST_NurseCallDevices //OST_SecurityDevices //OST_TelephoneDevices //ElectricalFixtures Buttons PushButtonData efData = new PushButtonData("efData", "Electrical Fixtures", _path, "DEIMod.ElectricalDevices"); PushButton efButton = devices.AddItem(efData) as PushButton; efButton.ToolTip = "Places electrical devices such as receptacles, junction boxes, and other power devices. "; efButton.LargeImage = toBitmapImage(Properties.Resources.Utility_9920); //CommunicationDevices PushButtonData comData = new PushButtonData("comData", "Communication Devices", _path, "DEIMod.Communication"); PushButton comButton = devices.AddItem(comData) as PushButton; comButton.ToolTip = "Places communication devices such as intercom system components."; comButton.LargeImage = toBitmapImage(Properties.Resources.Utility_13312); //DataDevices PushButtonData dataData = new PushButtonData("dataData", "Data Devices", _path, "DEIMod.DataDevices"); PushButton dataButton = devices.AddItem(dataData) as PushButton; dataButton.ToolTip = "Places data devices such as ethernet and other network connections."; dataButton.LargeImage = toBitmapImage(Properties.Resources.Utility_13314); //FireAlarmDevices PushButtonData fireData = new PushButtonData("fireData", "Fire Alarm Devices", _path, "DEIMod.FireAlarm"); PushButton fireButton = devices.AddItem(fireData) as PushButton; fireButton.ToolTip = "Places fire alarm devices such as smoke detectors, manual pull stations, and annunciators."; fireButton.LargeImage = toBitmapImage(Properties.Resources.Utility_13315); //LightingDevices PushButtonData lightData = new PushButtonData("lightData", "Lighting Devices", _path, "DEIMod.Lighting"); PushButton lightButton = devices.AddItem(lightData) as PushButton; lightButton.ToolTip = "Places lighting switches such as daylight sensors, occupancy sensors, and manual switches"; lightButton.LargeImage = toBitmapImage(Properties.Resources.Utility_13001); //NurseCallDevices PushButtonData nurseData = new PushButtonData("nurseData", "Nurse Call Devices", _path, "DEIMod.NurseCall"); PushButton nurseButton = devices.AddItem(nurseData) as PushButton; nurseButton.ToolTip = "Places nurse call devices such as call stations, code blue stations, and door lights."; nurseButton.LargeImage = toBitmapImage(Properties.Resources.Utility_13316); //SecurityDevices PushButtonData secureData = new PushButtonData("secureData", "Security Devices", _path, "DEIMod.Security"); PushButton secureButton = devices.AddItem(secureData) as PushButton; secureButton.ToolTip = "Places security devices such as door locks, motion sensors, and surveillance cameras."; secureButton.LargeImage = toBitmapImage(Properties.Resources.Utility_13317); //TelephoneDevices PushButtonData phoneData = new PushButtonData("phoneData", "Telephone Devices", _path, "DEIMod.Telephone"); PushButton phoneButton = devices.AddItem(phoneData) as PushButton; phoneButton.ToolTip = "Places a telephone jack."; phoneButton.LargeImage = toBitmapImage(Properties.Resources.Utility_13318); ComboBoxData typeSelector = new ComboBoxData("typeSelector"); ComboBox cBox = panel.AddItem(typeSelector) as ComboBox; ComboBoxMemberData cboxMemDataA = new ComboBoxMemberData("A", "Option A"); cboxMemDataA.GroupName = "Letters"; cBox.AddItem(cboxMemDataA); ComboBoxMemberData cboxMemDataB = new ComboBoxMemberData("B", "Option B"); cboxMemDataA.GroupName = "Letters"; cBox.AddItem(cboxMemDataB); }
/// <summary> /// Bind to combobox's DropDownOpened Event, add new levels that created by user. /// </summary> /// <param name="evnetArgs">Autodesk.Revit.UI.Events.ComboBoxDropDownOpenedEventArgs</param> public void AddNewLevels(object sender, ComboBoxDropDownOpenedEventArgs args) { Autodesk.Revit.UI.ComboBox comboboxLevel = sender as Autodesk.Revit.UI.ComboBox; if (null == comboboxLevel) { return; } FilteredElementCollector collector = new FilteredElementCollector(uiApplication.ActiveUIDocument.Document); ICollection<Element> founds = collector.OfClass(typeof(Level)).ToElements(); foreach (Element elem in founds) { Level level = elem as Level; bool alreadyContained = false; foreach (ComboBoxMember comboboxMember in comboboxLevel.GetItems()) { if (comboboxMember.Name == level.Name) { alreadyContained = true; } } if (!alreadyContained) { ComboBoxMemberData comboBoxMemberData = new ComboBoxMemberData(level.Name, level.Name); ComboBoxMember comboboxMember = comboboxLevel.AddItem(comboBoxMemberData); comboboxMember.Image = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "LevelsSelector.png"), UriKind.Absolute)); } } }
/// <summary> /// This method is used to create RibbonSample panel, and add wall related command buttons to it: /// 1. contains a SplitButton for user to create Non-Structural or Structural Wall; /// 2. contains a StackedBotton which is consisted with one PushButton and two Comboboxes, /// PushButon is used to reset all the RibbonItem, Comboboxes are use to select Level and WallShape /// 3. contains a RadioButtonGroup for user to select WallType. /// 4. Adds a Slide-Out Panel to existing panel with following functionalities: /// 5. a text box is added to set mark for new wall, mark is a instance parameter for wall, /// Eg: if user set text as "wall", then Mark for each new wall will be "wall1", "wall2", "wall3".... /// 6. a StackedButton which consisted of a PushButton (delete all the walls) and a PulldownButton (move all the walls in X or Y direction) /// </summary> /// <param name="application">An object that is passed to the external application /// which contains the controlled application.</param> private void CreateRibbonSamplePanel(UIControlledApplication application) { // create a Ribbon panel which contains three stackable buttons and one single push button. string firstPanelName = "Ribbon Sample"; RibbonPanel ribbonSamplePanel = application.CreateRibbonPanel(firstPanelName); #region Create a SplitButton for user to create Non-Structural or Structural Wall SplitButtonData splitButtonData = new SplitButtonData("NewWallSplit", "Create Wall"); SplitButton splitButton = ribbonSamplePanel.AddItem(splitButtonData) as SplitButton; PushButton pushButton = splitButton.AddPushButton(new PushButtonData("WallPush", "Wall", AddInPath, "Revit.SDK.Samples.Ribbon.CS.CreateWall")); pushButton.LargeImage = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "CreateWall.png"), UriKind.Absolute)); pushButton.Image = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "CreateWall-S.png"), UriKind.Absolute)); pushButton.ToolTip = "Creates a partition wall in the building model."; pushButton.ToolTipImage = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "CreateWallTooltip.bmp"), UriKind.Absolute)); pushButton = splitButton.AddPushButton(new PushButtonData("StrWallPush", "Structure Wall", AddInPath, "Revit.SDK.Samples.Ribbon.CS.CreateStructureWall")); pushButton.LargeImage = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "StrcturalWall.png"), UriKind.Absolute)); pushButton.Image = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "StrcturalWall-S.png"), UriKind.Absolute)); #endregion ribbonSamplePanel.AddSeparator(); #region Add a StackedButton which is consisted of one PushButton and two Comboboxes PushButtonData pushButtonData = new PushButtonData("Reset", "Reset", AddInPath, "Revit.SDK.Samples.Ribbon.CS.ResetSetting"); ComboBoxData comboBoxDataLevel = new ComboBoxData("LevelsSelector"); ComboBoxData comboBoxDataShape = new ComboBoxData("WallShapeComboBox"); IList<RibbonItem> ribbonItemsStacked = ribbonSamplePanel.AddStackedItems(pushButtonData, comboBoxDataLevel, comboBoxDataShape); ((PushButton)(ribbonItemsStacked[0])).Image = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "Reset.png"), UriKind.Absolute)); //Add options to WallShapeComboBox Autodesk.Revit.UI.ComboBox comboboxWallShape = (Autodesk.Revit.UI.ComboBox)(ribbonItemsStacked[2]); ComboBoxMemberData comboBoxMemberData = new ComboBoxMemberData("RectangleWall", "RectangleWall"); ComboBoxMember comboboxMember = comboboxWallShape.AddItem(comboBoxMemberData); comboboxMember.Image = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "RectangleWall.png"), UriKind.Absolute)); comboBoxMemberData = new ComboBoxMemberData("CircleWall", "CircleWall"); comboboxMember = comboboxWallShape.AddItem(comboBoxMemberData); comboboxMember.Image = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "CircleWall.png"), UriKind.Absolute)); comboBoxMemberData = new ComboBoxMemberData("TriangleWall", "TriangleWall"); comboboxMember = comboboxWallShape.AddItem(comboBoxMemberData); comboboxMember.Image = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "TriangleWall.png"), UriKind.Absolute)); comboBoxMemberData = new ComboBoxMemberData("SquareWall", "SquareWall"); comboboxMember = comboboxWallShape.AddItem(comboBoxMemberData); comboboxMember.Image = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "SquareWall.png"), UriKind.Absolute)); #endregion ribbonSamplePanel.AddSeparator(); #region Add a RadioButtonGroup for user to select WallType RadioButtonGroupData radioButtonGroupData = new RadioButtonGroupData("WallTypeSelector"); RadioButtonGroup radioButtonGroup = (RadioButtonGroup)(ribbonSamplePanel.AddItem(radioButtonGroupData)); ToggleButton toggleButton = radioButtonGroup.AddItem(new ToggleButtonData("Generic8", "Generic - 8\"", AddInPath, "Revit.SDK.Samples.Ribbon.CS.Dummy")); toggleButton.LargeImage = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "Generic8.png"), UriKind.Absolute)); toggleButton.Image = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "Generic8-S.png"), UriKind.Absolute)); toggleButton = radioButtonGroup.AddItem(new ToggleButtonData("ExteriorBrick", "Exterior - Brick", AddInPath, "Revit.SDK.Samples.Ribbon.CS.Dummy")); toggleButton.LargeImage = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "ExteriorBrick.png"), UriKind.Absolute)); toggleButton.Image = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "ExteriorBrick-S.png"), UriKind.Absolute)); #endregion //slide-out panel: ribbonSamplePanel.AddSlideOut(); #region add a Text box to set the mark for new wall TextBoxData testBoxData = new TextBoxData("WallMark"); Autodesk.Revit.UI.TextBox textBox = (Autodesk.Revit.UI.TextBox)(ribbonSamplePanel.AddItem(testBoxData)); textBox.Value = "new wall"; //default wall mark textBox.Image = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "WallMark.png"), UriKind.Absolute)); textBox.ToolTip = "Set the mark for new wall"; textBox.ShowImageAsButton = true; textBox.EnterPressed += new EventHandler<Autodesk.Revit.UI.Events.TextBoxEnterPressedEventArgs>(SetTextBoxValue); #endregion ribbonSamplePanel.AddSeparator(); #region Create a StackedButton which consisted of a PushButton (delete all the walls) and a PulldownButton (move all the walls in X or Y direction) PushButtonData deleteWallsButtonData = new PushButtonData("deleteWalls", "Delete Walls", AddInPath, "Revit.SDK.Samples.Ribbon.CS.DeleteWalls"); deleteWallsButtonData.ToolTip = "Delete all the walls created by the Create Wall tool."; deleteWallsButtonData.Image = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "DeleteWalls.png"), UriKind.Absolute)); PulldownButtonData moveWallsButtonData = new PulldownButtonData("moveWalls", "Move Walls"); moveWallsButtonData.ToolTip = "Move all the walls in X or Y direction"; moveWallsButtonData.Image = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "MoveWalls.png"), UriKind.Absolute)); // create stackable buttons IList<RibbonItem> ribbonItems = ribbonSamplePanel.AddStackedItems(deleteWallsButtonData, moveWallsButtonData); // add two push buttons as sub-items of the moveWalls PulldownButton. PulldownButton moveWallItem = ribbonItems[1] as PulldownButton; PushButton moveX = moveWallItem.AddPushButton(new PushButtonData("XDirection", "X Direction", AddInPath, "Revit.SDK.Samples.Ribbon.CS.XMoveWalls")); moveX.ToolTip = "move all walls 10 feet in X direction."; moveX.LargeImage = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "MoveWallsXLarge.png"), UriKind.Absolute)); PushButton moveY = moveWallItem.AddPushButton(new PushButtonData("YDirection", "Y Direction", AddInPath, "Revit.SDK.Samples.Ribbon.CS.YMoveWalls")); moveY.ToolTip = "move all walls 10 feet in Y direction."; moveY.LargeImage = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "MoveWallsYLarge.png"), UriKind.Absolute)); #endregion ribbonSamplePanel.AddSeparator(); application.ControlledApplication.DocumentCreated += new EventHandler<Autodesk.Revit.DB.Events.DocumentCreatedEventArgs>(DocumentCreated); }
/// <summary> /// Insert Level into ComboBox - LevelsSelector /// </summary> /// <param name="evnetArgs">Autodesk.Revit.DB.Events.DocumentCreatedEventArgs</param> public void DocumentCreated(object sender, Autodesk.Revit.DB.Events.DocumentCreatedEventArgs e) { uiApplication = new UIApplication(e.Document.Application); List<RibbonPanel> myPanels = uiApplication.GetRibbonPanels(); Autodesk.Revit.UI.ComboBox comboboxLevel = (Autodesk.Revit.UI.ComboBox)(myPanels[0].GetItems()[2]); if (null == comboboxLevel) { return; } FilteredElementCollector collector = new FilteredElementCollector(uiApplication.ActiveUIDocument.Document); ICollection<Element> founds = collector.OfClass(typeof(Level)).ToElements(); foreach (Element elem in founds) { Level level = elem as Level; ComboBoxMemberData comboBoxMemberData = new ComboBoxMemberData(level.Name, level.Name); ComboBoxMember comboboxMember = comboboxLevel.AddItem(comboBoxMemberData); comboboxMember.Image = new BitmapImage(new Uri(Path.Combine(ButtonIconsFolder, "LevelsSelector.png"), UriKind.Absolute)); } //refresh level list (in case user created new level after document created) comboboxLevel.DropDownOpened += new EventHandler<ComboBoxDropDownOpenedEventArgs>(AddNewLevels); }