コード例 #1
0
        public static void CreateUI(RibbonPanel ribbonPanel)
        {
            // Create a push button to trigger a command add it to the ribbon panel.
            var thisAssembly = Assembly.GetExecutingAssembly();

            var items = ribbonPanel.AddStackedItems
                        (
                new ComboBoxData("Category"),
                new PulldownButtonData("cmdRhinoInside.GrasshopperPlayer", "Grasshopper Player")
                        );

            categoriesComboBox = items[0] as Autodesk.Revit.UI.ComboBox;
            if (categoriesComboBox != null)
            {
                categoriesComboBox.ToolTip = "Category where Grasshopper Player will place geometry.";
            }

            mruPullDownButton = items[1] as Autodesk.Revit.UI.PulldownButton;
            if (mruPullDownButton != null)
            {
                mruPullDownButton.ToolTip = "Loads and evals a Grasshopper definition";
                mruPullDownButton.Image   = ImageBuilder.BuildImage("4");
                mruPullDownButton.SetContextualHelp(new ContextualHelp(ContextualHelpType.Url, "https://github.com/mcneel/rhino.inside/blob/master/Autodesk/Revit/README.md#sample-4"));

                mruPullDownButton.AddPushButton(typeof(Browse), "Browse...", "Browse for a Grasshopper definition to evaluate");
            }

            Revit.ApplicationUI.ViewActivated += ActiveUIApplication_ViewActivated;
        }
コード例 #2
0
        bool AddFileToMru(string filePath)
        {
            if (!File.Exists(filePath))
            {
                return(false);
            }

            if (mruPushPuttons == null)
            {
                mruPullDownButton.AddSeparator();
                mruPushPuttons = new Type[] { typeof(Mru0), typeof(Mru1), typeof(Mru2), typeof(Mru3), typeof(Mru4), typeof(Mru5) }.
                Select(x => mruPullDownButton.AddPushButton(x)).ToArray();
                foreach (var mru in mruPushPuttons)
                {
                    mru.Visible = false;
                    mru.Enabled = false;
                }
            }

            int lastItemToMove = 0;

            for (int m = 0; m < mruPushPuttons.Length; ++m)
            {
                lastItemToMove++;

                if (mruPushPuttons[m].ToolTip == filePath)
                {
                    break;
                }
            }

            int itemsToMove = lastItemToMove - 1;

            if (itemsToMove > 0)
            {
                for (int m = lastItemToMove - 1; m > 0; --m)
                {
                    mruPushPuttons[m].Visible         = mruPushPuttons[m - 1].Visible;
                    mruPushPuttons[m].Enabled         = mruPushPuttons[m - 1].Enabled;
                    mruPushPuttons[m].ToolTipImage    = mruPushPuttons[m - 1].ToolTipImage;
                    mruPushPuttons[m].LongDescription = mruPushPuttons[m - 1].LongDescription;
                    mruPushPuttons[m].ToolTip         = mruPushPuttons[m - 1].ToolTip;
                    mruPushPuttons[m].ItemText        = mruPushPuttons[m - 1].ItemText;
                    mruPushPuttons[m].Image           = mruPushPuttons[m - 1].Image;
                    mruPushPuttons[m].LargeImage      = mruPushPuttons[m - 1].LargeImage;
                }

                mruPushPuttons[0].Visible         = true;
                mruPushPuttons[0].Enabled         = true;
                mruPushPuttons[0].ToolTipImage    = null;
                mruPushPuttons[0].LongDescription = string.Empty;
                mruPushPuttons[0].ToolTip         = filePath;
                mruPushPuttons[0].ItemText        = Path.GetFileNameWithoutExtension(filePath);
                mruPushPuttons[0].Image           = ImageBuilder.BuildImage(Path.GetExtension(filePath).Substring(1));
                mruPushPuttons[0].LargeImage      = ImageBuilder.BuildLargeImage(Path.GetExtension(filePath).Substring(1));
            }

            return(true);
        }
コード例 #3
0
ファイル: Sample4.cs プロジェクト: leviat-tech/rhino.inside
        public static void CreateUI(RibbonPanel ribbonPanel)
        {
            var items = ribbonPanel.AddStackedItems
                        (
                new ComboBoxData("Category"),
                new PulldownButtonData("cmdRhinoInside.GrasshopperPlayer", "Grasshopper Player")
                        );

            categoriesComboBox = items[0] as Autodesk.Revit.UI.ComboBox;
            if (categoriesComboBox != null)
            {
                categoriesComboBox.ToolTip = "Category where Grasshopper Player will place geometry.";
            }

            mruPullDownButton = items[1] as Autodesk.Revit.UI.PulldownButton;
            if (mruPullDownButton != null)
            {
                mruPullDownButton.ToolTip = "Loads and evals a Grasshopper definition";
                mruPullDownButton.Image   = ImageBuilder.BuildImage("4");
                mruPullDownButton.SetContextualHelp(new ContextualHelp(ContextualHelpType.Url, "https://github.com/mcneel/rhino.inside/blob/master/Autodesk/Revit/README.md#sample-4"));

                mruPullDownButton.AddPushButton(typeof(Browse), "Browse...", "Browse for a Grasshopper definition to evaluate", typeof(Availability));
            }

            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;
            };
        }
コード例 #4
0
        public static void CreateUI(RibbonPanel ribbonPanel)
        {
            var buttonData = NewPushButtonData <Sample8, Availability>("Sample 8");

            if (ribbonPanel.AddItem(buttonData) is PushButton pushButton)
            {
                pushButton.ToolTip    = "Imports geometry from 3dm file to a Revit model or family";
                pushButton.Image      = ImageBuilder.BuildImage("8");
                pushButton.LargeImage = ImageBuilder.BuildLargeImage("8");
                pushButton.SetContextualHelp(new ContextualHelp(ContextualHelpType.Url, "https://github.com/mcneel/rhino.inside-revit/tree/master#sample-8"));
            }
        }
コード例 #5
0
        public static void CreateUI(RibbonPanel ribbonPanel)
        {
            var buttonData = NewPushButtonData <Sample1, NeedsActiveDocument <Availability> >("Sample 1");

            if (ribbonPanel.AddItem(buttonData) is PushButton pushButton)
            {
                pushButton.ToolTip    = "Creates a mesh sphere";
                pushButton.Image      = ImageBuilder.BuildImage("1");
                pushButton.LargeImage = ImageBuilder.BuildLargeImage("1");
                pushButton.SetContextualHelp(new ContextualHelp(ContextualHelpType.Url, "https://github.com/mcneel/rhino.inside-revit/tree/master#sample-1"));
            }
        }
コード例 #6
0
ファイル: Sample1.cs プロジェクト: zrinkaradic/rhino.inside
        public static void CreateUI(RibbonPanel ribbonPanel)
        {
            var buttonData = NewPushButtonData <Sample1, Availability>("Sample 1");

            if (ribbonPanel.AddItem(buttonData) is PushButton pushButton)
            {
                pushButton.ToolTip    = "Creates a mesh sphere";
                pushButton.Image      = ImageBuilder.BuildImage("1");
                pushButton.LargeImage = ImageBuilder.BuildLargeImage("1");
                pushButton.SetContextualHelp(new ContextualHelp(ContextualHelpType.Url, "https://github.com/mcneel/rhino.inside/blob/master/Autodesk/Revit/README.md#sample-1"));
            }
        }
コード例 #7
0
        public static void CreateUI(RibbonPanel ribbonPanel)
        {
            mruPullDownButton = ribbonPanel.AddItem(new PulldownButtonData("cmdRhinoInside.GrasshopperPlayer", "Sample 4")) as Autodesk.Revit.UI.PulldownButton;
            if (mruPullDownButton != null)
            {
                mruPullDownButton.ToolTip    = "Loads and evals a Grasshopper definition";
                mruPullDownButton.Image      = ImageBuilder.BuildImage("4");
                mruPullDownButton.LargeImage = ImageBuilder.BuildLargeImage("4");
                mruPullDownButton.SetContextualHelp(new ContextualHelp(ContextualHelpType.Url, "https://github.com/mcneel/rhino.inside-revit/tree/master#sample-4"));

                AddPushButton <Browse, NeedsActiveDocument <Availability> > (mruPullDownButton, "Browse...", "Browse for a Grasshopper definition to evaluate");
            }
        }
コード例 #8
0
ファイル: Sample4.cs プロジェクト: zjloscar/rhino.inside
        public static void CreateUI(RibbonPanel ribbonPanel)
        {
            mruPullDownButton = ribbonPanel.AddItem(new PulldownButtonData("cmdRhinoInside.GrasshopperPlayer", "Sample 4")) as Autodesk.Revit.UI.PulldownButton;
            if (mruPullDownButton != null)
            {
                mruPullDownButton.ToolTip    = "Loads and evals a Grasshopper definition";
                mruPullDownButton.Image      = ImageBuilder.BuildImage("4");
                mruPullDownButton.LargeImage = ImageBuilder.BuildLargeImage("4");
                mruPullDownButton.SetContextualHelp(new ContextualHelp(ContextualHelpType.Url, "https://github.com/mcneel/rhino.inside/blob/master/Autodesk/Revit/README.md#sample-4"));

                mruPullDownButton.AddPushButton(typeof(Browse), "Browse...", "Browse for a Grasshopper definition to evaluate", typeof(Availability));
            }
        }
コード例 #9
0
        internal static void CreateUI(RibbonPanel ribbonPanel)
        {
            if (ribbonPanel.AddItem(new PulldownButtonData("cmdRhinoInside.Help", "Help")) is PulldownButton pullDownButton)
            {
                pullDownButton.LargeImage = ImageBuilder.BuildImage("?");

                pullDownButton.AddPushButton(typeof(APIDocsCommand), "APIDocs", "Opens revitapidocs.com website", typeof(AllwaysAvailable));
                pullDownButton.AddPushButton(typeof(TheBuildingCoderCommand), "TheBuildingCoder", "Opens thebuildingcoder.typepad.com website", typeof(AllwaysAvailable));
                pullDownButton.AddSeparator();
                pullDownButton.AddPushButton(typeof(RhinoDevDocsCommand), "Rhino Dev Docs", "Opens developer.rhino3d.com website", typeof(AllwaysAvailable));
                pullDownButton.AddPushButton(typeof(DiscourseCommand), "McNeel Discourse", "Opens discourse.mcneel.com website", typeof(AllwaysAvailable));
                pullDownButton.AddPushButton(typeof(AboutCommand), "About", "Opens GitHub Repo website", typeof(AllwaysAvailable));
            }
        }
コード例 #10
0
        public static void CreateUI(RibbonPanel ribbonPanel)
        {
            var buttonData = NewPushButtonData <Sample6, Availability>("Sample 6");

            if (ribbonPanel.AddItem(buttonData) is PushButton pushButton)
            {
#if REVIT_2018
                pushButton.ToolTip = "Toggle Rhino model preview visibility";
#else
                pushButton.ToolTip = "Toggle Rhino model preview visibility (Revit 2018 or above)";
#endif
                pushButton.Image      = ImageBuilder.BuildImage("6");
                pushButton.LargeImage = ImageBuilder.BuildLargeImage("6");
                pushButton.SetContextualHelp(new ContextualHelp(ContextualHelpType.Url, "https://github.com/mcneel/rhino.inside-revit/tree/master#sample-6"));
            }
        }
コード例 #11
0
        public static void CreateUI(RibbonPanel ribbonPanel)
        {
            // Create a push button to trigger a command add it to the ribbon panel.
            var thisAssembly = Assembly.GetExecutingAssembly();

            var buttonData = new PushButtonData
                             (
                "cmdRhinoInside.RevitAPIDocs", "APIDocs",
                thisAssembly.Location,
                MethodBase.GetCurrentMethod().DeclaringType.FullName
                             );

            if (ribbonPanel.AddItem(buttonData) is PushButton pushButton)
            {
                pushButton.ToolTip    = "Opens revitapidocs.com website";
                pushButton.LargeImage = ImageBuilder.BuildImage("?");
            }
        }
コード例 #12
0
        internal static void CreateUI(RibbonPanel ribbonPanel)
        {
            if (ribbonPanel.AddItem(new PulldownButtonData("cmdRhinoInside.Help", "Help")) is PulldownButton pullDownButton)
            {
                helpButton            = pullDownButton;
                helpButton.Image      = ImageBuilder.BuildImage("?");
                helpButton.LargeImage = ImageBuilder.BuildLargeImage("?");

                helpButton.AddPushButton(typeof(CommandAPIDocs), "APIDocs", "Opens apidocs.co website", typeof(AllwaysAvailable));
                helpButton.AddPushButton(typeof(CommandTheBuildingCoder), "TheBuildingCoder", "Opens thebuildingcoder.typepad.com website", typeof(AllwaysAvailable));
                helpButton.AddSeparator();
                helpButton.AddPushButton(typeof(CommandRhinoDevDocs), "Rhino Dev Docs", "Opens developer.rhino3d.com website", typeof(AllwaysAvailable));
                helpButton.AddPushButton(typeof(CommandDiscourse), "McNeel Discourse", "Opens discourse.mcneel.com website", typeof(AllwaysAvailable));
                helpButton.AddSeparator();
                helpButton.AddPushButton(typeof(CommandCheckForUpdates), "Updates", "Checks if there are updates in GitHub", typeof(AllwaysAvailable));
                helpButton.AddPushButton(typeof(CommandAbout), "About", "Opens GitHub Repo website", typeof(AllwaysAvailable));
            }

            CommandCheckForUpdates.CheckUpdates();
        }
コード例 #13
0
        internal static void CreateUI(RibbonPanel ribbonPanel)
        {
            if (ribbonPanel.AddItem(new PulldownButtonData("cmdRhinoInside.Help", "Help")) is PulldownButton pullDownButton)
            {
                helpButton            = pullDownButton;
                helpButton.Image      = ImageBuilder.BuildImage("?");
                helpButton.LargeImage = ImageBuilder.BuildLargeImage("?");

                AddPushButton <CommandSampleFiles, AllwaysAvailable> (helpButton, "Sample files", "Opens sample files folder");
                AddPushButton <CommandAPIDocs, AllwaysAvailable> (helpButton, "APIDocs", "Opens apidocs.co website");
                AddPushButton <CommandTheBuildingCoder, AllwaysAvailable> (helpButton, "TheBuildingCoder", "Opens thebuildingcoder.typepad.com website");
                helpButton.AddSeparator();
                AddPushButton <CommandRhinoDevDocs, AllwaysAvailable> (helpButton, "Rhino Dev Docs", "Opens developer.rhino3d.com website");
                AddPushButton <CommandDiscourse, AllwaysAvailable> (helpButton, "McNeel Discourse", "Opens discourse.mcneel.com website");
                helpButton.AddSeparator();
                AddPushButton <CommandCheckForUpdates, AllwaysAvailable> (helpButton, "Updates", "Checks if there are updates in GitHub");
                AddPushButton <CommandAbout, AllwaysAvailable> (helpButton, "About…", "Shows Rhino.Inside Revit version information");
            }

            CommandCheckForUpdates.CheckUpdates();
        }
コード例 #14
0
        bool AddFileToMru(string filePath)
        {
            if (!File.Exists(filePath))
            {
                return(false);
            }

            if (mruPushPuttons is null)
            {
                mruPullDownButton.AddSeparator();
                mruPushPuttons = new PushButton[]
                {
                    AddPushButton <Mru0, NeedsActiveDocument <Availability> >(mruPullDownButton, null, null),
                    AddPushButton <Mru1, NeedsActiveDocument <Availability> >(mruPullDownButton, null, null),
                    AddPushButton <Mru2, NeedsActiveDocument <Availability> >(mruPullDownButton, null, null),
                    AddPushButton <Mru3, NeedsActiveDocument <Availability> >(mruPullDownButton, null, null),
                    AddPushButton <Mru4, NeedsActiveDocument <Availability> >(mruPullDownButton, null, null),
                    AddPushButton <Mru5, NeedsActiveDocument <Availability> >(mruPullDownButton, null, null),
                };

                foreach (var mru in mruPushPuttons)
                {
                    mru.Visible = false;
                    mru.Enabled = false;
                }
            }

            int lastItemToMove = 0;

            for (int m = 0; m < mruPushPuttons.Length; ++m)
            {
                lastItemToMove++;

                if (mruPushPuttons[m].ToolTip == filePath)
                {
                    break;
                }
            }

            int itemsToMove = lastItemToMove - 1;

            if (itemsToMove > 0)
            {
                for (int m = lastItemToMove - 1; m > 0; --m)
                {
                    mruPushPuttons[m].Visible         = mruPushPuttons[m - 1].Visible;
                    mruPushPuttons[m].Enabled         = mruPushPuttons[m - 1].Enabled;
                    mruPushPuttons[m].ToolTipImage    = mruPushPuttons[m - 1].ToolTipImage;
                    mruPushPuttons[m].LongDescription = mruPushPuttons[m - 1].LongDescription;
                    mruPushPuttons[m].ToolTip         = mruPushPuttons[m - 1].ToolTip;
                    mruPushPuttons[m].ItemText        = mruPushPuttons[m - 1].ItemText;
                    mruPushPuttons[m].Image           = mruPushPuttons[m - 1].Image;
                    mruPushPuttons[m].LargeImage      = mruPushPuttons[m - 1].LargeImage;
                }

                mruPushPuttons[0].Visible         = true;
                mruPushPuttons[0].Enabled         = true;
                mruPushPuttons[0].ToolTipImage    = null;
                mruPushPuttons[0].LongDescription = string.Empty;
                mruPushPuttons[0].ToolTip         = filePath;
                mruPushPuttons[0].ItemText        = Path.GetFileNameWithoutExtension(filePath);
                mruPushPuttons[0].Image           = ImageBuilder.BuildImage(Path.GetExtension(filePath).Substring(1));
                mruPushPuttons[0].LargeImage      = ImageBuilder.BuildLargeImage(Path.GetExtension(filePath).Substring(1));
            }

            return(true);
        }