public void Deactivate()
        {
            UserInterfaceEvents.OnResetCommandBars     -= OnResetCommandBars;
            UserInterfaceEvents.OnEnvironmentChange    -= OnEnvironmentChange;
            UserInterfaceEvents.OnResetRibbonInterface -= OnResetRibbonInterface;

            _createPartViewsFromAssemblyButton.Dispose();
            _createTopAndLeftViewButton.Dispose();
            _createPartViewsFromAssemblyButton = null;
            _createTopAndLeftViewButton        = null;

            Marshal.ReleaseComObject(Inventor);
            Inventor = null;

            GC.WaitForPendingFinalizers();
            GC.Collect();
        }
示例#2
0
        public void Activate(ApplicationAddInSite AddInSiteObject, bool FirstTime)
        {
            Inventor = AddInSiteObject.Application;
            UserInterfaceEvents.OnResetCommandBars     += OnResetCommandBars;
            UserInterfaceEvents.OnEnvironmentChange    += OnEnvironmentChange;
            UserInterfaceEvents.OnResetRibbonInterface += OnResetRibbonInterface;

            try
            {
                // Buttons only visible when in drawing edit mode.
                _createLeftThenThreeTopProjectedViewsButton =
                    new CreateLeftThenThreeTopProjectedViewsButton();
                _createTopAndLeftProjectedViewsButton = new CreateTopAndLeftProjectedViewsButton();
                _createPartViewsFromAssemblyButton    = new CreatePartViewsFromAssemblyButton();
                _exportPdfButton = new ExportPdfButton();

                // Buttons only visible when in assembly edit mode.
                _generateSheetMetalDrawingsButton  = new GenerateSheetMetalDrawingsButton();
                _generateMdfDrawingsButton         = new GenerateMdfDrawingsButton();
                _generateSubAssemblyDrawingsButton = new GenerateSubassemblyDrawingsButton();

                if (FirstTime == true)
                {
                    if (UserInterfaceManager.InterfaceStyle == InterfaceStyleEnum.kClassicInterface)
                    {
                        //// Create a new command bar
                        //var slotCommandBar = Runtime.UserInterfaceManager.CommandBars.Add("Slot", "Autodesk:SimpleAddIn:SlotToolbar", CommandBarTypeEnum.kRegularCommandBar, Runtime.AddInId);
                        //slotCommandBar.Controls.AddButton(_createTopAndLeftViewButton.ButtonDefinition, 0);

                        //// Make the command bar accessible in the panel menu for the 2d sketch environment.
                        //Runtime.UserInterfaceManager.Environments["PMxPartSketchEnvironment"].PanelBar.CommandBarList.Add(slotCommandBar);
                    }
                    else
                    {
                        RegisterButtons();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }