private void Form1_Load(object sender, System.EventArgs e) { try { mApp = (Inventor.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application"); foreach (ApplicationAddIn oAddIn in mApp.ApplicationAddIns) { try { //Fills up at runtime our addins combobox if ((oAddIn.AddInType == ApplicationAddInTypeEnum.kTranslationApplicationAddIn)) { ComboAddinsItem newItem = new ComboAddinsItem(oAddIn.DisplayName, oAddIn.ClassIdString); ComboAddIns.Items.Add(newItem); } } catch { //Exception can be thrown if "AddInType", "DisplayName" or "ClassIdString" properties //are not implemented. For a custom addin for example. continue; } } ComboAddIns.SelectedIndex = 0; } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("Error: Inventor must be running..."); Button1.Enabled = false; return; } }
private void Form1_Load(object sender, System.EventArgs e) { try { mApp = (Inventor.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application"); foreach (ApplicationAddIn oAddIn in mApp.ApplicationAddIns) { try { //Fills up at runtime our addins combobox if ((oAddIn.AddInType == ApplicationAddInTypeEnum.kTranslationApplicationAddIn)) { ComboAddinsItem newItem = new ComboAddinsItem(oAddIn.DisplayName, oAddIn.ClassIdString); ComboAddIns.Items.Add(newItem); } } catch { //Exception can be thrown if "AddInType", "DisplayName" or "ClassIdString" properties //are not implemented. For a custom addin for example. continue; } } ComboAddIns.SelectedIndex = 0; } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("Error: Inventor must be running..."); Button1.Enabled = false; return; } }
private void Button1_Click(System.Object sender, System.EventArgs e) { NameValueMap options = null; OptionsView.Items.Clear(); ComboAddinsItem item = (ComboAddinsItem)ComboAddIns.SelectedItem; if ((GetTranslatorSaveAsOptions(item.clsId, ref options))) { ListViewGroup saveGroup = OptionsView.Groups["GroupSaveOpts"]; int idx = 0; for (idx = 1; idx <= options.Count; idx++) { ListViewItem listviewItem = default(ListViewItem); listviewItem = OptionsView.Items.Add(options.Name[idx]); listviewItem.SubItems.Add(options.Value[options.Name[idx]].ToString()); listviewItem.Group = saveGroup; } } if ((GetTranslatorOpenOptions(item.clsId, ref options))) { ListViewGroup openGroup = OptionsView.Groups["GroupOpenOpts"]; int idx = 0; for (idx = 1; idx <= options.Count; idx++) { ListViewItem listviewItem = default(ListViewItem); listviewItem = OptionsView.Items.Add(options.Name[idx]); listviewItem.SubItems.Add(options.Value[options.Name[idx]].ToString()); listviewItem.Group = openGroup; } } }