Example #1
0
        public Result Execute(UIControlledApplication application, string tabName)
        {
#if Revit2020
            MainWindowHandle = application.MainWindowHandle;
            HwndSource hwndSource = HwndSource.FromHwnd(MainWindowHandle);
            RevitWindow = hwndSource.RootVisual as Window;
#endif
#if Revit2018
            try
            {
                MainWindowHandle = WindowHandleSearch.MainWindowHandle.Handle;
            }
            catch (Exception) { }
#endif
            string      assembly   = Assembly.GetExecutingAssembly().Location.Split(new string[] { "\\" }, StringSplitOptions.None).Last().Split('.').First();
            string      ribbonName = "Проверки";
            RibbonPanel panel      = application.CreateRibbonPanel(tabName, ribbonName);
            if (KPLN_Loader.Preferences.User.Department.Id == 4)
            {
                AddPushButtonData("Открыть менеджер проверок", "Серийная\nпроверка", "Запуск проверки выбранных документов на ошибки.", string.Format("{0}.{1}", assembly, "Commands.CommandOpenDialog"), panel, new Source.Source(Common.Collections.Icon.OpenManager), true);
            }
            AddPushButtonData("Открыть окно статистики", "Окно\ncтатистики", "Отображение статистики по документам, которые были проверены на ошибки.", string.Format("{0}.{1}", assembly, "Commands.CommandShowStatistics"), panel, new Source.Source(Common.Collections.Icon.Statistics), true);
            panel.AddSlideOut();
            if (KPLN_Loader.Preferences.User.Department.Id == 4)
            {
                AddPushButtonData("Параметры", "Параметры", "Редактирование пользовательских настроек.", string.Format("{0}.{1}", assembly, "Commands.CommandShowSettings"), panel, new Source.Source(Common.Collections.Icon.Preferences), true);
            }
            application.DialogBoxShowing += OnDialogBoxShowing;
            application.ControlledApplication.ApplicationInitialized += OnInitialized;
            application.ControlledApplication.FailuresProcessing     += OnFailureProcessing;
            application.ControlledApplication.DocumentOpened         += OnOpened;
            return(Result.Succeeded);
        }
Example #2
0
        private void CreateTableRibbon(UIControlledApplication uiApp, string tabName)
        {
            RibbonPanel panel = uiApp.CreateRibbonPanel(tabName, "Таблицы");

            PushButtonData dataRebarSketch = CreateButtonData("RebarSketch", "CommandCreatePictures3");

            dataRebarSketch.Text = "Вед-ть\nдеталей";
            panel.AddItem(dataRebarSketch);

            PushButtonData dataAutonumber = CreateButtonData("Autonumber", "CommandStart");

            panel.AddItem(dataAutonumber);

            PushButtonData dataCollapseRebarSchedule = CreateButtonData("CollapseRebarSchedule", "Command");

            dataCollapseRebarSchedule.Text = "Подчистить\nВРС";
            panel.AddItem(dataCollapseRebarSchedule);

            PushButtonData pbdRefreshSchedules = CreateButtonData("BatchPrintYay", "CommandRefreshSchedules");
            PushButtonData dataSchedulesTable  = CreateButtonData("SchedulesTable", "CommandCreateTable");
            PushButtonData dataRevisions       = CreateButtonData("RevisionClouds", "Command");

            panel.AddStackedItems(pbdRefreshSchedules, dataSchedulesTable, dataRevisions);

            panel.AddSlideOut();
            PushButtonData dataScetchConstructor = CreateButtonData("RebarSketch", "CommandFormGenerator");

            panel.AddItem(dataScetchConstructor);
        }
        /// <summary>
        /// Create our own ribbon panel with verious buttons
        /// for our exercise. We re-use commands defined in the
        /// Revit Intro Labs here. Cf. Section 3.8 (pp 46) of
        /// the Developers Guide.
        /// </summary>
        public void AddRibbonSampler(UIControlledApplication app)
        {
            // (1) create a ribbon tab and ribbon panel

            app.CreateRibbonTab("Ribbon Sampler");

            RibbonPanel panel = app.CreateRibbonPanel("Ribbon Sampler", "Ribbon Sampler");

            // Below are samplers of ribbon items. Uncomment
            // functions of your interest to see how it looks like

            // (2.1) add a simple push button for Hello World

            AddPushButton(panel);

            // (2.2) add split buttons for "Command Data", "DB Element" and "Element Filtering"

            AddSplitButton(panel);

            // (2.3) add pulldown buttons for "Command Data", "DB Element" and "Element Filtering"

            AddPulldownButton(panel);

            // (2.4) add radio/toggle buttons for "Command Data", "DB Element" and "Element Filtering"
            // we put it on the slide-out below.
            //AddRadioButton(panel);
            //panel.AddSeparator();

            // (2.5) add text box - TBD: this is used with the conjunction with event. Probably too complex for day one training.
            //  for now, without event.
            // we put it on the slide-out below.
            //AddTextBox(panel);
            //panel.AddSeparator();

            // (2.6) combo box - TBD: this is used with the conjunction with event. Probably too complex for day one training.
            // For now, without event. show two groups: Element Bascis (3 push buttons) and Modification/Creation (2 push button)

            AddComboBox(panel);

            // (2.7) stacked items - 1. hello world push button, 2. pulldown element bscis (command data, DB element, element filtering)
            // 3. pulldown modification/creation(element modification, model creation).

            AddStackedButtons_Complex(panel);

            // (2.8) slide out - if you don't have enough space, you can add additional space below the panel.
            // anything which comes after this will be on the slide out.

            panel.AddSlideOut();

            // (2.4) radio button - what it is

            AddRadioButton(panel);

            // (2.5) text box - what it is

            AddTextBox(panel);
        }
Example #4
0
        private void CreateVisibilitySwitcherCommandsOnRibbonAsSlideOut()
        {
            _ribbonPanel.AddSlideOut();
            PulldownButtonData pdbd =
                new PulldownButtonData("VisibiitySwitcher", "VisibiitySwitcher");
            PulldownButton pulldownButton = _ribbonPanel.AddItem(pdbd) as PulldownButton;

            foreach (var commandSetting in _settingsInterpreter.VisibilitySwitcherCommandSettings)
            {
                PushButtonData dynamicCommandPushButton =
                    CreateVisibilitySwitcherPushButtonDataFromSetting(commandSetting);
                dynamicCommandPushButton.ToolTip = commandSetting.VisibilityNameRegex;

                pulldownButton.AddPushButton(dynamicCommandPushButton);
            }
        }
        private void AddSlideOut(RibbonPanel panel)
        {
            string assembly = @"D:\Sample\HelloWorld\bin\Debug\Hello.dll";

            panel.AddSlideOut();

            // create some controls for the slide out
            PushButtonData b1 = new PushButtonData("ButtonName1", "Button 1",
                                                   assembly, "Hello.HelloButton");

            b1.LargeImage =
                new System.Windows.Media.Imaging.BitmapImage(new Uri(@"D:\Sample\HelloWorld\bin\Debug\39-Globe_32x32.png"));
            PushButtonData b2 = new PushButtonData("ButtonName2", "Button 2",
                                                   assembly, "Hello.HelloTwo");

            b2.LargeImage =
                new System.Windows.Media.Imaging.BitmapImage(new Uri(@"D:\Sample\HelloWorld\bin\Debug\39-Globe_16x16.png"));

            panel.AddItem(b1);
            panel.AddItem(b2);
        }
Example #6
0
        private void OnButtonCreate(UIControlledApplication application, RibbonPanel ribbonPanel, PanelInfo panel)
        {
            string executableLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            foreach (var button in panel.Buttons)
            {
                buttonFactory(ribbonPanel, executableLocation, button);
            }

            var slideout = panel.SlideOut;

            if (slideout == null || slideout.Count() == 0)
            {
                return;
            }

            ribbonPanel.AddSlideOut();

            foreach (var button in slideout)
            {
                buttonFactory(ribbonPanel, executableLocation, button);
            }
        }
Example #7
0
        public void AddElec_WTA_ELEC_Ribbon(UIControlledApplication a)
        {
            string ExecutingAssemblyPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
            string ExecutingAssemblyName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
            // create ribbon tab
            String thisNewTabName = "WTA-ELEC";

            try {
                a.CreateRibbonTab(thisNewTabName);
            } catch (Autodesk.Revit.Exceptions.ArgumentException) {
                // Assume error generated is due to "WTA" already existing
            }
            //   Add ribbon panels.
            String      thisNewPanelBe       = "Be This";
            RibbonPanel thisNewRibbonPanelBe = a.CreateRibbonPanel(thisNewTabName, thisNewPanelBe);

            String      thisNewPanelNamLFixt    = "Light Fixtures";
            RibbonPanel thisNewRibbonPanelLFixt = a.CreateRibbonPanel(thisNewTabName, thisNewPanelNamLFixt);

            String      thisNewPanelNameAim   = "Aiming Lights";
            RibbonPanel thisNewRibbonPanelAim = a.CreateRibbonPanel(thisNewTabName, thisNewPanelNameAim);

            //System.Windows.MessageBox.Show(a.GetRibbonPanels(thisNewTabName).Count.ToString());

            //   Create push buttons
            PushButtonData pbTwoPickTagLight  = new PushButtonData("TwoPickLightingTag", "Two Pick\nLighting Tag", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdTwoPickLightingTag");
            PushButtonData pbTwoPickTagSwitch = new PushButtonData("TwoPickSwitchTag", "Two Pick\nDevice Tag", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdTwoPickSwitchTag");
            PushButtonData pbTwoPickAimLight  = new PushButtonData("AimLight", " Aim ", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdTwoPickLightRot");
            PushButtonData pbAimManyLights    = new PushButtonData("AimManyLights", " Aim Many", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdAimManyLights");

            PushButtonData pbBeLighting        = new PushButtonData("BeLighting", "Lighting", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdBeLightingWorkSet");
            PushButtonData pbBePower           = new PushButtonData("BePower", "Power", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdBePowerWorkSet");
            PushButtonData pbBeAuxiliary       = new PushButtonData("BeAuxiliary", "Auxiliary", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdBeAuxiliaryWorkSet");
            PushButtonData pbSelOnlyLights     = new PushButtonData("SelOnlyLightFix", "Only Fixtures", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdPickOnlyLights");
            PushButtonData pbSelOnlyDevices    = new PushButtonData("SelOnlyDevices", "Only Devices", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdPickOnlyDevices");
            PushButtonData pbLightingReporter  = new PushButtonData("LRPT", "Room Picker", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdRoomLightingReporter");
            PushButtonData pbLightingTotReport = new PushButtonData("LRPTOT", "LPD Totalizer", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdRoomsLightPwrDensityReport");

            PushButtonData pbOCCDetTool = new PushButtonData("OCCDetTool", "OCC Det Tool", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdPlaceOCCSensorToolInstance");

            pbOCCDetTool.ToolTip = "Places Occupancy sensor detection tool.";
            string lDescOCCDetTool = "Requires a linked ceiling pick to set the sensor detection family tool's parameter. The tool adjusts the detection pattern " +
                                     "according to the ceiling height from the ceiling pick. Without a ceiling, place otherwise and manually change the instance parameter as needed. " +
                                     "Use the family's type selector to get the detection pattern you are interested in. " +
                                     "The tool is placed on a diagnostic workset that will be created if needed.";

            pbOCCDetTool.LongDescription = lDescOCCDetTool;
            pbOCCDetTool.ToolTipImage    = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".SENSDETLG.PNG");
            pbOCCDetTool.Image           = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".SENSDETSM.PNG");


            //   Set the large image shown on button
            //Note that the full image name is namespace_prefix + "." + the actual imageName);
            pbTwoPickTagLight.LargeImage  = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".TwoPickTag.png");
            pbTwoPickTagSwitch.LargeImage = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".TwoPickTagSwitch.png");

            // add button tips (when data, must be defined prior to adding button.)
            pbTwoPickTagLight.ToolTip  = "Places lighting tag in two or less picks.";
            pbTwoPickTagSwitch.ToolTip = "Places device tag in two or less picks.";

            pbTwoPickAimLight.ToolTip = "2D Aims a non hosted light.";
            pbAimManyLights.ToolTip   = "2D Aims a selection of non hosted lights.";

            pbBeLighting.ToolTip     = "Switch to Lighting Workset.";
            pbBePower.ToolTip        = "Switch to Power Workset.";
            pbBeAuxiliary.ToolTip    = "Switch to Auxiliary Workset.";
            pbSelOnlyLights.ToolTip  = "Selecting only lighting fixtures.";
            pbSelOnlyDevices.ToolTip = "Selecting only lighting devices.";

            pbLightingReporter.ToolTip = "Reports on all lighting in a room.";

            string lDescpbTwoPickTagLight = "Places the lighting tag in two picks.\nThe first pick selects the light fixture.\nThe second pick is the tag location.";
            string lDescpbTwoPickAimLight = "Pick a light.\nThen pick where it is supposed to aim.";
            string lDescpbAimManyLights   = "Select a bunch of lights.\nThen pick the one spot where they all should aim towards.";
            string lDescpb3DAim           = "The special element has to be a Sprinkler category family instance.";
            string lDescSelOnlyLights     = "Swipe over anything. Only lighting fixtures are selected.";
            string lDescSelOnlyDevices    = "Swipe over anything. Only lighting devices are selected.";
            string lDescBeLighting        = "If you can't beat'm, join'm. Become Elec Lighting workset.";
            string lDescBePower           = "If you can't beat'm, join'm. Become Elec Power workset.";
            string lDescBeAuxiliary       = "If you can't beat'm, join'm. Become Elec Auxiliary workset.";

            pbTwoPickTagLight.LongDescription = lDescpbTwoPickTagLight;
            pbTwoPickAimLight.LongDescription = lDescpbTwoPickAimLight;
            pbAimManyLights.LongDescription   = lDescpbAimManyLights;
            pbSelOnlyLights.LongDescription   = lDescSelOnlyLights;
            pbSelOnlyDevices.LongDescription  = lDescSelOnlyDevices;
            pbBeLighting.LongDescription      = lDescBeLighting;
            pbBePower.LongDescription         = lDescBePower;
            pbBeAuxiliary.LongDescription     = lDescBeAuxiliary;

            // add to ribbon panelA
            List <RibbonItem> projectButtonsA = new List <RibbonItem>();

            projectButtonsA.AddRange(thisNewRibbonPanelBe.AddStackedItems(pbBeLighting, pbBePower, pbBeAuxiliary));

            // add to ribbon panelB
            thisNewRibbonPanelLFixt.AddItem(pbTwoPickTagLight);
            thisNewRibbonPanelLFixt.AddItem(pbTwoPickTagSwitch);
            thisNewRibbonPanelLFixt.AddSeparator();
            List <RibbonItem> projectButtonsB = new List <RibbonItem>();

            projectButtonsB.AddRange(thisNewRibbonPanelLFixt.AddStackedItems(pbSelOnlyLights, pbSelOnlyDevices));
            thisNewRibbonPanelLFixt.AddSeparator();
            List <RibbonItem> projectButtonsBB = new List <RibbonItem>();

            projectButtonsBB.AddRange(thisNewRibbonPanelLFixt.AddStackedItems(pbLightingReporter, pbOCCDetTool, pbLightingTotReport));

            // add to ribbon panelC
            List <RibbonItem> projectButtonsC = new List <RibbonItem>();

            projectButtonsC.AddRange(thisNewRibbonPanelAim.AddStackedItems(pbTwoPickAimLight, pbAimManyLights));
            //projectButtons.AddRange(thisNewRibbonPanel.AddStackedItems(pbData2DN, pbData4DN, pbDataAPN));

            thisNewRibbonPanelBe.AddSlideOut();
            PushButtonData bInfo = new PushButtonData("Info", "Info", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdOpenDocFolder");

            bInfo.ToolTip    = "See the help document regarding this.";
            bInfo.LargeImage = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".InfoLg.png");
            thisNewRibbonPanelBe.AddItem(bInfo);

            thisNewRibbonPanelLFixt.AddSlideOut();
            thisNewRibbonPanelLFixt.AddItem(bInfo);
        } // AddMech_WTA_Elec_Ribbon
Example #8
0
        /// <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>
 /// Adds a slide out in the current panel.
 /// </summary>
 public void AddSlideOut()
 {
     panel.AddSlideOut();
 }
Example #10
0
        public void Add_WTA_FP_Ribbon(UIControlledApplication a)
        {
            string ExecutingAssemblyPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
            string ExecutingAssemblyName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
            // create ribbon tab
            String thisTabNameFP = "WTA-FP";

            try {
                a.CreateRibbonTab(thisTabNameFP);
            } catch (Autodesk.Revit.Exceptions.ArgumentException) {
                // Assume error generated is due to "WTA" already existing
            }

            #region Add ribbon panels.
            //   Add ribbon panels.
            String      thisPanelNamBe    = "Be This";
            RibbonPanel thisRibbonPanelBe = a.CreateRibbonPanel(thisTabNameFP, thisPanelNamBe);

            String      thisPanelNameSprinklers   = "Sprinklers";
            RibbonPanel thisRibbonPanelSprinklers = a.CreateRibbonPanel(thisTabNameFP, thisPanelNameSprinklers);

            String      thisPanelNameAiming   = "3d Aiming";
            RibbonPanel thisRibbonPanelAiming = a.CreateRibbonPanel(thisTabNameFP, thisPanelNameAiming);
            #endregion

            ///Note that the full image name is namespace_prefix + "." + the actual imageName);
            ///pushButton.LargeImage = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), "PlunkOMaticTCOM.QVis.png");

            //   Create push button in this ribbon panel
            PushButtonData pbDataSprnkConc = new PushButtonData("SprnkConc", "Concealed", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdPlaceConcealedSprinklerInstance");
            PushButtonData pbDataSprnkRec  = new PushButtonData("SprnkRec", "Recessed", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdPlaceRecessedSprinklerInstance");
            PushButtonData pbDataSprnkPend = new PushButtonData("SprnkPend", "Pendent", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdPlacePendentSprinklerInstance");
            PushButtonData pbDataSprnkUp   = new PushButtonData("SprnkUp", "Upright", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdPlaceUprightSprinklerInstance");
            PushButtonData pbDataOppArray  = new PushButtonData("OppArray", "Design Array", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdPlaceSprinklerArrayTool");
            PushButtonData pbDataOppArea   = new PushButtonData("OppArea", "Oper Area", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdPlaceSprinklerOperAreaTool");

            PushButtonData pbDataSelectOnlySprink = new PushButtonData("SelSprnk", "PickOnly", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdPickSprinksOnly");

            PushButtonData pbDataSetSprinkOps = new PushButtonData("SprnkOps", "Sprnk Ops", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdResetThisSprnkOps");
            pbDataSetSprinkOps.ToolTip = "Set design tool sprinkler spacing data.";
            string lDescDT = "The Design Array and Oper Area layout tool families take parameters";
            lDescDT += " that control the sprinkler operation area, spacing and array sizes. Those";
            lDescDT += " parameters can be set ahead of time as a persistent user settings so that";
            lDescDT += " it is not necessary to use the Revit properties setter to affect the desired values.";
            lDescDT += " The Sprnk Ops tool sets those values and allows you to apply them to a pick.";
            pbDataSetSprinkOps.LongDescription = lDescDT;
            pbDataSetSprinkOps.LargeImage      = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".SprnkOps.png");
            pbDataSetSprinkOps.ToolTipImage    = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".SetOpArea.PNG");


            PushButtonData pbBeFP = new PushButtonData("BeFP", "FireP", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdBeFPWorkSet");
            pbBeFP.ToolTip = "Switch to Fire Protection Workset.";
            string lDescBeFP = "If you can't beat'm, join'm. Become FIRE PROTECTION workset.";
            pbBeFP.LongDescription = lDescBeFP;

            //   Set the large image shown on button
            //Note that the full image name is namespace_prefix + "." + the actual imageName);
            pbDataSprnkUp.Image   = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".Upright.png");
            pbDataSprnkConc.Image = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".Concealed.png");
            pbDataSprnkPend.Image = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".Pendent.png");
            pbDataSprnkRec.Image  = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".Recessed.png");
            pbDataOppArea.Image   = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".OpArea.png");
            pbDataOppArray.Image  = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".OpArray.png");

            pbDataSelectOnlySprink.Image      = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".PickOnlySprnk16x16.png");
            pbDataSelectOnlySprink.LargeImage = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".PickOnlySprnk32x32.png");


            // add button tips (when data, must be defined prior to adding button.)
            pbDataSprnkConc.ToolTip = "Concealed Sprinkler";
            pbDataSprnkRec.ToolTip  = "Recessed Sprinkler";
            pbDataSprnkPend.ToolTip = "Pendent Sprinkler";
            pbDataSprnkUp.ToolTip   = "Upright Sprinkler";
            pbDataOppArea.ToolTip   = "Operation Area Tool";
            pbDataOppArray.ToolTip  = "Array Design Tool";

            pbDataSelectOnlySprink.ToolTip = "Pick Only Sprinklers";

            string lDesc          = "Places a sprinkler at the ceiling elevation set by picking a ceiling (if prompted).\n\n\u00A7 Workset will be FIRE PROTECTION.";
            string lDescTool      = "Places a sprinkler design tool at the ceiling elevation set by picking a ceiling.\n\n\u00A7 Workset will be FIRE PROTECTION.";
            string lDescPickOnlyS = "Swipe over anything. Only sprinklers are selected.";

            pbDataSprnkConc.LongDescription = lDesc;
            pbDataSprnkRec.LongDescription  = lDesc;
            pbDataSprnkPend.LongDescription = lDesc;
            pbDataSprnkUp.LongDescription   = lDesc;
            pbDataOppArray.LongDescription  = lDescTool;
            pbDataOppArea.LongDescription   = lDescTool;

            pbDataSelectOnlySprink.LongDescription = lDescPickOnlyS;

            RadioButtonGroupData rbgdSTD_EC = new RadioButtonGroupData("rbgdSTD_EC");
            RadioButtonGroup     rbgSTD_EC  = thisRibbonPanelSprinklers.AddItem(rbgdSTD_EC) as RadioButtonGroup;
            ToggleButtonData     tbSTD      = new ToggleButtonData("tbSTD", " STD ",
                                                                   ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdSetAs_STD");
            ToggleButtonData tbEC = new ToggleButtonData("tbEC", " EC ",
                                                         ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdSetAs_EC");
            tbSTD.ToolTip    = "Standard Coverage \nsprinklers will be placed.";
            tbEC.ToolTip     = "Extended Coverage \nsprinklers will be placed.";
            tbEC.LargeImage  = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".bt_EC.png");
            tbSTD.LargeImage = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".bt_STD.png");
            rbgSTD_EC.AddItem(tbSTD);
            rbgSTD_EC.AddItem(tbEC);

            // Not working
            //pbDataToggle_STD_EC = new PushButtonData("togbutdata_TOG_STD_EC", "STD/EC", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdTogState_STD_EC");
            //pbDataToggle_STD_EC.ToolTip = "Standard Coverage/Extended Coverage";  // undetermined at this point
            //pbDataToggle_STD_EC.LargeImage = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".bt_STD24x24.png");
            //PushButton pushbutdata_TOG_STD_EC = thisNewRibbonPanel.AddItem(pbDataToggle_STD_EC) as PushButton;

            PushButtonData b1x1 = new PushButtonData("OSET_1x1", "1x1", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdSetOffsetState1x1");
            PushButtonData b2x1 = new PushButtonData("OSET_2x1", "2x1", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdSetOffsetState2x1");
            PushButtonData b3x1 = new PushButtonData("OSET_3x1", "3x1", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdSetOffsetState3x1");
            PushButtonData b1x2 = new PushButtonData("OSET_1x2", "1x2", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdSetOffsetState1x2");
            PushButtonData b1x3 = new PushButtonData("OSET_1x3", "1x3", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdSetOffsetState1x3");
            PushButtonData b0x0 = new PushButtonData("OSET_0x0", "0x0", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdSetOffsetState0x0");

            b1x1.LargeImage = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".B1x1.png");
            b2x1.LargeImage = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".B2x1.png");
            b3x1.LargeImage = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".B3x1.png");
            b1x2.LargeImage = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".B1x2.png");
            b1x3.LargeImage = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".B1x3.png");
            b0x0.LargeImage = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".B0x0.png");

            b1x1.ToolTip = "Item placement will be offset\n" +
                           "1' by 1' from the pick point.\n" +
                           "Think lay-in ceiling tile.";
            b2x1.ToolTip = "Item placement will be offset\n" +
                           "2' by 1' from the pick point.\n" +
                           "Think lay-in ceiling tile.";
            b3x1.ToolTip = "Item placement will be offset\n" +
                           "3' by 1' from the pick point.\n" +
                           "Think lay-in ceiling tile.";
            b1x2.ToolTip = "Item placement will be offset\n" +
                           "1' by 2' from the pick point.\n" +
                           "Think lay-in ceiling tile.";
            b1x3.ToolTip = "Item placement will be offset\n" +
                           "1' by 3' from the pick point.\n" +
                           "Think lay-in ceiling tile.";
            b0x0.ToolTip = "Item placement will be at the\n" +
                           "pick point.";

            SplitButtonData sbOffSetData = new SplitButtonData("splitOffSets", "Loc");
            SplitButton     sbOffSet     = thisRibbonPanelSprinklers.AddItem(sbOffSetData) as SplitButton;
            sbOffSet.AddPushButton(b1x1);
            sbOffSet.AddPushButton(b2x1);
            sbOffSet.AddPushButton(b3x1);
            sbOffSet.AddPushButton(b1x2);
            sbOffSet.AddPushButton(b1x3);
            sbOffSet.AddPushButton(b0x0);


            #region 3dAiming
            PushButtonData pbReset3dAiming  = new PushButtonData("Reset3dAim", "Reset 3D Aiming", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdAimResetRotateOne3DMany");
            PushButtonData pbSingle3dAiming = new PushButtonData("Single3DAim", "Single 3D Aim", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdSprinkRot3D");
            PushButtonData pbMany3dAiming   = new PushButtonData("Many3dAim", "Many 3D Aim", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdSprinkRot3DMany");

            pbReset3dAiming.ToolTip = "Reset 3D aimed objects\n" +
                                      "to zero state.";
            pbSingle3dAiming.ToolTip = "3D aim a single object\n" +
                                       "to a target point.";
            pbMany3dAiming.ToolTip = "3D aim multiple objects\n" +
                                     "to the same target point.";
            #endregion

            // add to ribbon panelA
            // List<RibbonItem> projectButtonsBe = new List<RibbonItem>();
            // projectButtonsBe.AddRange(thisRibbonPanelBe.AddStackedItems(pbBeFP, another etc));
            thisRibbonPanelBe.AddItem(pbBeFP);

            // add to ribbon panel
            List <RibbonItem> sprnkButtons = new List <RibbonItem>();
            sprnkButtons.AddRange(thisRibbonPanelSprinklers.AddStackedItems(pbDataSprnkConc, pbDataSprnkRec, pbDataSprnkPend));
            sprnkButtons.AddRange(thisRibbonPanelSprinklers.AddStackedItems(pbDataSprnkUp, pbDataOppArray, pbDataOppArea));

            thisRibbonPanelSprinklers.AddSeparator();
            PushButton pushButtonSprnkOps = thisRibbonPanelSprinklers.AddItem(pbDataSetSprinkOps) as PushButton;

            thisRibbonPanelSprinklers.AddSeparator();
            PushButton pushButtonSelSprnk = thisRibbonPanelSprinklers.AddItem(pbDataSelectOnlySprink) as PushButton;

            // This is to another panel. No separator needed.
            List <RibbonItem> aimerButtons = new List <RibbonItem>();
            aimerButtons.AddRange(thisRibbonPanelAiming.AddStackedItems(pbSingle3dAiming, pbMany3dAiming, pbReset3dAiming));

            /// Anything added after slideout it declared can only be in the slideout
            thisRibbonPanelBe.AddSlideOut();
            PushButtonData bInfo = new PushButtonData("Info", "Info", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdOpenDocFolder");
            bInfo.ToolTip    = "See the help document regarding this.";
            bInfo.LargeImage = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".InfoLg.png");
            thisRibbonPanelBe.AddItem(bInfo);
            thisRibbonPanelSprinklers.AddSlideOut();
            thisRibbonPanelSprinklers.AddItem(bInfo);
        } // AddRibbon
Example #11
0
        public void AddMech_WTA_MECH_Ribbon(UIControlledApplication a)
        {
            string ExecutingAssemblyPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
            string ExecutingAssemblyName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
            // create ribbon tab
            String thisNewTabName = "WTA-MECH";

            try {
                a.CreateRibbonTab(thisNewTabName);
            } catch (Autodesk.Revit.Exceptions.ArgumentException) {
                // Assume error generated is due to "WTA" already existing
            }

            //   Add ribbon panels.
            String      thisPanelNamBe    = "Be This";
            RibbonPanel thisRibbonPanelBe = a.CreateRibbonPanel(thisNewTabName, thisPanelNamBe);

            String      thisPanelNameSensor   = " Sensor ";
            RibbonPanel thisRibbonPanelSensor = a.CreateRibbonPanel(thisNewTabName, thisPanelNameSensor);
            //   Set the large image shown on button
            //Note that the full image name is namespace_prefix + "." + the actual imageName);
            //pushButton.LargeImage = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".QVis.png");

            //   Create push button in this ribbon panel
            // Buttons for Sensor/Unit No leader  - these will be used in a split button stack
            PushButtonData pbMechStatUnit1 = new PushButtonData("SensForUnit1", "Sens for\nUnit ID/#", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdPlaceStatForMechUnitInstance1");
            PushButtonData pbMechStatUnit2 = new PushButtonData("SensForUnit2", "Sens for\nUnit #", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdPlaceStatForMechUnitInstance2");
            // The tool settings buttons
            PushButtonData pbMechStatUnitSet1 = new PushButtonData("SensForUnitSet1", "Setting 1", ExecutingAssemblyPath, ExecutingAssemblyName + ".MechStatUnitSettings1");
            PushButtonData pbMechStatUnitSet2 = new PushButtonData("SensForUnitSet2", "Setting 2", ExecutingAssemblyPath, ExecutingAssemblyName + ".MechStatUnitSettings2");

            // Buttons for Sensor/Unit With leader - these will be used in a split button stack
            PushButtonData pbMechStatUnitOff1 = new PushButtonData("SensForUnitOff1", "Sens w/L\nfor Unit ID/#", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdPlaceStatOffsetForMechUnitInstance1");
            PushButtonData pbMechStatUnitOff2 = new PushButtonData("SensForUnitOff2", "Sens w/L\nfor Unit #", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdPlaceStatOffsetForMechUnitInstance2");
            // The tool settings buttons
            PushButtonData pbMechStatUnitOffSet1 = new PushButtonData("SensForUnitOffSet1", "Setting 1", ExecutingAssemblyPath, ExecutingAssemblyName + ".MechStatUnitOffSettings1");
            PushButtonData pbMechStatUnitOffSet2 = new PushButtonData("SensForUnitOffSet2", "Setting 2", ExecutingAssemblyPath, ExecutingAssemblyName + ".MechStatUnitOffSettings2");

            // Buttons for ID/# tag - these will be used in a split button stack
            PushButtonData pbMechStatTag1 = new PushButtonData("Sens IDT", "ID/# Tag", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdTwoPickMechSensorTagEuip1");
            PushButtonData pbMechStatTag2 = new PushButtonData("Sens IDO", "# Tag", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdTwoPickMechSensorTagEuip2");


            // Buttons for ID/# Offset tag - these will be used in a split button stack
            PushButtonData pbMechStatTagOff1 = new PushButtonData("Sens OffsetT", "ID/# Offset", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdTwoPickMechSensorTagOffEuip1");
            PushButtonData pbMechStatTagOff2 = new PushButtonData("Sens OffsetO", "# Offset", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdTwoPickMechSensorTagOffEuip2");


            PushButtonData pbBeMechHVAC = new PushButtonData("BeMechHVAC", "HVAC", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdBeMECH_HVACWorkSet");

            pbBeMechHVAC.ToolTip = "Switch to Mech HVAC Workset.";
            string lDescBeMechHVAC = "If you can't beat'm, join'm. Become MECH HVAC workset.";

            pbBeMechHVAC.LongDescription = lDescBeMechHVAC;

            // Split buttons
            SplitButtonData sbMSU     = new SplitButtonData("sbMSU", "Sens\nfor Unit");
            SplitButtonData sbMSUO    = new SplitButtonData("sbMSUO", "Sens w/L\nfor Unit");
            SplitButtonData sbSTagReg = new SplitButtonData("sbSensTag", "Split Sens ID");
            SplitButtonData sbSTagOff = new SplitButtonData("sbSensTagOff", "Split Sens Offset");

            PushButtonData pbMechSpinStat = new PushButtonData("Sens Spin", "Sens Spin", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdSpinStat");
            PushButtonData pbMechTogSym   = new PushButtonData("Sens Symb", "Sens Symb", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdSymbStat");

            //   Set the large image shown on button
            //Note that the full image name is namespace_prefix + "." + the actual imageName);
            pbMechStatUnit1.LargeImage    = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".TStatUnit_1.png");
            pbMechStatUnitOff1.LargeImage = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".TStatUnitO_1.png");
            pbMechStatUnit2.LargeImage    = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".TStatUnit_2.png");
            pbMechStatUnitOff2.LargeImage = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".TStatUnitO_2.png");

            pbMechStatTag1.LargeImage    = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".SensTag_IDNO.png");
            pbMechStatTag2.LargeImage    = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".SensTag_NO.png");
            pbMechStatTagOff1.LargeImage = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".SensOffTag_IDNO.png");
            pbMechStatTagOff2.LargeImage = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".SensOffTag_NO.png");

            // add button tips (when data, must be defined prior to adding button.)
            pbMechStatUnit1.ToolTip    = "Places a Sensor Stat for mechanical equip with equip. tag.";
            pbMechStatUnitOff1.ToolTip = "Places a Sensor Stat with leader for mechanical equip with equip. tag.";
            pbMechStatUnit2.ToolTip    = "Places a Sensor Stat for mechanical equip with equip. tag.";
            pbMechStatUnitOff2.ToolTip = "Places a Sensor Stat with leader for mechanical equip with equip. tag.";
            pbMechStatTag1.ToolTip     = "Places ID and number equipment tag that is for Sensors.";
            pbMechStatTagOff1.ToolTip  = "Places offset Sensor symbol with ID and number equipment tag that is ID for Sensors.";
            pbMechStatTag2.ToolTip     = "Places number only equipment tag that is ID for Sensors.";
            pbMechStatTagOff2.ToolTip  = "Places offset Sensor symbol with number only equipment tag that is ID for Sensors.";

            pbMechSpinStat.ToolTip = "Toggles Horizontal/Vertical parameter value.";
            pbMechTogSym.ToolTip   = "Toggles Sensor symbol visibility.";

            string lDescMechStatUnit =
                "First pick is the Sensor location."
                + "\nSecond pick selects the mechanical equipment the Sensor is client to."
                + "\nThird pick selects the mechanical equipment Sensor ID text location at the Sensor. This is a Tag on the mechanical equipment.";
            string lDescMechStatUnitOff =
                "Places a Sensor for mechanical equipment in four picks."
                + "\nFirst pick is the Sensor location. Ignore the symbol. It will be turned off later."
                + "\nSecond pick is for the offset Sensor tag symbol location."
                + "\nThird pick selects the mechanical equipment the Sensor is client to."
                + "\nLast pick selects the mechanical equipment Sensor ID text location at the Sensor. This is a Tag on the mechanical equipment.";
            string lDescMechStatTag =
                "First pick is the mechanical equipment the Sensor is client to."
                + "\nLast pick selects the mechanical equipment Sensor ID text location at the Sensor. This is a Tag on the mechanical equipment.";
            string lDescMechStatTagOff = "First pick is the Sensor to change."
                                         + "\nSecond pick is for the Sensor offset symbol location."
                                         + "\nIf needed, third pick selects the mechanical equipment the Sensor is client to. Otherwise press Esc to exit."
                                         + "\nLast pick selects the mechanical equipment Sensor ID text location at the Sensor. This is a Tag on the mechanical equipment.";

            pbMechStatUnit1.LongDescription    = lDescMechStatUnit;
            pbMechStatUnitOff1.LongDescription = lDescMechStatUnitOff;
            pbMechStatUnit2.LongDescription    = lDescMechStatUnit;
            pbMechStatUnitOff2.LongDescription = lDescMechStatUnitOff;
            pbMechStatTag1.LongDescription     = lDescMechStatTag;
            pbMechStatTagOff1.LongDescription  = lDescMechStatTagOff;
            pbMechStatTag2.LongDescription     = lDescMechStatTag;
            pbMechStatTagOff2.LongDescription  = lDescMechStatTagOff;


            //String thisPanelGenScripName = "GenScrip";
            //RibbonPanel thisPanelGenScrip = a.CreateRibbonPanel(thisNewTabName, thisPanelGenScripName);

            //ComboBoxData CB1Data = new ComboBoxData("11111");
            //ComboBoxData CB2Data = new ComboBoxData("22222");
            //IList<RibbonItem> cnt1Stacked = thisPanelGenScrip.AddStackedItems(CB1Data, CB2Data);

            //Autodesk.Revit.UI.ComboBox combo1 = cnt1Stacked[0] as Autodesk.Revit.UI.ComboBox;

            //Autodesk.Revit.UI.ComboBox combo2 = cnt1Stacked[1] as Autodesk.Revit.UI.ComboBox;

            //ComboBoxMemberData SDD11 = new ComboBoxMemberData("CB1_01", "Item for CB1_01 item(SDD11)");
            //ComboBoxMemberData SDD12 = new ComboBoxMemberData("CB1_02", "Item for CB1_02 item(SDD1)");

            //ComboBoxMember cb1Mem11 = combo1.AddItem(SDD11);
            //ComboBoxMember cb1Mem12 = combo1.AddItem(SDD12);

            //ComboBoxMemberData SDD21 = new ComboBoxMemberData("CB2_01", "Item for CB2_01 item(SDD21)");
            //ComboBoxMemberData SDD22 = new ComboBoxMemberData("CB2_02", "Item for CB2_02 item(SDD22)");

            //ComboBoxMember cb1Mem21 = combo2.AddItem(SDD21);
            //ComboBoxMember cb1Mem22 = combo2.AddItem(SDD22);

            //combo1.CurrentChanged +=
            //    new EventHandler<Autodesk.Revit.UI.Events.ComboBoxCurrentChangedEventArgs>(ProcessComboChange);

            //combo2.CurrentChanged +=
            //    new EventHandler<Autodesk.Revit.UI.Events.ComboBoxCurrentChangedEventArgs>(ProcessComboChange);


            // add to ribbon panelA
            // List<RibbonItem> projectButtonsBe = new List<RibbonItem>();
            // projectButtonsBe.AddRange(thisRibbonPanelBe.AddStackedItems(pbBeMechHVAC));
            thisRibbonPanelBe.AddItem(pbBeMechHVAC);

            // assemble split buttons and add to ribbon
            sb_MU = thisRibbonPanelSensor.AddItem(sbMSU) as SplitButton;
            sb_MU.AddPushButton(pbMechStatUnit1);
            sb_MU.AddPushButton(pbMechStatUnit2);
            sb_MU.AddPushButton(pbMechStatUnitSet1);
            sb_MU.AddPushButton(pbMechStatUnitSet2);

            sb_MUO = thisRibbonPanelSensor.AddItem(sbMSUO) as SplitButton;
            sb_MUO.AddPushButton(pbMechStatUnitOff1);
            sb_MUO.AddPushButton(pbMechStatUnitOff2);
            sb_MUO.AddPushButton(pbMechStatUnitOffSet1);
            sb_MUO.AddPushButton(pbMechStatUnitOffSet2);

            thisRibbonPanelSensor.AddSeparator();

            // assemble split buttons and add to ribbon
            SplitButton sbT = thisRibbonPanelSensor.AddItem(sbSTagReg) as SplitButton;

            sbT.AddPushButton(pbMechStatTag1);
            sbT.AddPushButton(pbMechStatTag2);

            SplitButton sbOffT = thisRibbonPanelSensor.AddItem(sbSTagOff) as SplitButton;

            sbOffT.AddPushButton(pbMechStatTagOff1);
            sbOffT.AddPushButton(pbMechStatTagOff2);

            thisRibbonPanelSensor.AddSeparator();
            List <RibbonItem> ribbonItems = new List <RibbonItem>();

            ribbonItems.AddRange(thisRibbonPanelSensor.AddStackedItems(pbMechSpinStat, pbMechTogSym));


            thisRibbonPanelBe.AddSlideOut();
            PushButtonData bInfo = new PushButtonData("Info", "Info", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdOpenDocFolder");

            bInfo.ToolTip    = "See the help document regarding this.";
            bInfo.LargeImage = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".InfoLg.png");
            thisRibbonPanelBe.AddItem(bInfo);

            thisRibbonPanelSensor.AddSlideOut();
            thisRibbonPanelSensor.AddItem(bInfo);
        } // AddMech_WTA_MECH_Ribbon
Example #12
0
        public void AddTCOMDrops_WTA_TCOM_Ribbon(UIControlledApplication a)
        {
            string ExecutingAssemblyPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
            string ExecutingAssemblyName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
            // create ribbon tab
            String thisNewTabName = "WTA-TCOM";

            try {
                a.CreateRibbonTab(thisNewTabName);
            } catch (Autodesk.Revit.Exceptions.ArgumentException) {
                // Assume error generated is due to "WTA" already existing
            }
            //   Create a push button in the ribbon panel
            //PushButtonData pbData = new PushButtonData("QVis", "   QVis   ", ExecutingAssemblyPath, ExecutingAssemblyName + ".QVisCommand");
            //   Add new ribbon panel.
            String      thisNewPanelName       = "TCOM Drops";
            RibbonPanel thisNewRibbonPanelTCOM = a.CreateRibbonPanel(thisNewTabName, thisNewPanelName);
            // add button to ribbon panel
            //PushButton pushButton = thisNewRibbonPanel.AddItem(pbData) as PushButton;
            //   Set the large image shown on button
            //Note that the full image name is namespace_prefix + "." + the actual imageName);
            //pushButton.LargeImage = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(),  ExecutingAssemblyName + ".QVis.png");


            // provide button tips
            //pushButton.ToolTip = "Floats a form with buttons to toggle visibilities.";
            //pushButton.LongDescription = "On this form, the way the buttons look indicate the current visibility status.";

            //   Create push button in this ribbon panel
            PushButtonData pbData2DH     = new PushButtonData("2D H", "2D H", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdPlaceTComDrop2DHInstance");
            PushButtonData pbData4DH     = new PushButtonData("4D H", "4D H", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdPlaceTComDrop4DHInstance");
            PushButtonData pbDataAPH     = new PushButtonData("AP H", "AP H", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdPlaceTComDropAPHInstance");
            PushButtonData pbData2DN     = new PushButtonData(" 2D F ", " 2D F ", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdPlaceTComDrop2DNHInstance");
            PushButtonData pbData4DN     = new PushButtonData(" 4D F ", " 4D F ", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdPlaceTComDrop4DNHInstance");
            PushButtonData pbDataAPN     = new PushButtonData(" AP F ", " AP F ", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdPlaceTComDropAPNHInstance");
            PushButtonData pbData2PTTAG  = new PushButtonData(" 2PT\nTag ", " 2PT\nTag ", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdTwoPickTag");
            PushButtonData pbDataMtchTAG = new PushButtonData(" Match\nTag ", " Match\nTag ", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdMatchParamterForTCOMDropTag");


            //   Set the large image shown on button
            //Note that the full image name is namespace_prefix + "." + the actual imageName);
            pbData2PTTAG.LargeImage  = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".TagDrop.png");
            pbDataMtchTAG.LargeImage = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".MtchTagDrop.png");
            pbData2DN.Image          = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".TagDrop2Dsmall.png");
            pbData2DH.Image          = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".TagDrop2Dsmall.png");
            pbData4DN.Image          = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".TagDrop4Dsmall.png");
            pbData4DH.Image          = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".TagDrop4Dsmall.png");
            pbDataAPN.Image          = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".TagDropAPsmall.png");
            pbDataAPH.Image          = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".TagDropAPsmall.png");


            // add button tips (when data, must be defined prior to adding button.)
            pbData2DH.ToolTip     = "2D Hosted Drop";
            pbData4DH.ToolTip     = "4D Hosted Drop";
            pbDataAPH.ToolTip     = "AP Hosted Drop";
            pbData2DN.ToolTip     = "2D Non Hosted (Free) Drop";
            pbData4DN.ToolTip     = "4D Non Hosted (Free) Drop";
            pbDataAPN.ToolTip     = "AP Non Hosted (Free) Drop";
            pbData2PTTAG.ToolTip  = "Tag a drop with two picks.";
            pbDataMtchTAG.ToolTip = "Match one tag value to another.";

            string lDesc        = " => Places a drop of the INSTANCE value indicated and then prompts for the TAG location.\n\n\u00A7Workset will be TCOM.";
            string lDesc2PTTAG  = " => Tags an existing drop with two picks.\nFirst pick selects drop.\nSecond pick is tag location.\nPress ESC to exit the command.";
            string lDescMtchTAG = " => Matches the drop instance tag value by first picking the example tag and then picking the target drop instances.\nPress ESC to exit the command.";

            pbData2DH.LongDescription     = pbData2DH.ToolTip + lDesc;
            pbData4DH.LongDescription     = pbData4DH.ToolTip + lDesc;
            pbDataAPH.LongDescription     = pbDataAPH.ToolTip + lDesc;
            pbData2DN.LongDescription     = pbData2DN.ToolTip + lDesc;
            pbData4DN.LongDescription     = pbData4DN.ToolTip + lDesc;
            pbDataAPN.LongDescription     = pbDataAPN.ToolTip + lDesc;
            pbData2PTTAG.LongDescription  = lDesc2PTTAG;
            pbDataMtchTAG.LongDescription = lDescMtchTAG;

            // add button to ribbon panel
            thisNewRibbonPanelTCOM.AddItem(pbData2PTTAG);
            List <RibbonItem> projectButtons = new List <RibbonItem>();

            projectButtons.AddRange(thisNewRibbonPanelTCOM.AddStackedItems(pbData2DH, pbData4DH, pbDataAPH));
            projectButtons.AddRange(thisNewRibbonPanelTCOM.AddStackedItems(pbData2DN, pbData4DN, pbDataAPN));
            thisNewRibbonPanelTCOM.AddItem(pbDataMtchTAG);

            /// Once there is a slideout, all new items go in it.
            /// It is not possbile to get back to the panel panel.
            thisNewRibbonPanelTCOM.AddSlideOut();

            #region TCOM Info
            PushButtonData bInfoTCOM = new PushButtonData("Info", "Info", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdOpenDocFolder");
            bInfoTCOM.ToolTip = "See the TCOM help document.";
            bInfoTCOM.Image   = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".InfoSm.png");
            #endregion

            #region pbTCOMSettings
            PushButtonData pbTCOMSettings = new PushButtonData("TCOMSet", "TCOM Settings", ExecutingAssemblyPath, ExecutingAssemblyName + ".CmdTCOMSettings");
            pbTCOMSettings.Image   = NewBitmapImage(System.Reflection.Assembly.GetExecutingAssembly(), ExecutingAssemblyName + ".WTATabs.png");
            pbTCOMSettings.ToolTip = "Set TCOM Settings - like Tags in the companion view.";
            #endregion

            List <RibbonItem> slideOutPanelButtons = new List <RibbonItem>();
            slideOutPanelButtons.AddRange(thisNewRibbonPanelTCOM.AddStackedItems(bInfoTCOM, pbTCOMSettings));
        } // AddTCOMDrops_WTA-TCOM_Ribbon
Example #13
0
        internal static Result Start(RibbonHandler ribbon)
        {
            var result = Result.Failed;
            var button = RestoreButton(CommandName);

            switch (result = Revit.OnStartup(Revit.ApplicationUI))
            {
            case Result.Succeeded:
                // Update Rhino button Tooltip
                button.ToolTip         = $"Restores previously visible Rhino windows on top of Revit window";
                button.LongDescription = $"Use CTRL key to open a Rhino model";
                // hide the button title
                if (button.GetAdwndRibbonButton() is Autodesk.Windows.RibbonButton adwndRadioButton)
                {
                    adwndRadioButton.ShowText = false;
                }

                var assemblies = AppDomain.CurrentDomain.GetAssemblies();

                // Register UI on Revit
                if (assemblies.Any(x => x.GetName().Name == "RhinoCommon"))
                {
                    rhinoPanel = ribbon.CreateAddinPanel(Addin.RhinoVersionInfo?.ProductName ?? "Rhinoceros");
                    CommandRhino.CreateUI(rhinoPanel);
                    CommandImport.CreateUI(rhinoPanel);
                    CommandToggleRhinoPreview.CreateUI(rhinoPanel);
                    CommandPython.CreateUI(rhinoPanel);
                    CommandRhinoOptions.CreateUI(rhinoPanel);
                }

                if (assemblies.Any(x => x.GetName().Name == "Grasshopper"))
                {
                    grasshopperPanel = ribbon.CreateAddinPanel("Grasshopper");
                    CommandGrasshopper.CreateUI(grasshopperPanel);
                    CommandGrasshopperPreview.CreateUI(grasshopperPanel);
                    CommandGrasshopperSolver.CreateUI(grasshopperPanel);
                    CommandGrasshopperRecompute.CreateUI(grasshopperPanel);
                    CommandGrasshopperBake.CreateUI(grasshopperPanel);
                    grasshopperPanel.AddSeparator();
                    CommandGrasshopperPlayer.CreateUI(grasshopperPanel);
                    grasshopperPanel.AddSlideOut();
                    CommandGrasshopperPackageManager.CreateUI(grasshopperPanel);
                    CommandGrasshopperFolders.CreateUI(grasshopperPanel);

                    // Script Packages UI
                    UpdateScriptPkgUI(ribbon);

                    // setup listeners, and in either case, update the packages ui
                    // listed for changes in installed packages
                    CommandGrasshopperPackageManager.CommandCompleted += CommandGrasshopperPackageManager_CommandCompleted;
                    // listen for changes to user-script paths in options
                    AddinOptions.ScriptLocationsChanged += AddinOptions_ScriptLocationsChanged;
                }

                UpdateRibbonCompact();

                result = Result.Succeeded;
                break;

            case Result.Cancelled:
                button.Enabled = false;

                if (Addin.CurrentStatus == Addin.Status.Unavailable)
                {
                    button.ToolTip = "Rhino.Inside failed to found a valid copy of Rhino 7 WIP installed.";
                }
                else if (Addin.CurrentStatus == Addin.Status.Obsolete)
                {
                    button.ToolTip = "Rhino.Inside has expired.";
                }
                else
                {
                    button.ToolTip = "Rhino.Inside load was cancelled.";
                }

                button.SetContextualHelp(new ContextualHelp(ContextualHelpType.Url, @"https://www.rhino3d.com/inside/revit"));
                break;

            case Result.Failed:
                button.Enabled = false;
                button.ToolTip = "Rhino.Inside failed to load.";
                return(Result.Failed);
            }
            return(result);
        }