Esempio n. 1
0
        /// <summary>
        /// 根据XML对象设置当前元素的属性值
        /// </summary>
        /// <param name="element"></param>
        public override bool InitProperties(XElement element, IBundle bundle)
        {
            bool success = false;

            // 获取页签的唯一标识
            this.Id = element.AttibuteStringValue("id");
            if (string.IsNullOrEmpty(this.Id))
            {
                return(success);
            }
            // 获取页签名列类型
            string className = element.AttibuteStringValue("type");

            if (string.IsNullOrEmpty(className))
            {
                return(success);
            }
            // 创建页签的命令类型
            this.command = RibbonUtils.NewInstance <RibbonGroupCommand>(className, bundle);
            if (this.command == null)
            {
                return(success);
            }
            this.command.XRibbonElement = this;

            return(true);
        }
Esempio n. 2
0
        //Create the buton on the panel
        private void BuildUI(UIControlledApplication uiApp)
        {
            // Create buttons of trackchanges panel
            var panel = RibbonUtils.CreatePanel(uiApp, _tabName, "Utilities");
            var data  = new PushButtonData("btnColor", "Color\nElement", assemblyPath, typeof(CmdColorElement).FullName);

            data.LargeImage = RibbonUtils.ConvertFromBitmap(Properties.Resources.subscript_32);
            data.Image      = RibbonUtils.ConvertFromBitmap(Properties.Resources.subscript_16);
            data.ToolTip    = "Read level name and update for each elements in parameter VCF_Etage";
            var btnColor = panel.AddItem(data) as PushButton;

            //instruction file to open by F1 key
            string         instructionFile = @"https://github.com/tienduy-nguyen";
            ContextualHelp contextualHelp  = new ContextualHelp(ContextualHelpType.Url, instructionFile);

            btnColor.SetContextualHelp(contextualHelp);
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        /// <summary>
        /// 根据XML对象设置当前元素的属性值
        /// </summary>
        /// <param name="element"></param>
        public override bool InitProperties(XElement element, IBundle bundle)
        {
            bool success = false;

            // 获取页签的唯一标识
            this.Id = element.AttibuteStringValue("id");
            if (string.IsNullOrEmpty(this.Id))
            {
                return(success);
            }
            // 获取图片库
            this.ImageMso = element.AttibuteStringValue("imageMso");
            // 获取用户自定义图片
            this.IconName = element.AttibuteStringValue("iconName");
            // 获取用户自定义图片加载类型
            this.LoadMode = element.AttributeEnumValue <ResourceLoadMode>("loadMode", ResourceLoadMode.Local);
            // 加载用户图片资源
            if (string.IsNullOrEmpty(this.ImageMso) &&
                !string.IsNullOrEmpty(this.IconName))
            {
                this.Image = RibbonUtils.LoadImage(this.IconName, this.LoadMode, bundle);
            }
            // 获取页签名列类型
            string className = element.AttibuteStringValue("type");

            if (string.IsNullOrEmpty(className))
            {
                return(success);
            }
            // 创建页签的命令类型
            this.command = RibbonUtils.NewInstance <RibbonMenuCommand>(className, bundle);
            if (this.command == null)
            {
                return(success);
            }
            this.command.XRibbonElement = this;

            return(true);
        }
Esempio n. 5
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);
        }
Esempio n. 6
0
        public Result OnStartup(UIControlledApplication app)
        {
            //создаем новую вкладку на ленте
            var    newRibbon = new RibbonUtils();
            string tabName   = "SPGR Зонинг";

            newRibbon.CreateTab(app, tabName);
            #region Вкладка армирования проёма
            var appDesc1      = "Assign";
            var newPanel1     = newRibbon.AddPanel(app, tabName, appDesc1);
            var folderPath1   = @"C:\Program Files\BIMTech Utils\MEP\MEP Room";
            var appNamespace1 = "AssignParameterToInstancesInsideBBox";
            var dllPath1      = $@"Contents\{appNamespace1}.dll";
            var fullPath1     = Path.Combine(folderPath1, dllPath1);
            //добавляем кнопку на панель
            var button1 = newPanel1.AddButton(
                appDesc1,
                fullPath1,
                $"{appNamespace1}.Main");
            //задаём кнопке изображение
            var imageName1 = Path.Combine(folderPath1, @"UI\Images\mep.png");
            button1.Image        = new BitmapImage(new Uri(imageName1, UriKind.Absolute));
            button1.LargeImage   = new BitmapImage(new Uri(imageName1, UriKind.Absolute));
            button1.ToolTipImage = new BitmapImage(new Uri(imageName1, UriKind.Absolute));
            button1.ToolTip      = appDesc1;

            var appDesc2      = "MEP Cut";
            var newPanel2     = newRibbon.AddPanel(app, tabName, appDesc2);
            var folderPath2   = @"C:\Program Files\BIMTech Utils\MEP\MEP Room";
            var appNamespace2 = "CutMEPCurvesByMassEdges";
            var dllPath2      = $@"Contents\{appNamespace2}.dll";
            var fullPath2     = Path.Combine(folderPath2, dllPath2);
            //добавляем кнопку на панель
            var button2 = newPanel2.AddButton(
                appDesc2,
                fullPath2,
                $"{appNamespace2}.Main");
            //задаём кнопке изображение
            var imageName2 = Path.Combine(folderPath2, @"UI\Images\mep_cut.png");
            button2.Image        = new BitmapImage(new Uri(imageName2, UriKind.Absolute));
            button2.LargeImage   = new BitmapImage(new Uri(imageName2, UriKind.Absolute));
            button2.ToolTipImage = new BitmapImage(new Uri(imageName2, UriKind.Absolute));
            button2.ToolTip      = appDesc2;

            var appDesc3      = "MEP Rise";
            var newPanel3     = newRibbon.AddPanel(app, tabName, appDesc3);
            var folderPath3   = @"C:\Program Files\BIMTech Utils\MEP\MEP Room";
            var appNamespace3 = "AssignPipeRiseParameter";
            var dllPath3      = $@"Contents\{appNamespace3}.dll";
            var fullPath3     = Path.Combine(folderPath3, dllPath3);
            //добавляем кнопку на панель
            var button3 = newPanel3.AddButton(
                appDesc3,
                fullPath3,
                $"{appNamespace3}.Main");
            //задаём кнопке изображение
            var imageName3 = Path.Combine(folderPath3, @"UI\Images\piperise.png");
            button3.Image        = new BitmapImage(new Uri(imageName3, UriKind.Absolute));
            button3.LargeImage   = new BitmapImage(new Uri(imageName3, UriKind.Absolute));
            button3.ToolTipImage = new BitmapImage(new Uri(imageName3, UriKind.Absolute));
            button3.ToolTip      = appDesc3;

            var appDesc4      = "Signature";
            var newPanel4     = newRibbon.AddPanel(app, tabName, appDesc4);
            var folderPath4   = @"C:\Program Files\BIMTech Utils\MEP\MEP Room";
            var appNamespace4 = "SetViewSheetSignature";
            var dllPath4      = $@"Contents\{appNamespace4}.dll";
            var fullPath4     = Path.Combine(folderPath4, dllPath4);
            //добавляем кнопку на панель
            var button4 = newPanel4.AddButton(
                appDesc4,
                fullPath4,
                $"{appNamespace4}.Main");
            //задаём кнопке изображение
            var imageName4 = Path.Combine(folderPath4, @"UI\Images\signature.png");
            button4.Image        = new BitmapImage(new Uri(imageName4, UriKind.Absolute));
            button4.LargeImage   = new BitmapImage(new Uri(imageName4, UriKind.Absolute));
            button4.ToolTipImage = new BitmapImage(new Uri(imageName4, UriKind.Absolute));
            button3.ToolTip      = appDesc3;
            #endregion
            return(Result.Succeeded);
        }