Changes made not at all appearing in the ui

Changes made not at all appearing in the ui

Anonymous
Not applicable
1,570 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,571 Views
26 Replies
Replies (26)
Message 21 of 27

Owner2229
Advisor
Advisor
Accepted solution

Hi, for the log-in, log-out:

It can be done more-lessly on the AddIn side:

0) If someone attempts to open an part, the addin will stop this action.

1) The user will write in UserName and Password and click Log-In.

2) The Addin will check if the data matches with the ones stored in database.

3) If it matches it'll grant the user the right to open files.

    It can be simple shared flag in the addin, which will the addin check every time the user tries to open something.

 

 

The workflow for locking models should be:

1) Someone wants to open a part / assembly (model)

2) Your AddIn checks the database if the model is locked.

3) If it isn't locked it'll first tell the database it now is locked (we do it before opening becouse opening takes time in which another user might attepmt to open the model) and then open it.

4) When the user is done with the model (he closed it). The AddIn tels the database it is now unlocked.

 

You should also store in the database who has locked it.

If the PC or Inventor of the user who had the model open crashes, no-one would be able to open the model.

So the AddIn should check who's the user who has it open and if it is the user who's attempting to open it, it'll let him.

 

 

Here is the code that goes throught each Sub-Assembly and part in Assembly.

 

Inventor.Document oDoc;
oDoc = m_inventorApplication.ActiveDocument;
If (oDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject)
{
    ForEach (Inventor.Document aDoc In oDoc.AllReferencedDocuments)
{ // Here we can do whatever we want with each of the documents
MessageBox.Show(aDoc.FullFileName);
}
}

 

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 22 of 27

Owner2229
Advisor
Advisor
Accepted solution

Btw. In order to get all the referenced documents (aDoc) you muss have the source document (oDoc) open.

I've done some research about this and it is not possible other way, you muss have it open in Inventor or in Apprentice Server.

So you should "lock" the source document before you start opening it and then lock all referenced files once it is open.

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 23 of 27

Anonymous
Not applicable
Hi Mike

Is it possible to retrieve the file path of each file using this foreach?? If so, How?

Regards
Linoy Joseph
0 Likes
Message 24 of 27

Owner2229
Advisor
Advisor

You wont get anything better than "FullFileName", so you have to scope it.

 

Inventor.Document oDoc;
oDoc = m_inventorApplication.ActiveDocument;
If (oDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject)
{
    ForEach (Inventor.Document aDoc In oDoc.AllReferencedDocuments)
    {
String FileName;
FileName = aDoc.FullFileName

Integer FNP;
FNP = FileName.LastIndexOf("\"); // I'm not sure if it is "\" or "\\" in C#
String FolderName;
FolderName
= FileName.SubString(0, FNP);
MessageBox.Show(FolderName);
}
}

 

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 25 of 27

Anonymous
Not applicable
Hi Mike,

Thanks for the code,

is it possible to display the display ribbon tab in the opening of inventor, in my code base the it can be seen when we selecting an ipt file, i want to see the ribbon tab in the default opening of inventor like the 'vault' menu
my ui code like this :

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;


Regards
Linoy Joseph
0 Likes
Message 26 of 27

Owner2229
Advisor
Advisor
Accepted solution

HIi, you can use the previously posted code, just with "ZeroDoc".

 

This code will create new tab:

Inventor.UserInterfaceManager UIManager;
UIManager = m_inventorApplication.UserInterfaceManager;
Inventor.Ribbon assemblyRibbon;
assemblyRibbon = UIManager.Ribbons["ZeroDoc"];
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

 

And this one will create new panel on "GetStarted" tab:

Inventor.UserInterfaceManager UIManager;
UIManager = m_inventorApplication.UserInterfaceManager;
Inventor.Ribbon assemblyRibbon;
assemblyRibbon = UIManager.Ribbons["ZeroDoc"];
Inventor.RibbonTab assembleTab;
assembleTab = assemblyRibbon.RibbonTabs["id_GetStarted"];
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 27 of 27

Anonymous
Not applicable

Hi Mike

it works...Thanks

I placed a button 'add' to the panel now im trying to do ,when i click on add button i want to add current '.iam' file and all its reference file to add in to another documentation area. Thats what im trying to do...
As the first step i want to created a button event
My button definition is like :

 

m_AddButton = new ToggleSlotStateButton(
"Add", "Autodesk:SimpleAddIn:m_AddButton", CommandTypesEnum.kShapeEditCmdType,
addInCLSIDString, "Add to Wrench",
"Add", drawSlotIcon, drawSlotIcon, ButtonDisplayEnum.kAlwaysDisplayText);

 

and i wrote event definition to select the active document and its refrence documents :

 

 

private void m_AddButton_OnSelect(NameValueMap context)
{
Inventor.Document oDoc;
oDoc = m_inventorApplication.ActiveDocument;
if(oDoc.DocumentType == DocumentTypeEnum.kAssemblyDocumentObject)
{
foreach (Inventor.Document aDoc in oDoc.AllReferencedDocuments)
{
String FileName;
FileName = aDoc.FullFileName;
int FNP;
FNP = FileName.LastIndexOf("\\");
//String FolderName;
//FolderName = FileName.SubString(0, FNP);
MessageBox.Show(FileName);
}
}
}

 

is it possible with above code??

 

Regards

Linoy Joseph

 

0 Likes