1. How do I not copy the EXE program to the UGII directory?
A: Before calling the NX Open command function, move the current directory to the NX installation directory \UGII\,NX the installation directory must match the value of the environment variable Ugii_base_dir, otherwise error. You can use the following code:
Dim as String = environment.getenvironmentvariable ("ugii_base_dir") System.IO.Directory.SetCurrentDirectory (Instaldir)
2. My external program is very small, do not want to package NX's. NET library files to publish together, but use the user's library files, how to do?
A: The first step, display all the project files, expand the Application.myapp file, then open the Application.Designer.vb file, add the Startup event callback function for MyApplication, add the following code in it:
dim ufdir as string = environment.getenvironmentvariable ( " ugii_base_dir " ) Reflection.Assembly.LoadFrom (IO. Path.Combine (Ufdir, " \ugii\managed\ NXOpen.dll " )) Reflection.Assembly.LoadFrom (IO. Path.Combine (Ufdir, " \ugii\managed\ NXOpen.UF.dll " )) Reflection.Assembly.LoadFrom (IO. Path.Combine (Ufdir, " \ugii\managed\ NXOpen.Utilities.dll ))
The second step, modify the program run configuration file: Your exe program file name. config
<?XML version= "1.0" encoding= "Utf-8"?><Configuration> <Runtime> <assemblybindingxmlns= "Urn:schemas-microsoft-com:asm.v1"> <dependentassembly> <assemblyidentityname= "Nxopen"Culture= "neutral"PublicKeyToken= "NULL"/> <CodeBaseversion= "8.0.2.2"href= "File://d:\program files\siemens\nx 8.0\ugii\managed\nxopen.dll"/> </dependentassembly> <dependentassembly> <assemblyidentityname= "Nxopen.uf"Culture= "neutral"PublicKeyToken= "NULL"/> <CodeBaseversion= "8.0.2.2"href= "File://d:\program files\siemens\nx 8.0\ugii\managed\nxopen.uf.dll"/> </dependentassembly> <dependentassembly> <assemblyidentityname= "Nxopen.utilities"Culture= "neutral"PublicKeyToken= "NULL"/> <CodeBaseversion= "4.0.0.0"href= "File://d:\program files\siemens\nx 8.0\ugii\managed\nxopen.utilities.dll"/> </dependentassembly> </assemblybinding> </Runtime></Configuration>
Use. NET (C # or vb.net) to develop NX external programs