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.

            int largeIconSize = 0;

            if (m_inventorApplication.UserInterfaceManager.InterfaceStyle == InterfaceStyleEnum.kRibbonInterface)
            {
                largeIconSize = 32;
            }
            else
            {
                largeIconSize = 24;
            }

            ControlDefinitions controlDefs = m_inventorApplication.CommandManager.ControlDefinitions;

            stdole.IPictureDisp smallPicture1 = AxHostConverter.ImageToPictureDisp(new Icon(@"Resources\Icon1.ico").ToBitmap());
            stdole.IPictureDisp largePicture1 = AxHostConverter.ImageToPictureDisp(new Icon(@"Resources\Icon1.ico").ToBitmap());
            m_TreeViewBrowser            = controlDefs.AddButtonDefinition("HierarchyPane", "BrowserSample:HierarchyPane", CommandTypesEnum.kNonShapeEditCmdType, m_ClientId, null, null, smallPicture1, largePicture1);
            m_TreeViewBrowser.OnExecute += new ButtonDefinitionSink_OnExecuteEventHandler(m_TreeViewBrowser_OnExecute);



            stdole.IPictureDisp smallPicture2 = AxHostConverter.ImageToPictureDisp(new Icon(@"Resources\Icon2.ico").ToBitmap());
            stdole.IPictureDisp largePicture2 = AxHostConverter.ImageToPictureDisp(new Icon(@"Resources\Icon2.ico").ToBitmap());
            m_ActiveXBrowser            = controlDefs.AddButtonDefinition("ActiveXPane", "BrowserSample:ActiveXPane", CommandTypesEnum.kNonShapeEditCmdType, m_ClientId, null, null, smallPicture2, largePicture2);
            m_ActiveXBrowser.OnExecute += new ButtonDefinitionSink_OnExecuteEventHandler(m_ActiveXBrowser_OnExecute);

            stdole.IPictureDisp smallPicture3 = AxHostConverter.ImageToPictureDisp(new Icon(@"Resources\Icon3.ico").ToBitmap());
            stdole.IPictureDisp largePicture3 = AxHostConverter.ImageToPictureDisp(new Icon(@"Resources\Icon3.ico").ToBitmap());
            m_DoBrowserEvents            = controlDefs.AddButtonDefinition("DoBrowserEvents", "BrowserSample:DoBrowserEvents", CommandTypesEnum.kNonShapeEditCmdType, m_ClientId, null, null, smallPicture3, largePicture3);
            m_DoBrowserEvents.OnExecute += new ButtonDefinitionSink_OnExecuteEventHandler(m_DoBrowserEvents_OnExecute);


            // Get the assembly ribbon.
            Inventor.Ribbon partRibbon = m_inventorApplication.UserInterfaceManager.Ribbons["Part"];
            // Get the "Part" tab.
            Inventor.RibbonTab   partTab   = partRibbon.RibbonTabs[1];
            Inventor.RibbonPanel partPanel = partTab.RibbonPanels[1];
            partPanel.CommandControls.AddButton(m_TreeViewBrowser, true);
            partPanel.CommandControls.AddButton(m_DoBrowserEvents);
            partPanel.CommandControls.AddButton(m_ActiveXBrowser);
        }
Пример #2
0
        public static RibbonPanel CreateRibbonPanel(string buttonPlace, string idTabTools, string panelName, string displayName, ButtonDefinition buttonDefinition)
        {
            string classId = "{" + AddInGlobal.ClassId + "}";
            Ribbon ribbon  = AddInGlobal.InventorApp.UserInterfaceManager.Ribbons[buttonPlace];

            Inventor.RibbonTab   ribbonTab   = ribbon.RibbonTabs[idTabTools];
            Inventor.RibbonPanel ribbonPanel = ribbonTab.RibbonPanels.OfType <Inventor.RibbonPanel>()
                                               .SingleOrDefault(rp => rp.InternalName == panelName)
                                               ?? ribbonTab.RibbonPanels.Add(
                "Search 3D Models", "Search 3D Models", classId);
            ribbonPanel.CommandControls.AddButton(buttonDefinition, true);
            return(ribbonPanel);
        }
Пример #3
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);
        }
Пример #4
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);
                }
            }
        }