Example #1
0
        public void Activate(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.
            _inventorApplication = addInSiteObject.Application;

            ControlDefinitions controlDefs   = _inventorApplication.CommandManager.ControlDefinitions;
            IPictureDisp       smallPicture2 = AxHostConverter.ImageToPictureDisp(Resources.CreateMasterM.ToBitmap());
            IPictureDisp       largePicture2 = AxHostConverter.ImageToPictureDisp(Resources.CreateMasterM.ToBitmap());

            _dockableWindow            = controlDefs.AddButtonDefinition("Dockable Window", "DockableWindow:Show", CommandTypesEnum.kNonShapeEditCmdType, "{" + ClientId + "}", null, null, smallPicture2, largePicture2);
            _dockableWindow.OnExecute += m_dockableWindow_OnExecute;

            // Get the initial ribbon.
            Ribbon ribbon = _inventorApplication.UserInterfaceManager.Ribbons["ZeroDoc"];
            // Get "Extras" tab.
            RibbonTab extrasTab = ribbon.RibbonTabs["id_TabTools"];

            const string chatPanelInternalName = "DockableWindow:ChatPanel";
            RibbonPanel  panel = extrasTab.RibbonPanels.OfType <RibbonPanel>().SingleOrDefault(rp => rp.InternalName == chatPanelInternalName);

            if (panel == null)
            {
                panel = extrasTab.RibbonPanels.Add("Chat", chatPanelInternalName, "{" + ClientId + "}");
            }

            panel.CommandControls.AddButton(_dockableWindow, true);
        }
Example #2
0
        private void AddMainButtonToRibbon()
        {
            ControlDefinitions ctrlDefs = InventorApp.CommandManager.ControlDefinitions;
            var  currAssembly           = System.Reflection.Assembly.GetExecutingAssembly();
            Icon icon32        = Resources.shaft_32x32;
            Icon icon16        = Resources.shaft_16x16;
            var  pictureDisp32 = PictureDispConverter.ToIPictureDisp(icon32);
            var  pictureDisp16 = PictureDispConverter.ToIPictureDisp(icon16);

            this.mainButtonDefinition = ctrlDefs.AddButtonDefinition(
                DisplayName: "Shaft",
                InternalName: "Autodesk:InventorShaftGenerator:MainCtrl",
                Classification: CommandTypesEnum.kEditMaskCmdType,
                ClientId: AdnInventorUtilities.AddInGuid,
                ToolTipText: "Shaft Component Generator",
                StandardIcon: pictureDisp16,
                LargeIcon: pictureDisp32
                );
            this.mainButtonDefinition.OnExecute += OnMainButtonExecute;

            Ribbon    assebmlyRibbon = InventorApp.UserInterfaceManager.Ribbons["Assembly"];
            RibbonTab asmDesingTab   = assebmlyRibbon.RibbonTabs["id_TabDesign"];

            var panel3 = asmDesingTab.RibbonPanels.Add(
                DisplayName: "Tools Panel",
                InternalName: "Autodesk:InventorShaftGenerator:PartToolsPanel",
                ClientId: AdnInventorUtilities.AddInGuid);

            panel3.CommandControls.AddButton(
                ButtonDefinition: this.mainButtonDefinition,
                UseLargeIcon: true
                );
        }
Example #3
0
        /// <summary>
        /// modifies Drawing ribbon by adding two buttons used by the add-in
        /// </summary>
        private void modifyRibbon()
        {
            //get Command manager
            cmdMan = m_inventorApplication.CommandManager;

            //get control definitions
            ctrlDefs = cmdMan.ControlDefinitions;

            //define command category for add-in's buttons
            cmdCat = cmdMan.CommandCategories.Add("Auto-Breaker", "Autodesk:CmdCategory:AutoBreaker", addInGuid);

            //get 'Drawing' ribbon
            drawingRibbon = m_inventorApplication.UserInterfaceManager.Ribbons["Drawing"];

            //get 'Place Views' tab from 'Drawing' ribbon
            placeTab = drawingRibbon.RibbonTabs["id_TabPlaceViews"];

            //define 'Apply break' button
            applyButton            = ctrlDefs.AddButtonDefinition("Apply!", "Autodesk:AutoBreaker:ApplyButton", CommandTypesEnum.kQueryOnlyCmdType, addInGuid, "auto-break description", "auto-break tooltip", plus16obj, plus128obj, ButtonDisplayEnum.kAlwaysDisplayText);
            applyButton.OnExecute += new ButtonDefinitionSink_OnExecuteEventHandler(customAction);
            cmdCat.Add(applyButton);

            //define 'Settings' button
            settingsButton            = ctrlDefs.AddButtonDefinition("Settings", "Autodesk:AutoBreaker:SettingsButton", CommandTypesEnum.kQueryOnlyCmdType, addInGuid, "auto-breaker settings description", "auto-break settings tool-tip", gear16obj, gear128obj, ButtonDisplayEnum.kAlwaysDisplayText);
            settingsButton.OnExecute += new ButtonDefinitionSink_OnExecuteEventHandler(settingsClick);
            cmdCat.Add(settingsButton);

            //define panel in 'Place Views' tab
            panel                = placeTab.RibbonPanels.Add("Auto-Breaker", "Autodesk:AutoBreaker:AutoBreakerPanel", addInGuid);
            controlApplyBreak    = panel.CommandControls.AddButton(applyButton, true, true);
            controlSettingsBreak = panel.CommandControls.AddButton(settingsButton, true, true);
        }
Example #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;

            ControlDefinitions controlDefs = m_inventorApplication.CommandManager.ControlDefinitions;

            // Create Icons
            buildIcons();

            // Create button objects
            m_CrosswireBasketButton = controlDefs.AddButtonDefinition("Crosswire\nBasket", "Crosswire Basket Design Template", CommandTypesEnum.kShapeEditCmdType, addInGUID, "Generate a crosswire basket 3D model and\nengineering drawing using a template.",
                                                                      "Crosswire Basket Design Template", smallCWBasketDisp, largeCWBasketDisp);
            m_MeshBasketButton = controlDefs.AddButtonDefinition("Mesh\nBasket", "Mesh Basket Design Template", CommandTypesEnum.kShapeEditCmdType, addInGUID, "Generate a mesh basket 3D model and\nengineering drawing using a template.",
                                                                 "Mesh Basket Design Template", smallMeshBasketDisp, largeMeshBasketDisp);

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

            if (firstTime)
            {
                try
                {
                    if (m_inventorApplication.UserInterfaceManager.InterfaceStyle == InterfaceStyleEnum.kRibbonInterface)
                    {
                        try
                        {
                            buildCustomInterface();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                        }
                    }
                    else
                    {
                        // For classic interface, possibly incorrect code
                        CommandBar oCommandBar = m_inventorApplication.UserInterfaceManager.CommandBars["ZeroDoc"];
                        oCommandBar.Controls.AddButton(m_CrosswireBasketButton, 0);
                        oCommandBar.Controls.AddButton(m_MeshBasketButton, 0);
                    }
                }
                catch
                {
                    // For classic interface, possibly incorrect code
                    CommandBar oCommandBar = m_inventorApplication.UserInterfaceManager.CommandBars["ZeroDoc"];
                    oCommandBar.Controls.AddButton(m_CrosswireBasketButton, 0);
                    oCommandBar.Controls.AddButton(m_MeshBasketButton, 0);
                }
            }

            m_CrosswireBasketButton.OnExecute += new ButtonDefinitionSink_OnExecuteEventHandler(m_CrosswireBasketButton_OnExecute);
            m_MeshBasketButton.OnExecute      += new ButtonDefinitionSink_OnExecuteEventHandler(m_MeshBasketButton_OnExecute);
        }
Example #5
0
        public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime)
        {
            _addInSiteObject = addInSiteObject;

            // 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.
            _Application = addInSiteObject.Application;

            AdnInventorUtilities.Initialize(_Application, this.GetType());

            ControlDefinitions ctrlDefs =
                _Application.CommandManager.ControlDefinitions;

            System.Drawing.Icon Icon32 = Resources.CGAUDemo_32x32;
            System.Drawing.Icon Icon16 = Resources.CGAUDemo_16x16;

            object IPictureDisp32 = PictureDispConverter.ToIPictureDisp(Icon32);
            object IPictureDisp16 = PictureDispConverter.ToIPictureDisp(Icon16);

            try
            {
                _MainControlButtonDef =
                    ctrlDefs["Autodesk:AdskCGAUDemo:MainCtrl"] as ButtonDefinition;
            }
            catch
            {
                _MainControlButtonDef =
                    ctrlDefs.AddButtonDefinition(
                        "   Demo   \n   Control   ",
                        "Autodesk:AdskCGAUDemo:MainCtrl",
                        CommandTypesEnum.kEditMaskCmdType,
                        AdnInventorUtilities.AddInGuid,
                        "Client Graphics Demo AU",
                        "Client Graphics Demo AU",
                        IPictureDisp16,
                        IPictureDisp32,
                        ButtonDisplayEnum.kDisplayTextInLearningMode);
            }

            _MainControlButtonDef.OnExecute +=
                new ButtonDefinitionSink_OnExecuteEventHandler(MainControlButtonDef_OnExecute);

            if (firstTime)
            {
                Ribbon partRibbon = _Application.UserInterfaceManager.Ribbons["Part"];
                Ribbon asmRibbon  = _Application.UserInterfaceManager.Ribbons["Assembly"];
                Ribbon dwgRibbon  = _Application.UserInterfaceManager.Ribbons["Drawing"];

                AddToRibbon(partRibbon, AdnInventorUtilities.AddInGuid);
                AddToRibbon(asmRibbon, AdnInventorUtilities.AddInGuid);
                AddToRibbon(dwgRibbon, AdnInventorUtilities.AddInGuid);
            }
        }
        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);
        }
Example #7
0
        public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime)
        {
            //MASSIF NOTES: Probably best not to put license checks here, otherwise you might slow down the Inventor startup.

            // 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;

            //Create some UI
            Ribbon      partRibbon  = m_inventorApplication.UserInterfaceManager.Ribbons["ZeroDoc"];
            RibbonTab   massifTab   = partRibbon.RibbonTabs.Add("Massif SDK", "MASSIF_TAB_SAMPLE", Guid.NewGuid().ToString());
            RibbonPanel massifPanel = massifTab.RibbonPanels.Add("Massif Sample Tool", "PNL_MASSIF_SAMPLE", Guid.NewGuid().ToString());

            //Add a control definition for a button
            ControlDefinitions controlDefs = m_inventorApplication.CommandManager.ControlDefinitions;

            //Sort out the icon
            var btnImage = Properties.Resources.MassifIcon;

            stdole.IPictureDisp iPictDisp = PictureDispConverter.ToIPictureDisp(btnImage);

            //Create button definition
            runBtnDef = controlDefs.AddButtonDefinition("Run Test",
                                                        "{6C426CFE-E9BC-44CB-8B46-F2D4BDE05AE6}",
                                                        CommandTypesEnum.kQueryOnlyCmdType,
                                                        "573e1c9f-6fa9-4799-9afc-c4f0ad2b9d44",
                                                        "Test Massif licensing",
                                                        "Click to check that you have a license to run this addin.",
                                                        iPictDisp,
                                                        iPictDisp,
                                                        ButtonDisplayEnum.kDisplayTextInLearningMode
                                                        );

            //Add button to panel
            CommandControl startControl = massifPanel.CommandControls.AddButton(runBtnDef, true, true);

            uiEvents = m_inventorApplication.UserInterfaceManager.UserInterfaceEvents;

            try
            {
                runBtnDef.OnExecute += new ButtonDefinitionSink_OnExecuteEventHandler(RunBtnDef_OnExecute);
            }

            catch
            {
            }
        }
Example #8
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 #9
0
        public void Deactivate()
        {
            // This method is called by Inventor when the AddIn is unloaded.
            // The AddIn will be unloaded either manually by the user or
            // when the Inventor session is terminated

            // TODO: Add ApplicationAddInServer.Deactivate implementation

            // Release objects.
            m_inventorApplication = null;
            model      = null;
            plus16obj  = null;
            plus128obj = null;
            gear16obj  = null;
            gear128obj = null;

            cmdMan   = null;
            ctrlDefs = null;
            cmdCat.Delete();
            cmdCat        = null;
            drawingRibbon = null;
            placeTab      = null;
            applyButton.Delete();
            applyButton = null;
            settingsButton.Delete();
            settingsButton = null;
            panel.Delete();
            panel = null;
            controlApplyBreak.Delete();
            controlApplyBreak = null;
            controlSettingsBreak.Delete();
            controlSettingsBreak = null;

            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
        /// <summary>
        /// Function to simplify the creation of a button definition.  The big advantage
        /// to using this function is that you don't have to deal with converting images
        /// but instead just reference a folder on disk where this routine reads the images.
        /// </summary>
        /// <param name="DisplayName">
        /// The name of the command as it will be displayed on the button.
        /// </param>
        /// <param name="InternalName">
        /// The internal name of the command. This needs to be unique with respect to ALL other
        /// commands. It's best to incorporate a company name to help with uniqueness.
        /// </param>
        /// <param name="ToolTip">
        /// The tooltip that will be used for the command.
        ///
        /// This is optional and the display name will be used as the
        /// tooltip if no tooltip is specified. Like in the DisplayName argument, you can use
        /// returns to force line breaks.
        /// </param>
        /// <param name="IconFolder">
        /// The folder that contains the icon files. This can be a full path or a path that is
        /// relative to the location of the add-in dll. The folder should contain the files
        /// 16x16.png and 32x32.png. Each command will have its own folder so they can have
        /// their own icons.
        ///
        /// This is optional and if no icon is specified then no icon will be displayed on the
        /// button and it will be only text.
        /// </param>
        /// <returns>
        /// Returns the newly created button definition or Nothing in case of failure.
        /// </returns>
        public static Inventor.ButtonDefinition CreateButtonDefinition(string DisplayName,
                                                                       string InternalName,
                                                                       string ToolTip    = "",
                                                                       string IconFolder = "")
        {
            // Check to see if a command already exists is the specified internal name.
            Inventor.ButtonDefinition testDef = null;
            try
            {
                testDef = (Inventor.ButtonDefinition)Globals.invApp.CommandManager.ControlDefinitions[InternalName];
            }
            catch (Exception ex)
            {
            }

            if (!(testDef == null))
            {
                MessageBox.Show("Error when loading the add-in \"My_CSharp_AddIn\". A command already exists with the same internal name. Each add-in must have a unique internal name. Change the internal name in the call to CreateButtonDefinition.", "CSharp Inventor Add-In Template");
                return(null);
            }

            // Check to see if the provided folder is a full or relative path.
            if (!string.IsNullOrEmpty(IconFolder))
            {
                if (!System.IO.Directory.Exists(IconFolder))
                {
                    // The folder provided doesn't exist, so assume it is a relative path and
                    // build up the full path.
                    string dllPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

                    IconFolder = System.IO.Path.Combine(dllPath, IconFolder);
                }
            }

            // Get the images from the specified icon folder.
            stdole.IPictureDisp iPicDisp16x16 = null;
            stdole.IPictureDisp iPicDisp32x32 = null;
            if (!string.IsNullOrEmpty(IconFolder))
            {
                if (System.IO.Directory.Exists(IconFolder))
                {
                    string filename16x16 = System.IO.Path.Combine(IconFolder, "16x16.png");
                    string filename32x32 = System.IO.Path.Combine(IconFolder, "32x32.png");

                    if (System.IO.File.Exists(filename16x16))
                    {
                        try
                        {
                            System.Drawing.Bitmap image16x16 = new System.Drawing.Bitmap(filename16x16);
                            iPicDisp16x16 = ConvertImage.ConvertImageToIPictureDisp(image16x16);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Unable to load the 16x16.png image from \"" + IconFolder + "\"." + System.Environment.NewLine + "No small icon will be used.", "Error Loading Icon");
                        }
                    }
                    else
                    {
                        MessageBox.Show("The icon for the small button does not exist: \"" + filename16x16 + "\"." + System.Environment.NewLine + "No small icon will be used.", "Error Loading Icon");
                    }

                    if (System.IO.File.Exists(filename32x32))
                    {
                        try
                        {
                            System.Drawing.Bitmap image32x32 = new System.Drawing.Bitmap(filename32x32);
                            iPicDisp32x32 = ConvertImage.ConvertImageToIPictureDisp(image32x32);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Unable to load the 32x32.png image from \"" + IconFolder + "\"." + System.Environment.NewLine + "No large icon will be used.", "Error Loading Icon");
                        }
                    }
                    else
                    {
                        MessageBox.Show("The icon for the large button does not exist: \"" + filename32x32 + "\"." + System.Environment.NewLine + "No large icon will be used.", "Error Loading Icon");
                    }
                }
            }

            try
            {
                // Get the ControlDefinitions collection.
                ControlDefinitions controlDefs = Globals.invApp.CommandManager.ControlDefinitions;

                // Create the command defintion.
                ButtonDefinition btnDef = controlDefs.AddButtonDefinition(DisplayName, InternalName, Inventor.CommandTypesEnum.kShapeEditCmdType, Globals.g_addInClientID, "", ToolTip, iPicDisp16x16, iPicDisp32x32);
                return(btnDef);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Example #11
0
        public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime)
        {
            // authorization procedure
            _isAuthorize = true;

            if (_isAuthorize)
            {
                // Initialize AddIn members.
                _app = addInSiteObject.Application;

                #region UI INIT

                Image exportImg = TemplateAdskInventor.Properties.Resources.Button;
                _exportPict = ImageConversion.ImageToPictureDisp(exportImg);

                // get command manager
                _cmdMan = _app.CommandManager;

                // defne comand catagory for addin buttons
                _cmdCat = _cmdMan.CommandCategories.Add(
                    _panelDisplayName, "flecheria:CmdCategory:TemplateAdskInventor",
                    _addInGuid);

                ControlDefinitions ctrlDefs = _app.CommandManager.ControlDefinitions;

                try
                {
                    _exportBtnDef = ctrlDefs["flecheria:TemplateAdskInventor:TestButton"] as ButtonDefinition;
                }
                catch (Exception ex)
                {
                    #region BUTTON CREATION

                    ExportButton exportBtn = new ExportButton(_app,
                                                              "Export Obj", "flecheria:TemplateAdskInventor:ExportObj",
                                                              CommandTypesEnum.kQueryOnlyCmdType, _addInGuid,
                                                              "Export Obj with data",
                                                              "Export Obj with data and tree information",
                                                              _exportPict, _exportPict,
                                                              ButtonDisplayEnum.kAlwaysDisplayText);
                    _exportBtnDef = exportBtn.ButtonDefinition;
                    _cmdCat.Add(_exportBtnDef);

                    #endregion

                    Debug.WriteLine(ex.Message);
                }

                // create panel interface
                if (firstTime)
                {
                    try
                    {
                        if (_app.UserInterfaceManager.InterfaceStyle == InterfaceStyleEnum.kRibbonInterface)
                        {
                            #region RIBBON AND PANELS

                            // getting ribbons
                            Ribbon startedRib = _app.UserInterfaceManager.Ribbons["ZeroDoc"];
                            //Ribbon partRib = _app.UserInterfaceManager.Ribbons["Part"];
                            //Ribbon assemblyRib = _app.UserInterfaceManager.Ribbons["Assembly"];
                            //Ribbon drawingRib = _app.UserInterfaceManager.Ribbons["Drawing"];

                            // getting tab
                            RibbonTab startedTab = startedRib.RibbonTabs["id_GetStarted"];
                            //RibbonTab partTab = partRib.RibbonTabs["id_AddInsTab"];
                            //RibbonTab assemblyTab = assemblyRib.RibbonTabs["id_AddInsTab"];
                            //RibbonTab drawingTab = drawingRib.RibbonTabs["id_AddInsTab"];

                            _startedPanel = startedTab.RibbonPanels.Add(_panelDisplayName,
                                                                        "flecheria:TemplateAdskInventor:AOEPanelStart", _addInGuid, "", false);
                            //_partPanel = partTab.RibbonPanels.Add(_panelDisplayName,
                            //    "flecheria:TemplateAdskInventor:AOEPanelPart", _addInGuid, "", false);
                            //_assemblyPanel = assemblyTab.RibbonPanels.Add(_panelDisplayName,
                            //    "flecheria:TemplateAdskInventor:AOEPanelAssembly", _addInGuid, "", false);
                            //_drawingPanel = drawingTab.RibbonPanels.Add(_panelDisplayName,
                            //    "flecheria:TemplateAdskInventor:AOEPanelDrawing", addInGuid, "", false);

                            #endregion

                            #region CREATE BUTTON ON STARTED TAB

                            CommandControl startExportControl = _startedPanel.CommandControls.AddButton(
                                _exportBtnDef, false, true, "", true);

                            #endregion
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "TemplateAdskInventor Error");
                        Debug.Write(ex.Message);
                    }
                }

                #endregion
            }
        }
Example #12
0
        /// <summary>
        /// Called when the <see cref="StandardAddInServer"/> is being loaded
        /// </summary>
        /// <param name="AddInSiteObject"></param>
        /// <param name="FirstTime"></param>
        public void Activate(ApplicationAddInSite AddInSiteObject, bool FirstTime)
        {
            MainApplication = AddInSiteObject.Application; //Gets the application object, which is used in many different ways throughout this whole process
            string ClientID = "{0c9a07ad-2768-4a62-950a-b5e33b88e4a3}";

            Utilities.LoadSettings();

            #region Add Parallel Environment

            #region Load Images

            stdole.IPictureDisp ExportRobotIconSmall = PictureDispConverter.ToIPictureDisp(new Bitmap(Resource.SynthesisLogo16));
            stdole.IPictureDisp ExportRobotIconLarge = PictureDispConverter.ToIPictureDisp(new Bitmap(Resource.SynthesisLogo32));

            stdole.IPictureDisp SaveRobotIconSmall = PictureDispConverter.ToIPictureDisp(new Bitmap(Resource.Save16));
            stdole.IPictureDisp SaveRobotIconLarge = PictureDispConverter.ToIPictureDisp(new Bitmap(Resource.Save32));

            stdole.IPictureDisp ExportSetupRobotIconSmall = PictureDispConverter.ToIPictureDisp(new Bitmap(Resource.Gears16));
            stdole.IPictureDisp ExportSetupRobotIconLarge = PictureDispConverter.ToIPictureDisp(new Bitmap(Resource.Gears32));

            stdole.IPictureDisp YeetRobotIconSmall = PictureDispConverter.ToIPictureDisp(new Bitmap(Resource.Wand16));//these are still here at request of QA
            stdole.IPictureDisp YeetRobotIconLarge = PictureDispConverter.ToIPictureDisp(new Bitmap(Resource.Wand32));

            stdole.IPictureDisp WeightRobotIconSmall = PictureDispConverter.ToIPictureDisp(new Bitmap(Resource.Weight16));
            stdole.IPictureDisp WeightRobotIconLarge = PictureDispConverter.ToIPictureDisp(new Bitmap(Resource.Weight32));

            stdole.IPictureDisp SynthesisLogoSmall = PictureDispConverter.ToIPictureDisp(new Bitmap(Resource.SynthesisLogo16));
            stdole.IPictureDisp SynthesisLogoLarge = PictureDispConverter.ToIPictureDisp(new Bitmap(Resource.SynthesisLogo32));

            #region DEBUG
#if DEBUG
            stdole.IPictureDisp DebugButtonSmall = PictureDispConverter.ToIPictureDisp(new Bitmap(Resource.Wand16));
            stdole.IPictureDisp DebugButtonLarge = PictureDispConverter.ToIPictureDisp(new Bitmap(Resource.Wand32));
#endif
            #endregion

            #endregion

            #region UI Creation

            #region Setup New Environment and Ribbon
            Environments environments = MainApplication.UserInterfaceManager.Environments;
            ExporterEnv = environments.Add("Robot Exporter", "BxD:RobotExporter:Environment", null, SynthesisLogoSmall, SynthesisLogoLarge);

            Ribbon    assemblyRibbon = MainApplication.UserInterfaceManager.Ribbons["Assembly"];
            RibbonTab ExporterTab    = assemblyRibbon.RibbonTabs.Add("Robot Exporter", "BxD:RobotExporter:RobotExporterTab", ClientID, "", false, true);

            ControlDefinitions ControlDefs = MainApplication.CommandManager.ControlDefinitions;

            SetupPanel    = ExporterTab.RibbonPanels.Add("Start Over", "BxD:RobotExporter:SetupPanel", ClientID);
            SettingsPanel = ExporterTab.RibbonPanels.Add("Settings", "BxD:RobotExporter:SettingsPanel", ClientID);
            FilePanel     = ExporterTab.RibbonPanels.Add("File", "BxD:RobotExporter:FilePanel", ClientID);

            // Reset positioning of panels
            SettingsPanel.Reposition("BxD:RobotExporter:SetupPanel", false);
            FilePanel.Reposition("BxD:RobotExporter:SettingsPanel", false);
            #endregion

            #region Setup Buttons
            //Begin Wizard Export
            WizardExportButton            = ControlDefs.AddButtonDefinition("Exporter Setup", "BxD:RobotExporter:BeginWizardExport", CommandTypesEnum.kNonShapeEditCmdType, ClientID, null, "Quickly configure wheel and joint information.", ExportSetupRobotIconSmall, ExportSetupRobotIconLarge);
            WizardExportButton.OnExecute += BeginWizardExport_OnExecute;
            WizardExportButton.OnHelp    += _OnHelp;
            SetupPanel.CommandControls.AddButton(WizardExportButton, true);

            //Set Weight
            SetWeightButton            = ControlDefs.AddButtonDefinition("Robot Weight", "BxD:RobotExporter:SetWeight", CommandTypesEnum.kNonShapeEditCmdType, ClientID, null, "Change the weight of the robot.", WeightRobotIconSmall, WeightRobotIconLarge);
            SetWeightButton.OnExecute += SetWeight_OnExecute;
            SetWeightButton.OnHelp    += _OnHelp;
            SettingsPanel.CommandControls.AddButton(SetWeightButton, true);

            //Save Button
            SaveButton            = ControlDefs.AddButtonDefinition("Save Configuration", "BxD:RobotExporter:SaveRobot", CommandTypesEnum.kNonShapeEditCmdType, ClientID, null, "Save robot configuration to your assembly file for future exporting.", SaveRobotIconSmall, SaveRobotIconLarge);
            SaveButton.OnExecute += SaveButton_OnExecute;
            SaveButton.OnHelp    += _OnHelp;
            FilePanel.CommandControls.AddButton(SaveButton, true);

            //Export Button
            ExportButton            = ControlDefs.AddButtonDefinition("Export to Synthesis", "BxD:RobotExporter:ExportRobot", CommandTypesEnum.kNonShapeEditCmdType, ClientID, null, "Export your robot's model to Synthesis.", ExportRobotIconSmall, ExportRobotIconLarge);
            ExportButton.OnExecute += ExportButton_OnExecute;
            ExportButton.OnHelp    += _OnHelp;
            FilePanel.CommandControls.AddButton(ExportButton, true);

            #endregion

            #region DEBUG
#if DEBUG
            DebugPanel = ExporterTab.RibbonPanels.Add("Debug", "BxD:RobotExporter:DebugPanel", ClientID);
            //Selection Test
            DedectionTestButton            = ControlDefs.AddButtonDefinition("Detection Test", "BxD:RobotExporter:DetectionTestButton", CommandTypesEnum.kNonShapeEditCmdType, ClientID, null, null, DebugButtonSmall, DebugButtonLarge);
            DedectionTestButton.OnExecute += delegate(NameValueMap context)
            {
                if (Wizard.WizardUtilities.DetectWheels(Utilities.GUI.SkeletonBase, out List <RigidNode_Base> leftWheels, out List <RigidNode_Base> rightWheels))
                {
                    List <RigidNode_Base> allWheels = new List <RigidNode_Base>();
                    allWheels.AddRange(leftWheels);
                    allWheels.AddRange(rightWheels);
                    SelectNodes(allWheels);
                }
            };
            DebugPanel.CommandControls.AddButton(DedectionTestButton, true);
            //UI Test
            UITestButton            = ControlDefs.AddButtonDefinition("UI Test", "BxD:RobotExporter:UITestButton", CommandTypesEnum.kNonShapeEditCmdType, ClientID, null, null, DebugButtonSmall, DebugButtonLarge);
            UITestButton.OnExecute += delegate(NameValueMap context)
            {
                Wizard.WizardForm wizard = new Wizard.WizardForm();

                wizard.ShowDialog();
                if (Properties.Settings.Default.ShowExportOrAdvancedForm)
                {
                    Form finishDialog = new Wizard.ExportOrAdvancedForm();
                    finishDialog.ShowDialog();
                }
            };
            DebugPanel.CommandControls.AddButton(UITestButton, true);
#endif
            #endregion

            #endregion

            #region Final Environment Setup
            ExporterEnv.DefaultRibbonTab = "BxD:RobotExporter:RobotExporterTab";
            MainApplication.UserInterfaceManager.ParallelEnvironments.Add(ExporterEnv);
            ExporterEnv.DisabledCommandList.Add(MainApplication.CommandManager.ControlDefinitions["BxD:RobotExporter:Environment"]);
            #endregion

            #region Event Handler Assignment
            MainApplication.UserInterfaceManager.UserInterfaceEvents.OnEnvironmentChange += UIEvents_OnEnvironmentChange;
            MainApplication.ApplicationEvents.OnActivateDocument   += ApplicationEvents_OnActivateDocument;
            MainApplication.ApplicationEvents.OnDeactivateDocument += ApplicationEvents_OnDeactivateDocument;
            MainApplication.ApplicationEvents.OnCloseDocument      += ApplicationEvents_OnCloseDocument;
            LegacyInterchange.LegacyEvents.RobotModified           += new Action(() => { PendingChanges = true; });
            #endregion

            #endregion

            Instance = this;
        }
Example #13
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;

            // Create Icon
            ControlDefinitions controlDefs = m_inventorApplication.CommandManager.ControlDefinitions;

            Icon smallPush = InvAddIn.Properties.Resources.costEstimateIcon;
            Icon largePush = InvAddIn.Properties.Resources.costEstimateIcon;

            stdole.IPictureDisp smallCostIcon = PictureDispConverter.ToIPictureDisp(smallPush);
            stdole.IPictureDisp largCostIcon  = PictureDispConverter.ToIPictureDisp(largePush);

            m_CostEstimator = controlDefs.AddButtonDefinition("Estimator", "Open Cost Estimator Window.", CommandTypesEnum.kFilePropertyEditCmdType, addInGUID, "Open Cost Estimator Window.", "Cost Estimator", smallCostIcon, largCostIcon);

            if (firstTime)
            {
                try
                {
                    if (m_inventorApplication.UserInterfaceManager.InterfaceStyle == InterfaceStyleEnum.kRibbonInterface)
                    {
                        // Assembly Button
                        Ribbon    assemblyRibbon = m_inventorApplication.UserInterfaceManager.Ribbons["Assembly"];
                        RibbonTab toolsTab       = assemblyRibbon.RibbonTabs["id_TabTools"];

                        // Part Buttons
                        Ribbon    partRibbon   = m_inventorApplication.UserInterfaceManager.Ribbons["Part"];
                        RibbonTab toolsPartTab = partRibbon.RibbonTabs["id_TabTools"];

                        try
                        {
                            // For ribbon interface
                            // This is a new panel that can be made
                            RibbonPanel panel = toolsTab.RibbonPanels.Add("Cost Estimator", "Autodesk:Cost Estimator:Panel1", addInGUID, "", false);

                            CommandControl control1 = panel.CommandControls.AddButton(m_CostEstimator, true, true, "", false);

                            RibbonPanel    pane1_part = toolsPartTab.RibbonPanels.Add("Cost Estimator", "Autodesk:Cost Estimator:pane1_part", addInGUID, "", false);
                            CommandControl control2   = pane1_part.CommandControls.AddButton(m_CostEstimator, true, true, "", false);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                        }
                    }
                    else
                    {
                        // For classic interface, possibly incorrect code
                        CommandBar oCommandBar = m_inventorApplication.UserInterfaceManager.CommandBars["AMxAssemblyPanelCmdBar"];
                        oCommandBar.Controls.AddButton(m_CostEstimator, 0);
                    }
                }
                catch
                {
                    // For classic interface, possibly incorrect code
                    CommandBar oCommandBar = m_inventorApplication.UserInterfaceManager.CommandBars["AMxAssemblyPanelCmdBar"];
                    oCommandBar.Controls.AddButton(m_CostEstimator, 0);
                }
            }

            m_CostEstimator.OnExecute += new ButtonDefinitionSink_OnExecuteEventHandler(m_CostEstimator_OnExecute);

            // TODO: Add ApplicationAddInServer.Activate implementation.
            // e.g. event initialization, command creation etc.
        }
Example #14
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);
                }
            }
        }
Example #15
0
        private void InitEnvironmentPanels(RibbonTab exporterTab, string clientId, ControlDefinitions controlDefs)
        {
            // DRIVETRAIN PANEL
            driveTrainPanel = exporterTab.RibbonPanels.Add("Drive Train Setup", "BxD:RobotExporter:DriveTrainPanel", clientId);

            driveTrainTypeButton = controlDefs.AddButtonDefinition("Drive Train\nLayout",
                                                                   "BxD:RobotExporter:SetDriveTrainType", CommandTypesEnum.kNonShapeEditCmdType, clientId, null,
                                                                   "Select the drivetrain type (tank, H-drive, or mecanum).", ToIPictureDisp(new Bitmap(Resources.DrivetrainType32)), ToIPictureDisp(new Bitmap(Resources.DrivetrainType32)));
            driveTrainTypeButton.OnExecute += context =>
            {
                AnalyticsUtils.LogPage("Drivetrain Type Editor");
                new DrivetrainLayoutForm(RobotDataManager).ShowDialog();
            };
            driveTrainPanel.CommandControls.AddButton(driveTrainTypeButton, true);

            drivetrainWeightButton = controlDefs.AddButtonDefinition("Drive Train\nWeight",
                                                                     "BxD:RobotExporter:SetDriveTrainWeight", CommandTypesEnum.kNonShapeEditCmdType, clientId, null,
                                                                     "Assign the weight of the drivetrain.", ToIPictureDisp(new Bitmap(Resources.RobotWeight32)), ToIPictureDisp(new Bitmap(Resources.RobotWeight32)));
            drivetrainWeightButton.OnExecute += context =>
            {
                AnalyticsUtils.LogPage("Drivetrain Weight Editor");
                RobotDataManager.PromptRobotWeight();
            };
            driveTrainPanel.CommandControls.AddButton(drivetrainWeightButton, true);

            // JOINT PANEL
            jointPanel = exporterTab.RibbonPanels.Add("Joint Setup", "BxD:RobotExporter:JointPanel", clientId);

            advancedEditJointButton = controlDefs.AddButtonDefinition("Advanced Editor", "BxD:RobotExporter:AdvancedEditJoint",
                                                                      CommandTypesEnum.kNonShapeEditCmdType, clientId, null, "Joint editor for advanced users.", ToIPictureDisp(new Bitmap(Resources.JointEditor32)), ToIPictureDisp(new Bitmap(Resources.JointEditor32)));
            advancedEditJointButton.OnExecute += context =>
            {
                if (advancedJointEditor.Visible)
                {
                    return;
                }
                AnalyticsUtils.LogPage("Advanced Joint Editor");
                advancedJointEditor.Visible = true;
                jointEditorForm.Visible     = false;
            };
            jointPanel.SlideoutControls.AddButton(advancedEditJointButton);

            editJointButton = controlDefs.AddButtonDefinition("Edit Joints", "BxD:RobotExporter:EditJoint",
                                                              CommandTypesEnum.kNonShapeEditCmdType, clientId, null, "Edit existing joints.", ToIPictureDisp(new Bitmap(Resources.JointEditor32)), ToIPictureDisp(new Bitmap(Resources.JointEditor32)));
            editJointButton.OnExecute += context =>
            {
                if (!jointEditorForm.HasJoints())
                {
                    var result = MessageBox.Show("No rotational or slider joints detected in the assembly! Add joints to your robot by using the \"Joint\" button under \"Assemble\" and restart the robot export environment to edit joints.\n\n" +
                                                 "Would you like to view a video tutorial on adding joints to your assembly?", "No Joints Found", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                    if (result.Equals(DialogResult.Yes))
                    {
                        System.Diagnostics.Process.Start("https://youtu.be/fY3Vdkh8L0Y");
                    }
                    return;
                }

                if (jointEditorForm.Visible)
                {
                    jointEditorForm.Activate();
                }
                else
                {
                    AnalyticsUtils.LogPage("Joint Editor");
                    UnsupportedComponentsForm.CheckUnsupportedComponents(RobotDataManager.RobotBaseNode.ListAllNodes());
                    jointEditorForm.PreShow();
                    jointEditorForm.Show();
                    advancedJointEditor.Visible = false;
                }
            };
            jointPanel.CommandControls.AddButton(editJointButton, true);

            // PRECHECK PANEL
            precheckPanel = exporterTab.RibbonPanels.Add("Export Precheck", "BxD:RobotExporter:ChecklistPanel", clientId);

            dofButton = controlDefs.AddButtonDefinition("Toggle Joint\nViewer", "BxD:RobotExporter:JointViewer",
                                                        CommandTypesEnum.kNonShapeEditCmdType, clientId, null, "View status of all joints.", ToIPictureDisp(new Bitmap(Resources.Guide32)), ToIPictureDisp(new Bitmap(Resources.Guide32)));
            dofButton.OnExecute += context =>
            {
                jointViewKey.Visible = !jointViewKey.Visible;
                HighlightManager.DisplayJointHighlight = jointViewKey.Visible;
                if (jointViewKey.Visible)
                {
                    AnalyticsUtils.LogPage("Joint View");
                }
            };
            precheckPanel.CommandControls.AddButton(dofButton, true);

            // ADD-IN SETTINGS PANEL
            addInSettingsPanel = exporterTab.RibbonPanels.Add("Add-In", "BxD:RobotExporter:AddInSettings", clientId);

            settingsButton = controlDefs.AddButtonDefinition("Add-In Settings", "BxD:RobotExporter:Settings",
                                                             CommandTypesEnum.kNonShapeEditCmdType, clientId, null, "Configure add-in settings.", ToIPictureDisp(new Bitmap(Resources.Gears16)), ToIPictureDisp(new Bitmap(Resources.Gears32)));
            settingsButton.OnExecute += context =>
            {
                AnalyticsUtils.LogPage("Exporter Settings");
                new ExporterSettingsForm().ShowDialog();
            };
            addInSettingsPanel.CommandControls.AddButton(settingsButton, true);
        }
Example #16
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.

            ControlDefinitions controlDefs = m_inventorApplication.CommandManager.ControlDefinitions;

            // Icons
            //   System.Diagnostics.Debug.WriteLine(System.IO.Directory.GetCurrentDirectory());

            //string originalDir = System.IO.Directory.GetCurrentDirectory();
            //string dir = "%APPDATA%\\Autodesk\\ApplicationPlugins\\AssemblyToParts\\";
            //System.Diagnostics.Debug.WriteLine(System.IO.Directory.GetCurrentDirectory());
            //System.IO.Directory.SetCurrentDirectory(dir);
            //MessageBox.Show(System.IO.Directory.GetCurrentDirectory());

            string appData = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData);

            Icon smallPush = new Icon(appData + @"\Autodesk\ApplicationPlugins\AssemblyToParts\push parameters.ico");
            Icon largePush = new Icon(appData + @"\Autodesk\ApplicationPlugins\AssemblyToParts\\push parameters.ico");

            stdole.IPictureDisp smallPushIcon = PictureDispConverter.ToIPictureDisp(smallPush);
            stdole.IPictureDisp largePushIcon = PictureDispConverter.ToIPictureDisp(largePush);
            // End Icon code

            m_PushAndUpdateButton = controlDefs.AddButtonDefinition("Push and\nUpdate", "Push Parameters and UpdateIlogic", CommandTypesEnum.kShapeEditCmdType, addInGUID, "Push Assembly Parameters to child parts and/nupdate Ilogic for passing assembly parameters to children.",
                                                                    "Push Parameters and Update iLogic", smallPushIcon, largePushIcon);

            m_PullFromParents = controlDefs.AddButtonDefinition("Pull Parameters", "Pull Parameters from Parent", CommandTypesEnum.kShapeEditCmdType, addInGUID, "Pull Key Parameters from a chose parent file and add to the part's user parameters.",
                                                                "Push Key Parameters from parent file.", smallPushIcon, largePushIcon);

            if (firstTime)
            {
                try
                {
                    if (m_inventorApplication.UserInterfaceManager.InterfaceStyle == InterfaceStyleEnum.kRibbonInterface)
                    {
                        // Assembly Button
                        Ribbon    assemblyRibbon = m_inventorApplication.UserInterfaceManager.Ribbons["Assembly"];
                        RibbonTab assemblyTab    = assemblyRibbon.RibbonTabs["id_TabAssemble"];

                        // Part Buttons
                        Ribbon    partRibbon    = m_inventorApplication.UserInterfaceManager.Ribbons["Part"];
                        RibbonTab sketchTab     = partRibbon.RibbonTabs["id_TabSketch"];
                        RibbonTab sheetMetalTab = partRibbon.RibbonTabs["id_TabSheetMetal"];
                        RibbonTab modelTab      = partRibbon.RibbonTabs["id_TabModel"];


                        try
                        {
                            // For ribbon interface
                            // This is a new panel that can be made
                            RibbonPanel panel = assemblyTab.RibbonPanels.Add("Assembly to Parts", "Autodesk:Assembly to Parts:Panel1", addInGUID, "", false);
                            //   CommandControl control1 = panel.CommandControls.AddButton(m_PushParametersButton, true, true, "", false);
                            //  CommandControl control2 = panel.CommandControls.AddButton(m_UpdateIlogicButtton, true, true, "", false);
                            CommandControl control1 = panel.CommandControls.AddButton(m_PushAndUpdateButton, true, true, "", false);

                            // Child asy pulling from Parent
                            //                  RibbonPanel panel_asm = assemblyTab.RibbonPanels.Add("Assembly to Parts", "Autodesk:Assembly to Parts:panel_asm", addInGUID, "", false);
                            //             CommandControl control2 = panel_asm.CommandControls.AddButton(m_PullFromParents, true, true, "", false);

                            RibbonPanel    panel_sketch = sketchTab.RibbonPanels.Add("Assembly to Parts", "Autodesk:Assembly to Parts:panel_sketch", addInGUID, "", false);
                            CommandControl control3     = panel_sketch.CommandControls.AddButton(m_PullFromParents, true, true, "", false);

                            RibbonPanel    pane1_sheetMetal = sheetMetalTab.RibbonPanels.Add("Assembly to Parts", "Autodesk:Assembly to Parts:pane1_sheetMetal", addInGUID, "", false);
                            CommandControl control4         = pane1_sheetMetal.CommandControls.AddButton(m_PullFromParents, true, true, "", false);

                            RibbonPanel    panel_model = modelTab.RibbonPanels.Add("Assembly to Parts", "Autodesk:Assembly to Parts:pane1_sheetMetal", addInGUID, "", false);
                            CommandControl control5    = panel_model.CommandControls.AddButton(m_PullFromParents, true, true, "", false);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                        }
                    }
                    else
                    {
                        // For classic interface, possibly incorrect code
                        CommandBar oCommandBar = m_inventorApplication.UserInterfaceManager.CommandBars["AMxAssemblyPanelCmdBar"];
                        oCommandBar.Controls.AddButton(m_PushAndUpdateButton, 0);
                        oCommandBar.Controls.AddButton(m_PullFromParents, 0);
                        //    oCommandBar.Controls.AddButton(m_PushParametersButton, 0);
                        //oCommandBar.Controls.AddButton(m_UpdateIlogicButtton, 0);
                    }
                }
                catch
                {
                    // For classic interface, possibly incorrect code
                    CommandBar oCommandBar = m_inventorApplication.UserInterfaceManager.CommandBars["AMxAssemblyPanelCmdBar"];
                    oCommandBar.Controls.AddButton(m_PushAndUpdateButton, 0);
                    oCommandBar.Controls.AddButton(m_PullFromParents, 0);
                    //    oCommandBar.Controls.AddButton(m_PushParametersButton, 0);
                    //oCommandBar.Controls.AddButton(m_UpdateIlogicButtton, 0);
                }
            }

            m_PushAndUpdateButton.OnExecute += new ButtonDefinitionSink_OnExecuteEventHandler(m_PushAndUpdateButton_OnExecute);
            m_PullFromParents.OnExecute     += new ButtonDefinitionSink_OnExecuteEventHandler(m_PullFromParents_OnExecute);
        }
Example #17
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.

            ControlDefinitions oCtrlDefs = m_inventorApplication.CommandManager.ControlDefinitions;

            System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();

            string[] resources = assembly.GetManifestResourceNames();

            System.IO.Stream oStream1 = assembly.GetManifestResourceStream("ZeroRibbon.resources.Icon1.ico");
            System.IO.Stream oStream2 = assembly.GetManifestResourceStream("ZeroRibbon.resources.Icon2.ico");

            System.Drawing.Icon oIcon1 = new System.Drawing.Icon(oStream1);
            System.Drawing.Icon oIcon2 = new System.Drawing.Icon(oStream2);

            object oIPictureDisp1 = AxHostConverter.ImageToPictureDisp(oIcon1.ToBitmap());
            object oIPictureDisp2 = AxHostConverter.ImageToPictureDisp(oIcon2.ToBitmap());

            try
            {
                Zero_GetStarted_LaunchPanel_ButtonDef = oCtrlDefs["Autodesk:ZeroRibbon:ButtonDef1"] as ButtonDefinition;
                Zero_GetStarted_NewPanel_ButtonDef    = oCtrlDefs["Autodesk:ZeroRibbon:ButtonDef2"] as ButtonDefinition;
            }
            catch (Exception ex)
            {
                Zero_GetStarted_LaunchPanel_ButtonDef = oCtrlDefs.AddButtonDefinition("Ribbon Demo1",
                                                                                      "Autodesk:ZeroRibbon:ButtonDef1",
                                                                                      CommandTypesEnum.kEditMaskCmdType,
                                                                                      addInGuid,
                                                                                      "Ribbon Demo",
                                                                                      "Ribbon Demo Description",
                                                                                      oIPictureDisp1,
                                                                                      oIPictureDisp1,
                                                                                      ButtonDisplayEnum.kDisplayTextInLearningMode);

                Zero_GetStarted_NewPanel_ButtonDef = oCtrlDefs.AddButtonDefinition("Ribbon Demo2",
                                                                                   "Autodesk:ZeroRibbon:ButtonDef2",
                                                                                   CommandTypesEnum.kEditMaskCmdType,
                                                                                   addInGuid,
                                                                                   "Ribbon Demo",
                                                                                   "Ribbon Demo Description",
                                                                                   oIPictureDisp2,
                                                                                   oIPictureDisp2,
                                                                                   ButtonDisplayEnum.kDisplayTextInLearningMode);

                CommandCategory cmdCat = m_inventorApplication.CommandManager.CommandCategories.Add("RibbonDemo C#", "Autodesk:CmdCategory:RibbonDemoC#", addInGuid);


                cmdCat.Add(Zero_GetStarted_LaunchPanel_ButtonDef);
                cmdCat.Add(Zero_GetStarted_NewPanel_ButtonDef);
            }



            Ribbon      ribbon      = m_inventorApplication.UserInterfaceManager.Ribbons["ZeroDoc"];
            RibbonTab   tab         = ribbon.RibbonTabs["id_GetStarted"];
            RibbonPanel built_panel = tab.RibbonPanels["id_Panel_Launch"];

            built_panel.CommandControls.AddButton(Zero_GetStarted_LaunchPanel_ButtonDef, true);

            RibbonPanel panel1 = tab.RibbonPanels.Add("Ribbon Demo", "Autodesk:RibbonDemoC#:Panel1", addInGuid, "", false);

            panel1.CommandControls.AddButton(Zero_GetStarted_NewPanel_ButtonDef, true);


            Zero_GetStarted_LaunchPanel_ButtonDef.OnExecute += new ButtonDefinitionSink_OnExecuteEventHandler(Zero_GetStarted_LaunchPanel_ButtonDef_OnExecute);
            Zero_GetStarted_NewPanel_ButtonDef.OnExecute    += new ButtonDefinitionSink_OnExecuteEventHandler(Zero_GetStarted_NewPanel_ButtonDef_OnExecute);
        }
Example #18
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.
            ControlDefinitions oCtrlDefs = m_inventorApplication.CommandManager.ControlDefinitions;

            System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();

            string[] resources = assembly.GetManifestResourceNames();

            System.IO.Stream oStream32 = assembly.GetManifestResourceStream("RibbonDemoAddin.resources.button 32x32.ico");
            System.IO.Stream oStream16 = assembly.GetManifestResourceStream("RibbonDemoAddin.resources.button 16x16.ico");

            System.Drawing.Icon oIcon32 = new System.Drawing.Icon(oStream32);
            System.Drawing.Icon oIcon16 = new System.Drawing.Icon(oStream16);

            object oIPictureDisp32 = AxHostConverter.ImageToPictureDisp(oIcon32.ToBitmap());
            object oIPictureDisp16 = AxHostConverter.ImageToPictureDisp(oIcon16.ToBitmap());

            try
            {
                _buttonDef1 = oCtrlDefs["Autodesk:BrowserDemo:ButtonDef1"] as ButtonDefinition;
            }
            catch (Exception ex)
            {
                _buttonDef1 = oCtrlDefs.AddButtonDefinition("Ribbon Demo1",
                                                            "Autodesk:RibbonDemoC#:ButtonDef1",
                                                            CommandTypesEnum.kEditMaskCmdType,
                                                            addInGuid,
                                                            "Ribbon Demo",
                                                            "Ribbon Demo Description",
                                                            oIPictureDisp16,
                                                            oIPictureDisp32,
                                                            ButtonDisplayEnum.kDisplayTextInLearningMode);

                CommandCategory cmdCat = m_inventorApplication.CommandManager.CommandCategories.Add("RibbonDemo C#", "Autodesk:CmdCategory:RibbonDemoC#", addInGuid);

                cmdCat.Add(_buttonDef1);
            }

            if (firstTime)
            {
                try
                {
                    if (m_inventorApplication.UserInterfaceManager.InterfaceStyle == InterfaceStyleEnum.kRibbonInterface)
                    {
                        Ribbon ribbon = m_inventorApplication.UserInterfaceManager.Ribbons["Part"];

                        RibbonTab tab = ribbon.RibbonTabs["id_TabModel"];

                        try
                        {
                            RibbonPanel panel = tab.RibbonPanels.Add("Ribbon Demo", "Autodesk:RibbonDemoC#:Panel1", addInGuid, "", false);

                            CommandControl control1 = panel.CommandControls.AddButton(_buttonDef1, true, true, "", false);
                        }
                        catch (Exception ex)
                        {
                        }
                    }
                    else
                    {
                        CommandBar oCommandBar = m_inventorApplication.UserInterfaceManager.CommandBars["PMxPartFeatureCmdBar"];
                        oCommandBar.Controls.AddButton(_buttonDef1, 0);
                    }
                }
                catch
                {
                    CommandBar oCommandBar = m_inventorApplication.UserInterfaceManager.CommandBars["PMxPartFeatureCmdBar"];
                    oCommandBar.Controls.AddButton(_buttonDef1, 0);
                }
            }

            _buttonDef1.OnExecute += new ButtonDefinitionSink_OnExecuteEventHandler(_buttonDef1_OnExecute);
        }