Changes made not at all appearing in the ui

Changes made not at all appearing in the ui

Anonymous
Not applicable
1,554 Views
26 Replies
Message 1 of 27

Changes made not at all appearing in the ui

Anonymous
Not applicable

Hi all

 

i made some changes in the  sample addin code and it is not at all displaying changes in the ui, as a begginner im not at all expert in this 

can any one help me, 

Actually im trying to place a button in the ribbon of inventor and i placed a button.....here im attaching the code that i have done

 

thanks &regards

 

 

 

 

using System;
using System.Runtime.InteropServices;
using System.Drawing;
using System.Windows.Forms;
using Inventor;
using Microsoft.Win32;

namespace SimpleAddIn
{
/// <summary>
/// This is the primary AddIn Server class that implements the ApplicationAddInServer interface
/// that all Inventor AddIns are required to implement. The communication between Inventor and
/// the AddIn is via the methods on this interface.
/// </summary>

[GuidAttribute("963308E2-D850-466D-A1C5-503A2E171552")]
public class AddInServer : Inventor.ApplicationAddInServer
{
#region Data Members

//Inventor application object
private Inventor.Application m_inventorApplication;

//buttons
private AddSlotOptionButton m_addSlotOptionButton;
private DrawSlotButton m_drawSlotButton;
private ToggleSlotStateButton m_toggleSlotStateButton;

private ToggleSlotStateButton m_DemoButton;
//private Button m_SecondButton;
//private Button m_ThirdButton;
//private Button m_FourthButton;

 

//combo-boxes
private ComboBoxDefinition m_slotWidthComboBoxDefinition;
private ComboBoxDefinition m_slotHeightComboBoxDefinition;

//user interface event
private UserInterfaceEvents m_userInterfaceEvents;

// ribbon panel
RibbonPanel m_partSketchSlotRibbonPanel;

//event handler delegates
private Inventor.ComboBoxDefinitionSink_OnSelectEventHandler SlotWidthComboBox_OnSelectEventDelegate;
private Inventor.ComboBoxDefinitionSink_OnSelectEventHandler SlotHeightComboBox_OnSelectEventDelegate;

private Inventor.UserInterfaceEventsSink_OnResetCommandBarsEventHandler UserInterfaceEventsSink_OnResetCommandBarsEventDelegate;
private Inventor.UserInterfaceEventsSink_OnResetEnvironmentsEventHandler UserInterfaceEventsSink_OnResetEnvironmentsEventDelegate;
private Inventor.UserInterfaceEventsSink_OnResetRibbonInterfaceEventHandler UserInterfaceEventsSink_OnResetRibbonInterfaceEventDelegate;

#endregion

public AddInServer()
{
}

#region ApplicationAddInServer Members

public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime)
{
try
{
//the Activate 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;
Button.InventorApplication = m_inventorApplication;

//initialize event delegates
m_userInterfaceEvents = m_inventorApplication.UserInterfaceManager.UserInterfaceEvents;

UserInterfaceEventsSink_OnResetCommandBarsEventDelegate = new UserInterfaceEventsSink_OnResetCommandBarsEventHandler(UserInterfaceEvents_OnResetCommandBars);
m_userInterfaceEvents.OnResetCommandBars += UserInterfaceEventsSink_OnResetCommandBarsEventDelegate;

UserInterfaceEventsSink_OnResetEnvironmentsEventDelegate = new UserInterfaceEventsSink_OnResetEnvironmentsEventHandler(UserInterfaceEvents_OnResetEnvironments);
m_userInterfaceEvents.OnResetEnvironments += UserInterfaceEventsSink_OnResetEnvironmentsEventDelegate;

UserInterfaceEventsSink_OnResetRibbonInterfaceEventDelegate = new UserInterfaceEventsSink_OnResetRibbonInterfaceEventHandler(UserInterfaceEvents_OnResetRibbonInterface);
m_userInterfaceEvents.OnResetRibbonInterface += UserInterfaceEventsSink_OnResetRibbonInterfaceEventDelegate;

//load image icons for UI items
Icon addSlotOptionIcon = new Icon(this.GetType(), "AddSlotOption.ico");
Icon drawSlotIcon = new Icon(this.GetType(), "DrawSlot.ico");
Icon toggleSlotStateIcon = new Icon(this.GetType(), "ToggleSlotState.ico");

Icon m_DemoButtonIcon = new Icon(this.GetType(), "wren.ico");

//retrieve the GUID for this class
GuidAttribute addInCLSID;
addInCLSID = (GuidAttribute)GuidAttribute.GetCustomAttribute(typeof(AddInServer), typeof(GuidAttribute));
string addInCLSIDString;
addInCLSIDString = "{" + addInCLSID.Value + "}";

//create the comboboxes
m_slotWidthComboBoxDefinition = m_inventorApplication.CommandManager.ControlDefinitions.AddComboBoxDefinition("Wrench Width", "Autodesk:SimpleAddIn:SlotWidthCboBox", CommandTypesEnum.kShapeEditCmdType, 100, addInCLSIDString, "Slot width", "Slot width", Type.Missing, Type.Missing, ButtonDisplayEnum.kDisplayTextInLearningMode);
m_slotHeightComboBoxDefinition = m_inventorApplication.CommandManager.ControlDefinitions.AddComboBoxDefinition("Wrench Height", "Autodesk:SimpleAddIn:SlotHeightCboBox", CommandTypesEnum.kShapeEditCmdType, 100, addInCLSIDString, "Wrench height", "Wrench height", Type.Missing, Type.Missing, ButtonDisplayEnum.kDisplayTextInLearningMode);

//add some initial items to the comboboxes
m_slotWidthComboBoxDefinition.AddItem("1 cm", 0);
m_slotWidthComboBoxDefinition.AddItem("2 cm", 0);
m_slotWidthComboBoxDefinition.AddItem("3 cm", 0);
m_slotWidthComboBoxDefinition.AddItem("4 cm", 0);
m_slotWidthComboBoxDefinition.AddItem("5 cm", 0);
m_slotWidthComboBoxDefinition.ListIndex = 1;
m_slotWidthComboBoxDefinition.ToolTipText = m_slotWidthComboBoxDefinition.Text;
m_slotWidthComboBoxDefinition.DescriptionText = "Wrench width: " + m_slotWidthComboBoxDefinition.Text;

SlotWidthComboBox_OnSelectEventDelegate = new ComboBoxDefinitionSink_OnSelectEventHandler(SlotWidthComboBox_OnSelect);
m_slotWidthComboBoxDefinition.OnSelect += SlotWidthComboBox_OnSelectEventDelegate;

m_slotHeightComboBoxDefinition.AddItem("1 cm", 0);
m_slotHeightComboBoxDefinition.AddItem("2 cm", 0);
m_slotHeightComboBoxDefinition.AddItem("3 cm", 0);
m_slotHeightComboBoxDefinition.AddItem("4 cm", 0);
m_slotHeightComboBoxDefinition.AddItem("5 cm", 0);
m_slotHeightComboBoxDefinition.ListIndex = 1;
m_slotHeightComboBoxDefinition.ToolTipText = m_slotHeightComboBoxDefinition.Text;
m_slotHeightComboBoxDefinition.DescriptionText = "Wrench height: " + m_slotHeightComboBoxDefinition.Text;

SlotHeightComboBox_OnSelectEventDelegate = new ComboBoxDefinitionSink_OnSelectEventHandler(SlotHeightComboBox_OnSelect);
m_slotHeightComboBoxDefinition.OnSelect += SlotHeightComboBox_OnSelectEventDelegate;

//create buttons
m_addSlotOptionButton = new AddSlotOptionButton(
"Add Slot width/height", "Autodesk:SimpleAddIn:AddSlotOptionCmdBtn", CommandTypesEnum.kShapeEditCmdType,
addInCLSIDString, "Adds option for slot width/height",
"Add slot option", addSlotOptionIcon, addSlotOptionIcon, ButtonDisplayEnum.kDisplayTextInLearningMode);

m_drawSlotButton = new DrawSlotButton(
"Draw Slot", "Autodesk:SimpleAddIn:DrawSlotCmdBtn", CommandTypesEnum.kShapeEditCmdType,
addInCLSIDString, "Create slot sketch graphics",
"Draw Slot", drawSlotIcon, drawSlotIcon, ButtonDisplayEnum.kDisplayTextInLearningMode);

m_toggleSlotStateButton = new ToggleSlotStateButton(
"Toggle Slot State", "Autodesk:SimpleAddIn:ToggleSlotStateCmdBtn", CommandTypesEnum.kShapeEditCmdType,
addInCLSIDString, "Enables/Disables state of slot command",
"Toggle Slot State", toggleSlotStateIcon, toggleSlotStateIcon, ButtonDisplayEnum.kDisplayTextInLearningMode);

m_DemoButton = new ToggleSlotStateButton("Demo Button", "Autodesk:SimpleAddIn:m_DemoButton", CommandTypesEnum.kShapeEditCmdType,
addInCLSIDString, "Selection function",
"Demo Button", m_DemoButtonIcon, m_DemoButtonIcon, ButtonDisplayEnum.kDisplayTextInLearningMode);

 

//create the command category
CommandCategory slotCmdCategory = m_inventorApplication.CommandManager.CommandCategories.Add("Wrench", "Autodesk:SimpleAddIn:SlotCmdCat", addInCLSIDString);

slotCmdCategory.Add(m_slotWidthComboBoxDefinition);
slotCmdCategory.Add(m_slotHeightComboBoxDefinition);
slotCmdCategory.Add(m_addSlotOptionButton.ButtonDefinition);
slotCmdCategory.Add(m_drawSlotButton.ButtonDefinition);
slotCmdCategory.Add(m_toggleSlotStateButton.ButtonDefinition);

slotCmdCategory.Add(m_DemoButton.ButtonDefinition);

if (firstTime == true)
{
//access user interface manager
UserInterfaceManager userInterfaceManager;
userInterfaceManager = m_inventorApplication.UserInterfaceManager;

InterfaceStyleEnum interfaceStyle;
interfaceStyle = userInterfaceManager.InterfaceStyle;

//create the UI for classic interface
if (interfaceStyle == InterfaceStyleEnum.kClassicInterface)
{
//create toolbar
CommandBar slotCommandBar;
slotCommandBar = userInterfaceManager.CommandBars.Add("Wrench", "Autodesk:SimpleAddIn:SlotToolbar", CommandBarTypeEnum.kRegularCommandBar, addInCLSIDString);

//add comboboxes to toolbar
slotCommandBar.Controls.AddComboBox(m_slotWidthComboBoxDefinition, 0);
slotCommandBar.Controls.AddComboBox(m_slotHeightComboBoxDefinition, 0);

//add buttons to toolbar
slotCommandBar.Controls.AddButton(m_addSlotOptionButton.ButtonDefinition, 0);
slotCommandBar.Controls.AddButton(m_drawSlotButton.ButtonDefinition, 0);
slotCommandBar.Controls.AddButton(m_toggleSlotStateButton.ButtonDefinition, 0);

slotCommandBar.Controls.AddButton(m_DemoButton.ButtonDefinition, 0);

//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);
}
//create the UI for ribbon interface
else
{
//get the ribbon associated with part document
Inventor.Ribbons ribbons;
ribbons = userInterfaceManager.Ribbons;

Inventor.Ribbon partRibbon;
partRibbon = ribbons["Part"];

//get the tabls associated with part ribbon
RibbonTabs ribbonTabs;
ribbonTabs = partRibbon.RibbonTabs;

RibbonTab partSketchRibbonTab;
partSketchRibbonTab = ribbonTabs["id_TabSketch"];

//create a new panel with the tab
RibbonPanels ribbonPanels;
ribbonPanels = partSketchRibbonTab.RibbonPanels;

m_partSketchSlotRibbonPanel = ribbonPanels.Add("Wrench", "Autodesk:SimpleAddIn:SlotRibbonPanel", "{DB59D9A7-EE4C-434A-BB5A-F93E8866E872}", "", false);

//add controls to the slot panel
CommandControls partSketchSlotRibbonPanelCtrls;
partSketchSlotRibbonPanelCtrls = m_partSketchSlotRibbonPanel.CommandControls;

//add the combo boxes to the ribbon panel
CommandControl slotWidthCmdCboBoxCmdCtrl;
slotWidthCmdCboBoxCmdCtrl = partSketchSlotRibbonPanelCtrls.AddComboBox(m_slotWidthComboBoxDefinition, "", false);

CommandControl slotHeightCmdCboBoxCmdCtrl;
slotHeightCmdCboBoxCmdCtrl = partSketchSlotRibbonPanelCtrls.AddComboBox(m_slotHeightComboBoxDefinition, "", false);

//add the buttons to the ribbon panel
CommandControl drawSlotCmdBtnCmdCtrl;
drawSlotCmdBtnCmdCtrl = partSketchSlotRibbonPanelCtrls.AddButton(m_drawSlotButton.ButtonDefinition, false, true, "", false);


CommandControl slotOptionCmdBtnCmdCtrl;
slotOptionCmdBtnCmdCtrl = partSketchSlotRibbonPanelCtrls.AddButton(m_addSlotOptionButton.ButtonDefinition, false, true, "", false);

CommandControl toggleSlotStateCmdBtnCmdCtrl;
toggleSlotStateCmdBtnCmdCtrl = partSketchSlotRibbonPanelCtrls.AddButton(m_toggleSlotStateButton.ButtonDefinition, false,true, "", false);


CommandControl m_DemoButtonCmdBtnCmdCtrl;
m_DemoButtonCmdBtnCmdCtrl = partSketchSlotRibbonPanelCtrls.AddButton(m_DemoButton.ButtonDefinition, false, true, "", false);
}
}

MessageBox.Show ("To access the commands of the sample addin, activate a 2d sketch of a part \n document and select the \"AddInSlot\" toolbar within the panel menu");
}
catch(Exception e)
{
MessageBox.Show(e.ToString());
}
}

public void Deactivate()
{
//the Deactivate 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

try
{
m_userInterfaceEvents.OnResetCommandBars -= UserInterfaceEventsSink_OnResetCommandBarsEventDelegate;
m_userInterfaceEvents.OnResetEnvironments -= UserInterfaceEventsSink_OnResetEnvironmentsEventDelegate;

UserInterfaceEventsSink_OnResetCommandBarsEventDelegate = null;
UserInterfaceEventsSink_OnResetEnvironmentsEventDelegate = null;
m_userInterfaceEvents = null;
if (m_partSketchSlotRibbonPanel != null )
{
m_partSketchSlotRibbonPanel.Delete();
}

//release inventor Application object
Marshal.ReleaseComObject(m_inventorApplication);
m_inventorApplication = null;

GC.WaitForPendingFinalizers();
GC.Collect();
}
catch(Exception e)
{
MessageBox.Show(e.ToString());
}
}

public void ExecuteCommand(int CommandID)
{
//this method was used to notify when an AddIn command was executed
//the CommandID parameter identifies the command that was executed

//Note:this method is now obsolete, you should use the new
//ControlDefinition objects to implement commands, they have
//their own event sinks to notify when the command is executed
}

public object Automation
{
//if you want to return an interface to another client of this addin,
//implement that interface in a class and return that class object
//through this property

get
{
return null;
}
}

private void UserInterfaceEvents_OnResetCommandBars(ObjectsEnumerator commandBars, NameValueMap context)
{
try
{
CommandBar commandBar;
for (int commandBarCt = 1; commandBarCt <= commandBars.Count; commandBarCt++)
{
commandBar = (Inventor.CommandBar)commandBars[commandBarCt];
if (commandBar.InternalName == "Autodesk:SimpleAddIn:SlotToolbar")
{
//add comboboxes to toolbar
commandBar.Controls.AddComboBox(m_slotWidthComboBoxDefinition, 0);
commandBar.Controls.AddComboBox(m_slotHeightComboBoxDefinition, 0);

//add buttons to toolbar
commandBar.Controls.AddButton(m_addSlotOptionButton.ButtonDefinition, 0);
commandBar.Controls.AddButton(m_drawSlotButton.ButtonDefinition, 0);
commandBar.Controls.AddButton(m_toggleSlotStateButton.ButtonDefinition, 0);

commandBar.Controls.AddButton(m_DemoButton.ButtonDefinition, 0);

return;
}
}
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
}

private void UserInterfaceEvents_OnResetEnvironments(ObjectsEnumerator environments, NameValueMap context)
{
try
{
Inventor.Environment environment;
for (int environmentCt = 1; environmentCt <= environments.Count; environmentCt++)
{
environment = (Inventor.Environment)environments[environmentCt];
if (environment.InternalName == "PMxPartSketchEnvironment")
{
//make this command bar accessible in the panel menu for the 2d sketch environment.
environment.PanelBar.CommandBarList.Add(m_inventorApplication.UserInterfaceManager.CommandBars["Autodesk:SimpleAddIn:SlotToolbar"]);

return;
}
}
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
}

private void UserInterfaceEvents_OnResetRibbonInterface(NameValueMap context)
{
try
{

UserInterfaceManager userInterfaceManager;
userInterfaceManager = m_inventorApplication.UserInterfaceManager;

//get the ribbon associated with part document
Inventor.Ribbons ribbons;
ribbons = userInterfaceManager.Ribbons;

Inventor.Ribbon partRibbon;
partRibbon = ribbons["Part"];

//get the tabls associated with part ribbon
RibbonTabs ribbonTabs;
ribbonTabs = partRibbon.RibbonTabs;

RibbonTab partSketchRibbonTab;
partSketchRibbonTab = ribbonTabs["id_TabSketch"];

//create a new panel with the tab
RibbonPanels ribbonPanels;
ribbonPanels = partSketchRibbonTab.RibbonPanels;

m_partSketchSlotRibbonPanel = ribbonPanels.Add("Wrench", "Autodesk:SimpleAddIn:SlotRibbonPanel", "{DB59D9A7-EE4C-434A-BB5A-F93E8866E872}", "", false);

//add controls to the slot panel
CommandControls partSketchSlotRibbonPanelCtrls;
partSketchSlotRibbonPanelCtrls = m_partSketchSlotRibbonPanel.CommandControls;

//add the combo boxes to the ribbon panel
CommandControl slotWidthCmdCboBoxCmdCtrl;
slotWidthCmdCboBoxCmdCtrl = partSketchSlotRibbonPanelCtrls.AddComboBox(m_slotWidthComboBoxDefinition, "", false);

CommandControl slotHeightCmdCboBoxCmdCtrl;
slotHeightCmdCboBoxCmdCtrl = partSketchSlotRibbonPanelCtrls.AddComboBox(m_slotHeightComboBoxDefinition, "", false);

//add the buttons to the ribbon panel
CommandControl drawSlotCmdBtnCmdCtrl;
drawSlotCmdBtnCmdCtrl = partSketchSlotRibbonPanelCtrls.AddButton(m_drawSlotButton.ButtonDefinition, false, true, "", false);

CommandControl slotOptionCmdBtnCmdCtrl;
slotOptionCmdBtnCmdCtrl = partSketchSlotRibbonPanelCtrls.AddButton(m_addSlotOptionButton.ButtonDefinition, false, true, "", false);

CommandControl toggleSlotStateCmdBtnCmdCtrl;
toggleSlotStateCmdBtnCmdCtrl = partSketchSlotRibbonPanelCtrls.AddButton(m_toggleSlotStateButton.ButtonDefinition, false, true, "", false);

CommandControl m_DemoButtonCmdBtnCmdCtrl;
m_DemoButtonCmdBtnCmdCtrl = partSketchSlotRibbonPanelCtrls.AddButton(m_DemoButton.ButtonDefinition, false, true, "", false);

}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
}

private void SlotWidthComboBox_OnSelect(NameValueMap context)
{
m_slotWidthComboBoxDefinition.ToolTipText = m_slotWidthComboBoxDefinition.Text;
m_slotWidthComboBoxDefinition.DescriptionText = "Wrench width: " + m_slotWidthComboBoxDefinition.Text;
}

private void SlotHeightComboBox_OnSelect(NameValueMap context)
{
m_slotHeightComboBoxDefinition.ToolTipText = m_slotHeightComboBoxDefinition.Text;
m_slotHeightComboBoxDefinition.DescriptionText = "Wrench height: " + m_slotHeightComboBoxDefinition.Text;
}

#endregion
}
}

0 Likes
1,555 Views
26 Replies
Replies (26)
Message 2 of 27

Owner2229
Advisor
Advisor
Accepted solution

Hi, wow, well good luck to the one who'll go throught it.

 

You shouldn't be writing "all in one" code.

You have to separate it atleast in sections like:

Modules

Sub Procedures

Functions

 

In THIS thread (marked as solution) is shown the basic sorting of modules and Sub Procedures.

You can't directly use it as it is written in VB instead of your C#.

 

Basicaly, you should first write just few lines of code with basic functionality. Test it. And if it works, write more code if needed.

If one Sub procedure is longer than 10 lines, consider spliting it in more Subs and/of Functions.

 

So I would suggest you starting all over with the template and maybe some tutorials, like Modthemachine and MyFirstPlugin

It might be worth for the sake of practise.

 

Even it might seem different, I'm not trying to be rude, just honest. If I have offended you somehow, please feel free to ignore my comment.

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
Message 3 of 27

Anonymous
Not applicable
Hi,
Thanks for your replay, any way as per your suggestion i will try create it in modules, expecting your help in future
Thanks&regards
0 Likes
Message 4 of 27

Owner2229
Advisor
Advisor

Wise move, I believe you won't regret it. I'll be waiting for the update about your progress 🙂

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
Message 5 of 27

Anonymous
Not applicable
Hi Mike,

i successfully placed a button in the tab,

now i really want to place a new ribbon tab,can you help me ,do you have any reference to do this

Thanks & Regards
0 Likes
Message 6 of 27

Owner2229
Advisor
Advisor
Accepted solution

Hi, I'm more like VB oriented, but you can try to tweak this out:

 

// List of some basic Ribbon panels
// "Assembly" > "id_TabAssemble"
// "Part"     > "id_TabModel"
// "Drawing"  > "id_TabPlaceViews"
// "ZeroDoc"  > "id_GetStarted"
Inventor.UserInterfaceManager UIManager UIManager = InventorApplication.UserInterfaceManager
Inventor.Ribbon assemblyRibbon assemblyRibbon = UIManager.Ribbons.Item("Assembly")
Inventor.RibbonTab assembleTab assembleTab = assemblyRibbon.RibbonTabs.Item("id_TabAssemble")
Inventor.RibbonPanel panel Try {
// addInCLSIDString is the GuidAttribute of your addin and should be replaced by the actual reference panel = assembleTab.RibbonPanels.Add("MySuperBar", "MySuperBar_Panel", addInCLSIDString) } Catch { panel = assembleTab.RibbonPanels.Item("MySuperBar_Panel") }
// intead of m_ButtonDefinition write the actual button definition you're ussing to add the button panel.CommandControls.AddButton(m_ButtonDefinition, True) // true for big button

 

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
Message 7 of 27

Anonymous
Not applicable

Hi Mike ,

 

thanks for your valuable support,

 

i used the code that you mentioned ,thanks for the code

 

i attached an image, their is a tab called vault and my aim is to create a tab like valut and place some 

 

panels their for login and log out buttons.

 

can you specify a solution for creating a item like vault in inventor

 

with your support i create panels and place buttons ..once  again thanks for your valuable support 

 

Regards

 

 

0 Likes
Message 8 of 27

Owner2229
Advisor
Advisor

Alright then, let's just add some lines to your current code:

 

// List of some basic Ribbon panels
// "Assembly" > "id_TabAssemble"
// "Part"     > "id_TabModel"
// "Drawing"  > "id_TabPlaceViews"
// "ZeroDoc"  > "id_GetStarted"

Inventor.UserInterfaceManager UIManager
UIManager = InventorApplication.UserInterfaceManager

Inventor.Ribbon assemblyRibbon
assemblyRibbon = UIManager.Ribbons.Item("Assembly")

// Get or create Ribbon Tab Inventor.RibbonTab assembleTab
Try
{ assembleTab = assemblyRibbon.RibbonTabs.Item("id_MyOwnTab") }
Catch
{
// DisplayName, InternalName, ClientID, TargetTab, InsertBeforeTarget, Contextual
assembleTab = assemblyRibbon.RibbonTabs.Add("MyOwnTab", "id_MyOwnTab", addInCLSIDString, _
"id_TabAssemble", False, False)
}

// Get or create Ribbon Panel Inventor.RibbonPanel panel Try { // addInCLSIDString is the GuidAttribute of your addin and should be replaced by the actual reference panel = assembleTab.RibbonPanels.Add("MySuperBar", "MySuperBar_Panel", addInCLSIDString) } Catch { panel = assembleTab.RibbonPanels.Item("MySuperBar_Panel") }
// Add button // Intead of m_ButtonDefinition write the actual button definition you're ussing to add the button panel.CommandControls.AddButton(m_ButtonDefinition, True) // true for big button
Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 9 of 27

Anonymous
Not applicable

Hi mike,

i used the code that you given, but unfortunately it wont works , i used this code

 

 

 

Inventor.UserInterfaceManager UIManager;
UIManager = m_inventorApplication.UserInterfaceManager;

Inventor.Ribbon assemblyRibbon;
assemblyRibbon = UIManager.Ribbons["Part"];

Inventor.RibbonTab assembleTab;
try
{
assembleTab = assemblyRibbon.RibbonTabs["id_MyOwnTab"];

}
catch
{
// DisplayName, InternalName, ClientID, TargetTab, InsertBeforeTarget, Contextual
assembleTab = assemblyRibbon.RibbonTabs.Add("MyOwnTab", "id_MyOwnTab", addInCLSIDString, "id_TabModel", false, false);

}

Inventor.RibbonPanel panel;
try
{
// addInCLSIDString is the GuidAttribute of your addin and should be replaced by the actual reference
panel = assembleTab.RibbonPanels.Add("MySuperBar", "MySuperBar_Panel", addInCLSIDString);
}
catch
{
panel = assembleTab.RibbonPanels["MySuperBar_Panel"];
}

 

0 Likes
Message 10 of 27

Owner2229
Advisor
Advisor

Hi, I have tested by VB.Net version and I have found that it only works with "InsertBeforeTarget" set as true. Interesting...

 

Inventor.UserInterfaceManager UIManager;
UIManager = m_inventorApplication.UserInterfaceManager;
Inventor.Ribbon assemblyRibbon;
assemblyRibbon = UIManager.Ribbons["Part"];
Inventor.RibbonTab assembleTab;
try
{
assembleTab = assemblyRibbon.RibbonTabs["id_MyOwnTab"];

}
catch
{
// DisplayName, InternalName, ClientID, TargetTab, InsertBeforeTarget, Contextual
assembleTab = assemblyRibbon.RibbonTabs.Add("MyOwnTab", "id_MyOwnTab", addInCLSIDString, "id_TabModel", true, false);
}
Inventor.RibbonPanel panel;
try
{
// addInCLSIDString is the GuidAttribute of your addin and should be replaced by the actual reference
panel = assembleTab.RibbonPanels.Add("MySuperBar", "MySuperBar_Panel", addInCLSIDString);
}
catch
{
panel = assembleTab.RibbonPanels["MySuperBar_Panel"];
}

Here are all the Ribbon Panel's names, so you can find the one you need:   RibbonTabs

 

BTW: Are you ussing this "as it is" or as a Sub Procedure with variables instead of texts?

 

You can also try this, as the last three parameters are optional:

 

assembleTab = assemblyRibbon.RibbonTabs.Add("MyOwnTab", "id_MyOwnTab", addInCLSIDString, null, null, null);
Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
Message 11 of 27

Anonymous
Not applicable
Hi Mike,

I used the same code,but the ribbon tab is not generated,can you please share a simple code that you create a ribbon tab......as per your suggestions i created panel and place buttons their....thanks for your valuable support
Regards
Linoy
0 Likes
Message 12 of 27

Anonymous
Not applicable

Hi Mike,

I used the same code,but the ribbon tab is not generated,can you please share a simple code that you create a ribbon tab......as per your suggestions i created panel and place buttons their....thanks for your valuable support
Regards
Linoy

0 Likes
Message 13 of 27

Owner2229
Advisor
Advisor
Accepted solution

Hi, the highlighted line creates the Ribbon tab. Btw. in the code you send was misssing the last line, the one that was creating the button. Without the button is the tab invisible.

 

Inventor.UserInterfaceManager UIManager;
UIManager = m_inventorApplication.UserInterfaceManager;
Inventor.Ribbon assemblyRibbon;
assemblyRibbon = UIManager.Ribbons["Part"];
Inventor.RibbonTab assembleTab;
try
{
assembleTab = assemblyRibbon.RibbonTabs["id_MyOwnTab"];

}
catch
{
// DisplayName, InternalName, ClientID, TargetTab, InsertBeforeTarget, Contextual
assembleTab = assemblyRibbon.RibbonTabs.Add("MyOwnTab", "id_MyOwnTab", addInCLSIDString, "id_TabModel", true, false);
}
Inventor.RibbonPanel panel;
try
{
// addInCLSIDString is the GuidAttribute of your addin and should be replaced by the actual reference
panel = assembleTab.RibbonPanels.Add("MySuperBar", "MySuperBar_Panel", addInCLSIDString);
}
catch
{
panel = assembleTab.RibbonPanels["MySuperBar_Panel"];
}

// intead of m_ButtonDefinition write the actual button definition you're ussing to add the button panel.CommandControls.AddButton(m_ButtonDefinition, True) // true for big button
Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
Message 14 of 27

Anonymous
Not applicable
Hi Mike

Finally i got the output, i forgot to place the button , the tab will be displayed with at least one button right?..thanks for your support .
Thanks& regards
Linoy Joseph
0 Likes
Message 15 of 27

Owner2229
Advisor
Advisor

You're welcomed. Ribbon seems to not support empty tabs, so there have to be an button for it to be visible.

 

Good luck with the rest of your code and feel free to post here or in new thread if you'll need further help. Smiley Happy

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 16 of 27

Anonymous
Not applicable

Hi Mike,

 

How can we checkin and checkout inventor files (iam,ipt) to third party softwares.

 

Here im trying to do is placed some buttons in inventor tab to checkout  files that stored in our product

 

and after the changes made we need to checkin files back....How can it made possible...i hope u can help mee

 

Thanks

 

Linoy Joseph

0 Likes
Message 17 of 27

Owner2229
Advisor
Advisor

Hi, I'm not realy sure what kind of checkin / checkout you have on mind. Do you mean:

1) Autodesk Vault checkin / checkout

2) Locking / unlocking the parts for write

3) Import / export external document type (e.g. step)

4) Download / upload the documents from / to web servise (e.g. cloud storage)

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 18 of 27

Anonymous
Not applicable
hi
Yeah, im planning to create a vault that is similar to Autodesk Vault checkin / checkout . Here i need a login, logout, checkin, checkout facilities with our product..
How can it possible?
Regards
Linoy
0 Likes
Message 19 of 27

Owner2229
Advisor
Advisor
Accepted solution

Hi, it sure is possible, it's just the matter of tools.

I assume you do want some kind of security in this, as you want the users to log-in to this service.

Where woul'd you like to store this information:

1) User database

2) Lock tags

 

Do you have acces to some kind of database? Like SQL or something you're ussing there.

It would be the best to store this information there.

If not, do you atleast have some kind of server, where you can set up permissions?

 

So the options are:

 

For User database:

A) Server database

B) Encrypted read-only database file in dedicated folder on server, inaccesible for users.

 

For Lock tags:

A) Server database

B) Encrypted read-only database file in dedicated folder on server, inaccesible for users.

C) Lock file saved for each project in it's main workfolder.

D) Lock state saved in the part/assembly. I wouldn't recoment this option at all, as it will be slow AF.

    Reading the "can I open it" would take some minutes for large assemblies.

    Locking and unlocking them might take up to hours for large assemblies.

 

There's also an option to make it as web-based service, so your coleagues could use it "out-of-office" (e.g. from home), but there's not much I can help you with in this case. We can still make it accesible for "out-of-office" work but it would require exposing the server to the internet.

 

Eighter way, this "project" of yours might be quite time consuming...

Especialy if you want me do give you the solution as whole.

One thing is showing examples and the other is creating this type of complex solution.

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
Message 20 of 27

Anonymous
Not applicable
hi,
Ya sure, i already have a database , and need to set a security using login,

Now i really want to know if i select an Assembly file (.iam) is there any methods to select all its reference files and sub files. In the checkin or checkout if i select an .iam file need to select all its reference files and Sub files like part(ipt) , all related files...is ther any method for passing the .iam file name and returns all its related files in c# code....if you have, can you please share it
Regards
Linoy Joseph
0 Likes