示例#1
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;
            Application   app   = uiapp.Application;
            Document      doc   = uidoc.Document;

            var relayTab = RibbonUtils.GetTab("Relay");

            //create the panels for the sub directories
            foreach (var directory in Directory.GetDirectories(Globals.RelayGraphs))
            {
                //the upper folder name (panel name)
                DirectoryInfo dInfo = new DirectoryInfo(directory);

                Autodesk.Revit.UI.RibbonPanel panelToUse;

                //try to create the panel, if it already exists, just use it
                try
                {
                    panelToUse = uiapp.CreateRibbonPanel("Relay", dInfo.Name);
                }
                catch (Exception)
                {
                    panelToUse = uiapp.GetRibbonPanels("Relay").First(p => p.Name.Equals(dInfo.Name));
                }

                //find the files that do not have a button yet
                var toCreate = Directory.GetFiles(directory, "*.dyn")
                               .Where(f => RibbonUtils.GetButton("Relay", dInfo.Name, $"relay{new FileInfo(f).Name.Replace(" ", "")}") == null).ToArray();

                //if the user is holding down the left shift key, then force the large icons
                bool forceLargeIcons = Keyboard.IsKeyDown(Key.LeftShift);

                RibbonUtils.AddItems(panelToUse, toCreate, forceLargeIcons);
            }

            //subscribe to the events of the button to associate the current DYN
            Autodesk.Windows.ComponentManager.UIElementActivated -= ComponentManagerOnUIElementActivated;
            Autodesk.Windows.ComponentManager.UIElementActivated += ComponentManagerOnUIElementActivated;

            return(Result.Succeeded);
        }
示例#2
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;
            Application   app   = uiapp.Application;
            Document      doc   = uidoc.Document;

            var relayTab = RibbonUtils.GetTab("Relay");

            //create the panels for the sub directories
            foreach (var directory in Directory.GetDirectories(Globals.RelayGraphs))
            {
                DirectoryInfo dInfo = new DirectoryInfo(directory);

                Autodesk.Revit.UI.RibbonPanel panelToUse = null;

                try
                {
                    panelToUse = uiapp.CreateRibbonPanel("Relay", dInfo.Name);
                }
                catch (Exception)
                {
                    panelToUse = uiapp.GetRibbonPanels("Relay").First(p => p.Name.Equals(dInfo.Name));
                }

                var toCreate = Directory.GetFiles(directory, "*.dyn")
                               .Where(f => RibbonUtils.GetButton("Relay", dInfo.Name, $"relay{new FileInfo(f).Name.Replace(" ", "")}") == null).ToArray();

                RibbonUtils.AddItems(panelToUse, toCreate);
            }

            //subscribe to the events of the button to associate the current DYN
            Autodesk.Windows.ComponentManager.UIElementActivated -= ComponentManagerOnUIElementActivated;
            Autodesk.Windows.ComponentManager.UIElementActivated += ComponentManagerOnUIElementActivated;

            return(Result.Succeeded);
        }
示例#3
0
 //Create a panel in the custom tab given by name
 public Autodesk.Revit.UI.RibbonPanel CreateRibbonPanel(string tabName, string panelName)
 {
     return(ControlledApplication != null
                ? ControlledApplication.CreateRibbonPanel(tabName, panelName)
                : _uiapp.CreateRibbonPanel(tabName, panelName));
 }
 internal RibbonPanel CreateRibbonPanel(string tabName, string panelName)
 {
     return(ControlledApplication != null
                ? ControlledApplication.CreateRibbonPanel(tabName, panelName)
                : uiApplication.CreateRibbonPanel(tabName, panelName));
 }