private void UserInterfaceEvents_OnResetRibbonInterface(NameValueMap context) { //TODO: Fix this try { //get the ribbon associated with part document Inventor.Ribbons ribbons = userInterfaceManager.Ribbons; Inventor.Ribbon assemblyRibbon = ribbons["Assembly"]; //get the tabls associated with part ribbon RibbonTabs ribbonTabs = assemblyRibbon.RibbonTabs; RibbonTab assemblyRibbonTab = ribbonTabs["id_Assembly"]; //create a new panel with the tab RibbonPanels ribbonPanels = assemblyRibbonTab.RibbonPanels; assemblyRibbonPanel = ribbonPanels.Add(ribbonPanelDisplayName, ribbonPanelInternalName, "{DB59D9A7-EE4C-434A-BB5A-F93E8866E872}", "", false); CommandControls assemblyRibbonPanelCtrls = assemblyRibbonPanel.CommandControls; CommandControl copyUtilCmdBtnCmdCtrl = assemblyRibbonPanelCtrls.AddButton(dynamoAddinButton.ButtonDefinition, true, true, "", false); } catch (Exception e) { MessageBox.Show(e.ToString()); } }
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); }
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); }
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()); } }
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. AddinGlobal.InventorApp = addInSiteObject.Application; // Initialize AddIn members. m_inventorApplication = addInSiteObject.Application; try { AddinGlobal.GetAddinClassId(this.GetType()); Icon icon1 = Properties.Resources.button_turn_on; Icon icon2 = Properties.Resources.log_door; Icon icon3 = Properties.Resources.chat_31; Icon icon4 = Properties.Resources.off_on_power_energy_1_; Icon icon5 = null; //Icon icon1 = new Icon(this.GetType(), "InventorAddIn1.Properties.AddSlotOption.ico"); //Change it if necessary but make sure it's embedded. //Button1 InventorButton button1 = new InventorButton( "Session erstellen", "InventorAddinServer.Button_" + Guid.NewGuid().ToString(), "Button 1 description", "Erstellen Sie eine neue Session", icon1, icon1, CommandTypesEnum.kShapeEditCmdType, ButtonDisplayEnum.kDisplayTextInLearningMode); button1.SetBehavior(true, true, true); button1.Execute = ButtonAction.Button1_Execute; //Button2 InventorButton button2 = new InventorButton( "Beitreten", "InventorAddinServer.Button_" + Guid.NewGuid().ToString(), "Button 1 description", "Eine Session beitreten", icon2, icon2, CommandTypesEnum.kShapeEditCmdType, ButtonDisplayEnum.kDisplayTextInLearningMode); button2.SetBehavior(true, true, true); button2.Execute = ButtonAction.Button2_Execute; //Button3 InventorButton button3 = new InventorButton( "Messages", "InventorAddinServer.Button_" + Guid.NewGuid().ToString(), "Button 1 description", "See your Messages", icon3, icon3, CommandTypesEnum.kShapeEditCmdType, ButtonDisplayEnum.kDisplayTextInLearningMode); button3.SetBehavior(true, true, true); button3.Execute = ButtonAction.Button3_Execute; //Button4 InventorButton button4 = new InventorButton( "Beenden", "InventorAddinServer.Button_" + Guid.NewGuid().ToString(), "Button 1 description", "Beenden Sie die Session", icon4, icon4, CommandTypesEnum.kShapeEditCmdType, ButtonDisplayEnum.kDisplayTextInLearningMode); button4.SetBehavior(true, true, true); button4.Execute = ButtonAction.Button4_Execute; //Button5 InventorButton button5 = new InventorButton( "Username: \n Meeting-ID: ", "InventorAddinServer.Button_" + Guid.NewGuid().ToString(), "Button 1 description", "Info", icon5, icon5, CommandTypesEnum.kShapeEditCmdType, ButtonDisplayEnum.kDisplayTextInLearningMode); button5.SetBehavior(true, true, true); button5.Execute = ButtonAction.Button5_Execute; ButtonAction.InventorApp = m_inventorApplication; if (firstTime == true) { UserInterfaceManager uiMan = AddinGlobal.InventorApp.UserInterfaceManager; if (uiMan.InterfaceStyle == InterfaceStyleEnum.kRibbonInterface) //kClassicInterface support can be added if necessary. { /*Inventor.Ribbon ribbon = uiMan.Ribbons["Assem"];//["Part"]; * RibbonTab tab = ribbon.RibbonTabs["id_TabTools"]; //Change it if necessary.*/ //Assembly Inventor.Ribbons ribbon = uiMan.Ribbons; Inventor.Ribbon assemblyRibbon = ribbon["Assembly"]; RibbonTabs ribbonTabs = assemblyRibbon.RibbonTabs; RibbonTab tab = ribbonTabs["id_AddInsTab"]; //CommandBarList ContextMenuList/ CommandBar DefaultMenuBar AddinGlobal.RibbonPanelId = "{d04e0c45-dec6-4881-bd3f-a7a81b99f307}"; AddinGlobal.assemblyRibbonPanel = tab.RibbonPanels.Add( "AddOutButtons", "AddOutButtons.RibbonPanel_" + Guid.NewGuid().ToString(), AddinGlobal.RibbonPanelId, String.Empty, true); AddinGlobal.RibbonPanels.Add(AddinGlobal.assemblyRibbonPanel); CommandControls cmdCtrls = AddinGlobal.assemblyRibbonPanel.CommandControls; cmdCtrls.AddButton(button1.ButtonDef, button1.DisplayBigIcon, button1.DisplayText, "", button1.InsertBeforeTarget); cmdCtrls.AddButton(button2.ButtonDef, button2.DisplayBigIcon, button2.DisplayText, "", button2.InsertBeforeTarget); cmdCtrls.AddButton(button3.ButtonDef, button3.DisplayBigIcon, button3.DisplayText, "", button3.InsertBeforeTarget); cmdCtrls.AddButton(button4.ButtonDef, button4.DisplayBigIcon, button4.DisplayText, "", button4.InsertBeforeTarget); //Part Inventor.Ribbon partRibbon = ribbon["Part"]; RibbonTabs partRibbonTabs = partRibbon.RibbonTabs; RibbonTab modelRibbonTab = partRibbonTabs["id_AddInsTab"]; //CommandBarList ContextMenuList/ CommandBar DefaultMenuBar AddinGlobal.RibbonPanelId = "{d04e0c45-dec6-4881-bd3f-a7a81b99f307}"; AddinGlobal.partRibbonPanel = modelRibbonTab.RibbonPanels.Add( "AddOutButtons", "AddOutButtons.RibbonPanel_" + Guid.NewGuid().ToString(), AddinGlobal.RibbonPanelId, String.Empty, true); AddinGlobal.RibbonPanels.Add(AddinGlobal.partRibbonPanel); CommandControls pcmdCtrls = AddinGlobal.partRibbonPanel.CommandControls; pcmdCtrls.AddButton(button1.ButtonDef, button1.DisplayBigIcon, button1.DisplayText, "", button1.InsertBeforeTarget); pcmdCtrls.AddButton(button2.ButtonDef, button2.DisplayBigIcon, button2.DisplayText, "", button2.InsertBeforeTarget); pcmdCtrls.AddButton(button3.ButtonDef, button3.DisplayBigIcon, button3.DisplayText, "", button3.InsertBeforeTarget); pcmdCtrls.AddButton(button4.ButtonDef, button4.DisplayBigIcon, button4.DisplayText, "", button4.InsertBeforeTarget); //Drawing Inventor.Ribbon drawingRibbon = ribbon["Drawing"]; RibbonTabs drawingRibbonTabs = drawingRibbon.RibbonTabs; RibbonTab drawingRibbonTab = drawingRibbonTabs["id_AddInsTab"]; //CommandBarList ContextMenuList/ CommandBar DefaultMenuBar AddinGlobal.RibbonPanelId = "{d04e0c45-dec6-4881-bd3f-a7a81b99f307}"; AddinGlobal.drawingRibbonPanel = drawingRibbonTab.RibbonPanels.Add( "AddOutButtons", "AddOutButtons.RibbonPanel_" + Guid.NewGuid().ToString(), AddinGlobal.RibbonPanelId, String.Empty, true); AddinGlobal.RibbonPanels.Add(AddinGlobal.drawingRibbonPanel); CommandControls dcmdCtrls = AddinGlobal.drawingRibbonPanel.CommandControls; dcmdCtrls.AddButton(button1.ButtonDef, button1.DisplayBigIcon, button1.DisplayText, "", button1.InsertBeforeTarget); dcmdCtrls.AddButton(button2.ButtonDef, button2.DisplayBigIcon, button2.DisplayText, "", button2.InsertBeforeTarget); dcmdCtrls.AddButton(button3.ButtonDef, button3.DisplayBigIcon, button3.DisplayText, "", button3.InsertBeforeTarget); dcmdCtrls.AddButton(button4.ButtonDef, button4.DisplayBigIcon, button4.DisplayText, "", button4.InsertBeforeTarget); /* Get the 2d sketch environment base object * Inventor.Environment partSketchEnvironment; * partSketchEnvironment = userInterfaceManager.Environments["PMxPartSketchEnvironment"]; * * //make this command bar accessible in the panel menu for the 2d sketch environment. * partSketchEnvironment.PanelBar.CommandBarList.Add(slotCommandBar);*/ } } } catch (Exception e) { MessageBox.Show(e.ToString()); } // TODO: Add ApplicationAddInServer.Activate implementation. // e.g. event initialization, command creation etc. }
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); } } }