} //------------------------------------------------------------------------------ / // Callback Name: myInfoCB // This is a callback method associated with querying information for a UDO. // The information is printed in the listing window. //------------------------------------------------------------------------------ public static int myInfoCB(UserDefinedEvent infoEvent) { try { ListingWindow theLW = theSession.ListingWindow; theLW.Open(); theLW.WriteLine(" "); theLW.WriteLine("------------------------------------------------------------"); theLW.WriteLine("Begin Custom Information"); theLW.WriteLine(" "); theLW.WriteLine("UDO Class Name: '" + infoEvent.UserDefinedObject.UserDefinedClass.ClassName + "'"); theLW.WriteLine("UDO Friendly Name: '" + infoEvent.UserDefinedObject.UserDefinedClass.FriendlyName + "'"); double[] myUDOdoubles = infoEvent.UserDefinedObject.GetDoubles(); theLW.WriteLine("myUDOdoubles(0) = " + myUDOdoubles[0]); theLW.WriteLine("myUDOdoubles(1) = " + myUDOdoubles[1]); theLW.WriteLine("myUDOdoubles(2) = " + myUDOdoubles[2]); theLW.WriteLine(" "); theLW.WriteLine("End Custom Information"); } catch (NXOpen.NXException ex) { // ---- Enter your exception handling code here ----- UI.GetUI().NXMessageBox.Show("Caught exception", NXMessageBox.DialogType.Error, ex.Message); } return(0); }
//------------------------------------------------------------------------------ // Callback Name: myEditCB // This is a callback method associated with editing a UDO. //------------------------------------------------------------------------------ public static int myEditCB(UserDefinedEvent editEvent) { try { View myView = null; Point3d myCursor; myCursor.X = 0; myCursor.Y = 0; myCursor.Z = 0; // highlight the current udo we are about to edit // this is helpful if multiple udo's were on the selection // list when the user decided to edit them editEvent.UserDefinedObject.Highlight(); // ask the user to select a new origin for this UDO Selection.DialogResponse myResponse = theUI.SelectionManager.SelectScreenPosition("Select New Origin for C# UDO", out myView, out myCursor); // we are done asking the user for input... unhighlight the udo editEvent.UserDefinedObject.Unhighlight(); // use the new screen position (if the user picked one) if (myResponse == Selection.DialogResponse.Pick) { double[] myUDOdoubles = new double[3]; myUDOdoubles[0] = myCursor.X; myUDOdoubles[1] = myCursor.Y; myUDOdoubles[2] = myCursor.Z; // store the newly selected origin with the udo editEvent.UserDefinedObject.SetDoubles(myUDOdoubles); // add the udo to the display list manually // this will force the udo display to regenerate // immediately and show the changes we just made theUFSession.Disp.AddItemToDisplay (editEvent.UserDefinedObject.Tag); } } catch (NXOpen.NXException ex) { // ---- Enter your exception handling code here ----- UI.GetUI().NXMessageBox.Show("Caught exception", NXMessageBox.DialogType.Error, ex.Message); } return(0); } //------------------------------------------------------------------------------ /