Zoes
Mechanical
- Sep 30, 2011
- 46
Hi there,
Any ideas mapping menu buttons to c# with NXOpen? I thick I'm on the right track but I'm not sure. The code below tries to map the menu button "Create Rectangle" to a window forms button:
namespace sth
{
public partial class Someform : Form
{
public NXOpen.UI theUI = NXOpen.UI.GetUI();
public Session theSession = Session.GetSession();
public UFSession theUfSession = UFSession.GetUFSession();
public NXOpen.Session.UndoMarkId Id2;
public int nErrs1;
public DisplayModification displayModification1;
public Part workPart;
public Part displayPart;
public NXOpen.MenuBar.MenuButton myButton;
public Someform()
{
InitializeComponent();
workPart = theSession.Parts.Work;
displayPart = theSession.Parts.Display;
NXOpen.MenuBar.MenuButton myButton = theUI.MenuBarManager.GetButtonFromName("Create Rectangle");
this.myButton = form_btn;
}
private void form_btn_Click(object sender, EventArgs e)
{
try
{
// Update part
theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Create Rectangle");
nErrs1 = theSession.UpdateManager.DoUpdate(Id2);
lw.WriteLine("button clicked" + "\r\n");
}
catch (Exception ex)
{
MessageBox.Show("Error is : " + ex);
}
}
}}
Any ideas mapping menu buttons to c# with NXOpen? I thick I'm on the right track but I'm not sure. The code below tries to map the menu button "Create Rectangle" to a window forms button:
namespace sth
{
public partial class Someform : Form
{
public NXOpen.UI theUI = NXOpen.UI.GetUI();
public Session theSession = Session.GetSession();
public UFSession theUfSession = UFSession.GetUFSession();
public NXOpen.Session.UndoMarkId Id2;
public int nErrs1;
public DisplayModification displayModification1;
public Part workPart;
public Part displayPart;
public NXOpen.MenuBar.MenuButton myButton;
public Someform()
{
InitializeComponent();
workPart = theSession.Parts.Work;
displayPart = theSession.Parts.Display;
NXOpen.MenuBar.MenuButton myButton = theUI.MenuBarManager.GetButtonFromName("Create Rectangle");
this.myButton = form_btn;
}
private void form_btn_Click(object sender, EventArgs e)
{
try
{
// Update part
theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Create Rectangle");
nErrs1 = theSession.UpdateManager.DoUpdate(Id2);
lw.WriteLine("button clicked" + "\r\n");
}
catch (Exception ex)
{
MessageBox.Show("Error is : " + ex);
}
}
}}