- Create a library project in C#;
- Add a class with 2 methods like below:
class TestAtt { public static void Main() { Session theSession = Session.GetSession(); theSession.ListingWindow.Open(); theSession.ListingWindow.WriteLine("Running the Sample Application"); MessageBox.Show("Good"); } public static int UnloadLibrary() { return (int)Session.LibraryUnloadOption.Explicitly; } }
- Add reference dll in UGDir\UGII\managed\ to the project
- Add “using NXOpen; using NXOpen.UF;” in the class file
- Add the NXSigningResource.res to the project, configure the Build Action as “Embedded Resource”
- In the post-build event, type “SignLibrary -verify $(TargetPath)” to sign the dll.
Note that the last 2 steps are not necessary if you only run the extension plugin/addin on your local computer, however they are required if you want to run on other computers. For more details, refer to NX Open Programmer’s Guide at UGDir/UGDOC/html_files/nxopen_prog_guide/index.html
- Compile and build, a dll will be generated.
- Open UGNx, press Ctrl +U, browse to the folder where the DLL resides, click the DLL, and the DLL will be loaded.
That is it. Happy coding!
Posted in CAD, Dotnet/C#
