private void CreateRibbon()
        {
            try
            {
                Inventor.UserInterfaceManager userInterFaceMgr = mInventorApp.UserInterfaceManager;
                userInterFaceMgr.UserInterfaceEvents.OnEnvironmentChange += new UserInterfaceEventsSink_OnEnvironmentChangeEventHandler(OnEnvironmentChange);

                //retrieve the GUID for this class
                GuidAttribute addInCLSID = (GuidAttribute)GuidAttribute.GetCustomAttribute(typeof(RubiksCube.RubiksAddInServer), typeof(GuidAttribute));
                string        clientId   = "{" + addInCLSID.Value + "}";

                Icon         appLarge     = Resources.Rubiks_Cube_32;
                object       applargeIcon = AxHostConverter.ImageToPictureDisp(appLarge.ToBitmap());
                Icon         appStand     = Resources.Rubiks_Cube_16;
                object       appStandIcon = AxHostConverter.ImageToPictureDisp(appStand.ToBitmap());
                Environments envs         = userInterFaceMgr.Environments;
                mEnvironment = envs.Add(Resources.IDC_ENV_DISPLAY_NAME, Resources.IDC_ENV_INTERNAL_NAME, null, appStandIcon, applargeIcon);
                mEnvironment.AdditionalVisibleRibbonTabs = new string[] { Resources.IDC_ENV_INTERNAL_NAME };

                mObjCollection = mInventorApp.TransientObjects.CreateObjectCollection();

                //get the ribbon associated with part document
                Inventor.Ribbons ribbons = userInterFaceMgr.Ribbons;
                mPartRibbon = ribbons[Resources.IDC_ENV_PART];

                //get the tabs associated with part ribbon
                Inventor.RibbonTabs rubikRibbonTabs = mPartRibbon.RibbonTabs;
                mRubiksPartTab = rubikRibbonTabs.Add(Resources.IDC_TAB_DISPLAY_NAME, Resources.IDC_TAB_INTERNAL_NAME, "F0911DF2-478B-49EC-808D-D7C1F5271B6D", Resources.IDC_TARGET_TAB_NAME, true, true);

                //Adding solve Panel.
                RibbonPanel             solvePanel   = mRubiksPartTab.RibbonPanels.Add(Resources.IDC_SOLVE_DISPLAY_NAME, Resources.IDC_SOLVE_INTERNAL_NAME, "60A50C33-F7EE-4B74-BCB0-C5CE03C1B3E6");
                Inventor.CommandControl solveControl = solvePanel.CommandControls.AddButton(mSolve, true, true);

                //Adding randomize Panel.
                RibbonPanel             scramblePanel   = mRubiksPartTab.RibbonPanels.Add(Resources.IDC_SCRAMBLE_DISPLAY_NAME, Resources.IDC_SCRAMBLE_INTERNAL_NAME, "D20674CE-A855-4403-850B-FDE59C4A167B");
                Inventor.CommandControl scrambleControl = scramblePanel.CommandControls.AddButton(mScramble, true, true);

                //Adding randomize Panel.
                RibbonPanel playPanel = mRubiksPartTab.RibbonPanels.Add(Resources.IDC_PLAY_DISPLAY_NAME, Resources.IDC_PLAY_INTERNAL_NAME, "343D703C-1194-4715-BF54-3BE4E3B9FF64");
                //Inventor.CommandControl playControl = playPanel.CommandControls.AddButton(mPlay, true, true, "", false);

                mObjCollection.Add(mPlay);
                mObjCollection.Add(mNext);
                CommandControl partCmdCtrl = playPanel.CommandControls.AddSplitButtonMRU(mObjCollection, true);

                mEnvironment.DefaultRibbonTab = Resources.IDC_TAB_INTERNAL_NAME;
                userInterFaceMgr.ParallelEnvironments.Add(mEnvironment);
                mEnvCtrlDef = mInventorApp.CommandManager.ControlDefinitions[Resources.IDC_ENV_INTERNAL_NAME];
                mEnvCtrlDef.ProgressiveToolTip.ExpandedDescription = Resources.IDC_APPLICATION_BTN_TOOLTIP_EXPANDED;
                mEnvCtrlDef.ProgressiveToolTip.Description         = Resources.IDC_APPLICATION_BTN_TOOLTIP_DESCRIPTION;
                mEnvCtrlDef.ProgressiveToolTip.Title = Resources.IDC_APPLICATION_BTN_TITLE;

                AddToDisabledList();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.InnerException.Message);
            }
        }
Example #2
0
        private void CreateUserInterface()
        {
            // Get a reference to the UserInterfaceManager object.
            Inventor.UserInterfaceManager UIManager = m_inventorApplication.UserInterfaceManager;

            // Get the zero doc ribbon.
            Inventor.Ribbon zeroRibbon = UIManager.Ribbons["Part"];

            // Get the getting started tab.
            Inventor.RibbonTab startedTab = zeroRibbon.RibbonTabs["id_TabModel"];

            // Get the new features panel.
            Inventor.RibbonPanel newFeaturesPanel = startedTab.RibbonPanels["id_PanelP_ModelModify"];

            // Add a button to the panel, using the previously created button definition.
            newFeaturesPanel.CommandControls.AddButton(m_buttonDef, true);
        }
Example #3
0
        public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime)
        {
            // This method is called by Inventor when it loads the addin.
            // The AddInSiteObject provides access to the Inventor Application object.
            // The FirstTime flag indicates if the addin is loaded for the first time.

            // Initialize AddIn members.
            m_inventorApplication = addInSiteObject.Application;

            // TODO: Add ApplicationAddInServer.Activate implementation.
            // e.g. event initialization, command creation etc.

            // Get a reference to the UserInterfaceManager object.
            Inventor.UserInterfaceManager UIManager = m_inventorApplication.UserInterfaceManager;

            // Get a reference to the ControlDefinitions object.
            ControlDefinitions controlDefs = m_inventorApplication.CommandManager.ControlDefinitions;

            // Get the images from the resources.  They are stored as .Net images and the
            // PictureConverter class is used to convert them to IPictureDisp objects, which
            // the Inventor API requires.
            stdole.IPictureDisp icon_large = PictureConverter.ImageToPictureDisp(Properties.Resources.ribbon_icon);
            stdole.IPictureDisp icon_small = PictureConverter.ImageToPictureDisp(Properties.Resources.icon16);

            // Create the button definition.
            m_buttonDef = controlDefs.AddButtonDefinition("Tabs", "UIRibbonSampleOne",
                                                          CommandTypesEnum.kNonShapeEditCmdType,
                                                          "{0defbf22-e302-4266-9bc9-fb80d5c8eb7e}", "", "", icon_small, icon_large);

            // Call the function to add information to the user-interface.
            if (firstTime)
            {
                CreateUserInterface();
                //PrintRibbonNames();
            }

            // Connect to UI events to be able to handle a UI reset.
            m_uiEvents = m_inventorApplication.UserInterfaceManager.UserInterfaceEvents;
            m_uiEvents.OnResetRibbonInterface += m_uiEvents_OnResetRibbonInterface;

            m_buttonDef.OnExecute += m_buttonDef_OnExecute;
        }
Example #4
0
        private void PrintRibbonNames()
        {
            using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Users\Samuel Bryner\ribbons.txt"))
            {
                Inventor.UserInterfaceManager UIManager = m_inventorApplication.UserInterfaceManager;

                // Get the zero doc ribbon.
                foreach (Ribbon rib in UIManager.Ribbons)
                {
                    file.WriteLine(rib.InternalName);
                    foreach (RibbonTab tab in rib.RibbonTabs)
                    {
                        file.WriteLine(string.Format("  - Tab: internal name = '{0}', display name = '{1}'", tab.InternalName, tab.DisplayName));
                        foreach (RibbonPanel panel in tab.RibbonPanels)
                        {
                            file.WriteLine(string.Format("      - Panel: {0} = '{1}'", panel.DisplayName, panel.InternalName));
                        }
                    }
                }
            }
        }
Example #5
0
        public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime)
        {
            // This method is called by Inventor when it loads the addin.
            // The AddInSiteObject provides access to the Inventor Application object.
            // The FirstTime flag indicates if the addin is loaded for the first time.

            // Initialize AddIn members.
            m_inventorApplication = addInSiteObject.Application;

            // Add event handlers
            m_AppEvents = m_inventorApplication.ApplicationEvents;

            // TODO: Add ApplicationAddInServer.Activate implementation.
            // e.g. event initialization, command creation etc.


            // Define the buttons on ribbons
            Inventor.UserInterfaceManager UIManager = m_inventorApplication.UserInterfaceManager;

            // Define ControlDefinition (Button on the ribbon panel)
            ControlDefinitions controlDefs = m_inventorApplication.CommandManager.ControlDefinitions;

            // SPECIFICATION BUTTON
            // Define Command
            string CommandID = "SpecificationCmd";

            try
            {
                // try to get the existing command definition
                SpecificationCommand = (Inventor.ButtonDefinition)controlDefs[CommandID];
            }

            catch
            {
                // or create it
                IPictureDisp SmallPicture = (Inventor.IPictureDisp)PictureDispConverter.ToIPictureDisp(AutoSpecification.Properties.Resources.SimpleIcon16);
                IPictureDisp LargePicture = (Inventor.IPictureDisp)PictureDispConverter.ToIPictureDisp(AutoSpecification.Properties.Resources.SimpleIcon32);

                SpecificationCommand = controlDefs.AddButtonDefinition(
                    "Создание спецификаций на агрегат", CommandID,
                    CommandTypesEnum.kEditMaskCmdType,
                    Guid.NewGuid().ToString(),
                    "Автоспецификации",
                    "Создание спецификаций на агрегат",
                    SmallPicture,
                    LargePicture, ButtonDisplayEnum.kNoTextWithIcon);
            }
            // register the method that will be executed
            SpecificationCommand.OnExecute += new Inventor.ButtonDefinitionSink_OnExecuteEventHandler(SpecificationCommand_OnExecute);

            // add buttons to ribbon
            if (firstTime)
            {
                UserInterfaceManager userInterfaceManager = m_inventorApplication.UserInterfaceManager;
                if (userInterfaceManager.InterfaceStyle == InterfaceStyleEnum.kRibbonInterface)
                {
                    // Assembly ribbon

                    // 1. Access the Assebly ribbon
                    Inventor.Ribbon ribbonPart = userInterfaceManager.Ribbons["Assembly"];

                    // 2. Get Assemble tab
                    Inventor.RibbonTab tabSampleBlog = ribbonPart.RibbonTabs["id_TabAssemble"];

                    // 3. Create panel
                    Inventor.RibbonPanel pnlMyCommands = tabSampleBlog.RibbonPanels.Add("Спецификация", "id_Panel_AssemblyAutoSpecification", Guid.NewGuid().ToString());

                    // 4. Add Button to Panel
                    pnlMyCommands.CommandControls.AddButton(SpecificationCommand, true, false);


                    //// Part Ribbon (SheetMetalTab)

                    //// 1. Access the Part ribbon
                    //ribbonPart = userInterfaceManager.Ribbons["Part"];

                    //// 2. Get Part tab
                    //tabSampleBlog = ribbonPart.RibbonTabs["id_TabSheetMetal"];

                    //// 3. Create panel
                    //pnlMyCommands = tabSampleBlog.RibbonPanels.Add("Макросы", "id_Panel_SheetMetalReplacePart", Guid.NewGuid().ToString());

                    //// 4. Add Button to Panel
                    //pnlMyCommands.CommandControls.AddButton(ReplacePartCommand, true, false);
                    //pnlMyCommands.CommandControls.AddSeparator();
                    //pnlMyCommands.CommandControls.AddButton(ExportDXFCommand, true, false);
                    //pnlMyCommands.CommandControls.AddButton(BendTechnologyCommand, true, false);

                    //// Part Ribbon (ModelTab)

                    //// 2. Get Part tab
                    //tabSampleBlog = ribbonPart.RibbonTabs["id_TabModel"];

                    //// 3. Create panel
                    //pnlMyCommands = tabSampleBlog.RibbonPanels.Add("Макросы", "id_Panel_ModelReplacePart", Guid.NewGuid().ToString());

                    //// 4. Add Button to Panel
                    //pnlMyCommands.CommandControls.AddButton(ReplacePartCommand, true, false);
                    ////pnlMyCommands.CommandControls.AddSeparator();
                    ////pnlMyCommands.CommandControls.AddButton(ExportDXFCommand, true, false);
                    ////pnlMyCommands.CommandControls.AddButton(BendTechnologyCommand, true, false);


                    //// Drawing Ribbon (PlaceViewsTab)
                    //// 1. Access the Part ribbon
                    //ribbonPart = userInterfaceManager.Ribbons["Drawing"];

                    //// 2. Get Part tab
                    //tabSampleBlog = ribbonPart.RibbonTabs["id_TabPlaceViews"];

                    //// 3. Create panel
                    //pnlMyCommands = tabSampleBlog.RibbonPanels.Add("Макросы", "id_Panel_PlaceViewsReplacePart", Guid.NewGuid().ToString());

                    //// 4. Add Button to Panel
                    //pnlMyCommands.CommandControls.AddButton(ExportPDFCommand, true, false);
                    //pnlMyCommands.CommandControls.AddButton(TranslateToENCommand, true, false);
                    //pnlMyCommands.CommandControls.AddSeparator();
                    //pnlMyCommands.CommandControls.AddButton(FramePartsListCommand, true, false);

                    //// Drawing Ribbon (TabAnnotateESKD)

                    //// 2. Get Part tab
                    //tabSampleBlog = ribbonPart.RibbonTabs["id_TabAnnotateESKD"];

                    //// 3. Create panel
                    //pnlMyCommands = tabSampleBlog.RibbonPanels.Add("Макросы", "id_Panel_AnnotateESKDReplacePart", Guid.NewGuid().ToString());

                    //// 4. Add Button to Panel
                    //pnlMyCommands.CommandControls.AddButton(ExportPDFCommand, true, false);
                    //pnlMyCommands.CommandControls.AddButton(TranslateToENCommand, true, false);
                    //pnlMyCommands.CommandControls.AddSeparator();
                    //pnlMyCommands.CommandControls.AddButton(FramePartsListCommand, true, false);
                }
            }
        }