public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime) { try { SetupDynamoPaths(); inventorApplication = addInSiteObject.Application; PersistenceManager.InventorApplication = inventorApplication; userInterfaceManager = inventorApplication.UserInterfaceManager; //initialize event delegates userInterfaceEvents = inventorApplication.UserInterfaceManager.UserInterfaceEvents; UserInterfaceEventsSink_OnResetCommandBarsEventDelegate = new UserInterfaceEventsSink_OnResetCommandBarsEventHandler(UserInterfaceEvents_OnResetCommandBars); userInterfaceEvents.OnResetCommandBars += UserInterfaceEventsSink_OnResetCommandBarsEventDelegate; UserInterfaceEventsSink_OnResetEnvironmentsEventDelegate = new UserInterfaceEventsSink_OnResetEnvironmentsEventHandler(UserInterfaceEvents_OnResetEnvironments); userInterfaceEvents.OnResetEnvironments += UserInterfaceEventsSink_OnResetEnvironmentsEventDelegate; UserInterfaceEventsSink_OnResetRibbonInterfaceEventDelegate = new UserInterfaceEventsSink_OnResetRibbonInterfaceEventHandler(UserInterfaceEvents_OnResetRibbonInterface); userInterfaceEvents.OnResetRibbonInterface += UserInterfaceEventsSink_OnResetRibbonInterfaceEventDelegate; appEvents = inventorApplication.ApplicationEvents; appEvents.OnActivateDocument += appEvents_OnActivateDocument; appEvents.OnDeactivateDocument += appEvents_OnDeactivateDocument; Icon dynamoIcon = Resources.logo_square_32x32; //retrieve the GUID for this class GuidAttribute addInCLSID; addInCLSID = (GuidAttribute)GuidAttribute.GetCustomAttribute(this.GetType(), typeof(GuidAttribute)); string addInCLSIDString; addInCLSIDString = "{" + addInCLSID.Value + "}"; dynamoAddinButton = new DynamoInventorAddinButton( buttonDisplayName, buttonInternalName, CommandTypesEnum.kShapeEditCmdType, addInCLSIDString, "Initialize Dynamo.", "Dynamo is a visual programming environment for Inventor.", dynamoIcon, dynamoIcon, ButtonDisplayEnum.kDisplayTextInLearningMode); CommandCategory assemblyUtilitiesCategory = inventorApplication.CommandManager.CommandCategories.Add(commandCategoryDisplayName, commandCategoryInternalName, addInCLSID); assemblyUtilitiesCategory.Add(dynamoAddinButton.ButtonDefinition); if (firstTime == true) { InterfaceStyleEnum interfaceStyle; interfaceStyle = userInterfaceManager.InterfaceStyle; if (interfaceStyle == InterfaceStyleEnum.kClassicInterface) { CommandBar assemblyUtilityCommandBar; assemblyUtilityCommandBar = userInterfaceManager.CommandBars.Add(commandBarDisplayName, commandBarInternalName, CommandBarTypeEnum.kRegularCommandBar, addInCLSID); } else { Inventor.Ribbons ribbons = userInterfaceManager.Ribbons; Inventor.Ribbon assemblyRibbon = ribbons["Assembly"]; RibbonTabs ribbonTabs = assemblyRibbon.RibbonTabs; RibbonTab assemblyRibbonTab = ribbonTabs["id_AddInsTab"]; RibbonPanels ribbonPanels = assemblyRibbonTab.RibbonPanels; assemblyRibbonPanel = ribbonPanels.Add(ribbonPanelDisplayName, ribbonPanelInternalName, "{DB59D9A7-EE4C-434A-BB5A-F93E8866E872}", "", false); CommandControls assemblyRibbonPanelCtrls = assemblyRibbonPanel.CommandControls; CommandControl assemblyCmdBtnCmdCtrl = assemblyRibbonPanelCtrls.AddButton(dynamoAddinButton.ButtonDefinition, true, true, "", false); Inventor.Ribbon partRibbon = ribbons["Part"]; RibbonTabs partRibbonTabs = partRibbon.RibbonTabs; RibbonTab modelRibbonTab = partRibbonTabs["id_AddInsTab"]; RibbonPanels partRibbonPanels = modelRibbonTab.RibbonPanels; partRibbonPanel = partRibbonPanels.Add(ribbonPanelDisplayName, ribbonPanelInternalName, "{DB59D9A7-EE4C-434A-BB5A-F93E8866E872}", "", false); CommandControls partRibbonPanelCtrls = partRibbonPanel.CommandControls; CommandControl partCmdBtnCmdCtrl = partRibbonPanelCtrls.AddButton(dynamoAddinButton.ButtonDefinition, true, true, "", false); Inventor.Ribbon drawingRibbon = ribbons["Drawing"]; RibbonTabs drawingRibbonTabs = drawingRibbon.RibbonTabs; RibbonTab drawingRibbonTab = drawingRibbonTabs["id_AddInsTab"]; RibbonPanels drawingRibbonPanels = drawingRibbonTab.RibbonPanels; drawingRibbonPanel = drawingRibbonPanels.Add(ribbonPanelDisplayName, ribbonPanelInternalName, "{DB59D9A7-EE4C-434A-BB5A-F93E8866E872}", "", false); CommandControls drawingRibbonPanelCtrls = drawingRibbonPanel.CommandControls; CommandControl drawingCmdBtnCmdCtrl = drawingRibbonPanelCtrls.AddButton(dynamoAddinButton.ButtonDefinition, true, true, "", false); } } } catch (Exception e) { MessageBox.Show(e.ToString()); } }