static GH_UserDefinedObject() { try { Console.WriteLine("注册"); // Define your custom UDO class GHFeatureClass = TheSession.UserDefinedClassManager.CreateUserDefinedObjectClass ("GHFeature", "Object Created From Grasshopper"); // Setup properties on the custom UDO class GHFeatureClass.AllowQueryClassFromName = UserDefinedClass.AllowQueryClass.On; // Register callbacks for the UDO class // GHFeature.AddDisplayHandler(new UserDefinedClass.DisplayCallback(Program.myDisplayCB)); // GHFeature.AddAttentionPointHandler(new UserDefinedClass.DisplayCallback(Program.myDisplayCB)); // GHFeature.AddFitHandler(new UserDefinedClass.DisplayCallback //(Program.myDisplayCB)); // GHFeature.AddSelectionHandler(new //UserDefinedClass.DisplayCallback(Program.myDisplayCB)); // GHFeature.AddEditHandler(new UserDefinedClass.GenericCallback(Program.myEditCB)); // GHFeature.AddInformationHandler(new //UserDefinedClass.GenericCallback(Program.myInfoCB)); // Add this class to the list of object types available for selection in NX. // If you skip this step you won't be able to select UDO's of this class, // even though you registered a selection callback. TheUI.SelectionManager.SetSelectionStatusOfUserDefinedClass(GHFeatureClass, true); } catch (NXOpen.NXException ex) { // ---- Enter your exception handling code here ----- TheUI.NXMessageBox.Show("Caught exception", NXMessageBox.DialogType.Error, ex.Message); throw ex; } }
static void Main(string[] args) { UserDefinedClass udc = new UserDefinedClass(); udc.UserProperty = "This is the property value"; ClassTracer ct = new ClassTracer(udc); ct.TraceProperties(); ct.CallMethod("UserFunction", "parameter 1 value"); }
static void Main(string[] args) { string str = "hello"; UserDefinedStruct userDefinedStruct = new UserDefinedStruct(2); GenericFunction(userDefinedStruct, str); int integer = 1; UserDefinedClass userDefinedClass = new UserDefinedClass(2); GenericFunction(integer, userDefinedClass); }
//------------------------------------------------------------------------------ // initUDO // Checks to see which (if any) of the application's static variables are // uninitialized, and sets them accordingly. // Initializes the UDO class and registers all of its callback methods. //------------------------------------------------------------------------------ static int initUDO(bool alertUser) { try { if (theSession == null) { theSession = Session.GetSession(); } if (theUI == null) { theUI = UI.GetUI(); } if (theUFSession == null) { theUFSession = UFSession.GetUFSession(); } if (myUDOclass == null) { if (alertUser) { ListingWindow theLW = theSession.ListingWindow; theLW.Open(); theLW.WriteLine("Registering C# UDO Class"); } // Define your custom UDO class myUDOclass = theSession.UserDefinedClassManager.CreateUserDefinedObjectClass ("Sample_CSharp_UDO", "Sample C# UDO"); // Setup properties on the custom UDO class myUDOclass.AllowQueryClassFromName = UserDefinedClass.AllowQueryClass.On; // Register callbacks for the UDO class myUDOclass.AddDisplayHandler(new UserDefinedClass.DisplayCallback(Program.myDisplayCB)); myUDOclass.AddAttentionPointHandler(new UserDefinedClass.DisplayCallback(Program.myDisplayCB)); myUDOclass.AddFitHandler(new UserDefinedClass.DisplayCallback (Program.myDisplayCB)); myUDOclass.AddSelectionHandler(new UserDefinedClass.DisplayCallback(Program.myDisplayCB)); myUDOclass.AddEditHandler(new UserDefinedClass.GenericCallback(Program.myEditCB)); myUDOclass.AddInformationHandler(new UserDefinedClass.GenericCallback(Program.myInfoCB)); // Add this class to the list of object types available for selection in NX. // If you skip this step you won't be able to select UDO's of this class, // even though you registered a selection callback. theUI.SelectionManager.SetSelectionStatusOfUserDefinedClass(myUDOclass, true); } } catch (NXOpen.NXException ex) { // ---- Enter your exception handling code here ----- UI.GetUI().NXMessageBox.Show("Caught exception", NXMessageBox.DialogType.Error, ex.Message); } return(0); }
public virtual object UserDefinedClass_default(UserDefinedClass arg = default) => default(UserDefinedClass);
public virtual object UserDefinedClass_null(UserDefinedClass arg = null) => null;