- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all, I hope you are doing good.
I have developed an add-in in which I was able to create a button and add a image to the button. I tried searching for the code to implement opening of a form when the button is clicked in c#. There are references for the same using visual Basic but as I am beginner into inventor programming I was not able to convert into c#. So please can you write a code for only opening the form when the button is clicked.
I would Like to share my coded part until now.
m_inventorApplication = addInSiteObject.Application;
ControlDefinitions conDefs = m_inventorApplication.CommandManager.ControlDefinitions;
m_UserInterfaceEvents = m_inventorApplication.UserInterfaceManager.UserInterfaceEvents;
Ribbon ribbon = m_inventorApplication.UserInterfaceManager.Ribbons["Part"];
RibbonTab ribbonTab;
try
{
ribbonTab = ribbon.RibbonTabs["id_TabModel"];
}
catch (Exception)
{
ribbonTab = ribbon.RibbonTabs.Add("3D Model", "id_TabModel", Guid.NewGuid().ToString());
}
RibbonPanel ribbonPanel;
ribbonPanel = ribbonTab.RibbonPanels.Add("3D Objects", "id_PanelP_ModelObjects", Guid.NewGuid().ToString());
//string projectPath = System.IO.Directory.GetCurrentDirectory();
//string smallPicFileName = System.IO.Path.Combine(projectPath, "small.png");
//string bigPicFileName = System.IO.Path.Combine(projectPath, "big.png");
stdole.IPictureDisp smallPic = null;
stdole.IPictureDisp bigPic = null;
//System.Drawing.Bitmap small = new Bitmap(smallPicFileName);
//System.Drawing.Bitmap big = new Bitmap(bigPicFileName);
smallPic = PictureConverter.ImageToPictureDisp(Properties.Resources.small);
bigPic = PictureConverter.ImageToPictureDisp(Properties.Resources.big);
definition = conDefs.AddButtonDefinition("CageModeller", "id_CageModeller", Inventor.CommandTypesEnum.kShapeEditCmdType,
Guid.NewGuid().ToString(), "Feature to easily model the anticavitation Cage"
, "Cage Modeller" + "\n\n Feature to easily model the anticavitation Cage", smallPic, bigPic);
ribbonPanel.CommandControls.AddButton(definition);
Solved! Go to Solution.