cancel
Showing results for 
Search instead for 
Did you mean: 

how to run execute external nx journal in C#.net

PLM World Member Creator PLM World Member Creator
PLM World Member Creator

i have use this code

 

 

using System;
using NXOpen;
using NXOpen.UF;
using System.Runtime.InteropServices;

public class Program
{
// class members
private static Session theSession;
private static UFSession theUfSession;
public static Program theProgram;
public static bool isDisposeCalled;

//------------------------------------------------------------------------------
// Constructor
//------------------------------------------------------------------------------
public Program()
{
try
{

theSession = Session.GetSession();
theUfSession = UFSession.GetUFSession();
isDisposeCalled = false;


//code
//Session theSession = Session.GetSession();
Part workPart = theSession.Parts.Work;
Part displayPart = theSession.Parts.Display;
// ----------------------------------------------
// Menu: File->Close->Save As and Close...
// ----------------------------------------------
PartSaveStatus partSaveStatus1;
partSaveStatus1 = workPart.SaveAs("C:\\Users\\Dhaval\\Desktop\\PISTON_9HSE_411_2");

partSaveStatus1.Dispose();
workPart.Close(NXOpen.BasePart.CloseWholeTree.True, NXOpen.BasePart.CloseModified.DontCloseModified, null);

workPart = null;
displayPart = null;


}
catch (NXOpen.NXException ex)
{
// ---- Enter your exception handling code here -----
// UI.GetUI().NXMessageBox.Show("Message", NXMessageBox.DialogType.Error, ex.Message);
}
}

//------------------------------------------------------------------------------
// Explicit Activation
// This entry point is used to activate the application explicitly
//------------------------------------------------------------------------------
public static int Main(string[] args)
{
int retValue = 0;
try
{
theProgram = new Program();

//TODO: Add your application code here

theProgram.Dispose();
}
catch (NXOpen.NXException ex)
{
// ---- Enter your exception handling code here -----

}
return retValue;
}

//------------------------------------------------------------------------------
// Following method disposes all the class members
//------------------------------------------------------------------------------
public void Dispose()
{
try
{
if (isDisposeCalled == false)
{
//TODO: Add your application code here
}
isDisposeCalled = true;
}
catch (NXOpen.NXException ex)
{
// ---- Enter your exception handling code here -----

}
}

}

 

 

 

but get this type of error Unable to load DLL 'libpart': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

how to remove this error

6 REPLIES

Re: how to run execute external nx journal in C#.net

Experimenter
Experimenter

Ideally, it should pick the DLLs, using environment variables.

 

But for testing, you can manually pick all the required dlls( e.g libpart.dll) [Example path : C:\Program Files\Siemens\NX 10.0\UGOPEN\SampleNXOpenApplications\.NET\RemotingExample\Client\obj\Debug] and paste it to your project bin folder Example path : F:\NXParts\SensorsList\SensorsList\bin\Debug.

 

 

Re: how to run execute external nx journal in C#.net

Siemens Phenom Siemens Phenom
Siemens Phenom

 

You need to have the folder where libpart.dll lives in your PATH envrionment variable.  In any version up to and including NX10, this will be %UGII_ROOT_DIR% - the ugii folder.  In NX11, it will be %UGII_BASE_DIR%\NXBIN.

 

If you run your .exe from an NX Command Prompt, then the PATH and the other environment variables that you need should be set properly to allow you to run the .exe.

 

Start -> All Programs -> Siemens NX ## -> NX Tools -> Command Prompt

Re: how to run execute external nx journal in C#.net

Experimenter
Experimenter

I have windows 8.1 installed and I am using NX10, but in my setup I am unable to find NX Command promt.

I think it is missing (ugiicmd.bat ) is present in UGII. But there is not command prompt.

 

Could you please help.

Re: how to run execute external nx journal in C#.net

Siemens Phenom Siemens Phenom
Siemens Phenom

The shortcut should be:

 

C:\Windows\System32\cmd.exe /k ugiicmd.bat "%UGII_BASE_DIR%"

 

with a Start-In folder of %UGII_BASE_DIR%\UGII\

 

where "%UGII_BASE_DIR% should be replaced with the path specific to your system.

 

As long as %UGII_BASE_DIR%\UGII\\ugiicmd.bat exists on your system, you should be able to manually create the shortcut. If this file does not exist,you will probably have to reinstall NX.

Re: how to run execute external nx journal in C#.net

Siemens Phenom Siemens Phenom
Siemens Phenom

Manish, did you ever get this to work?  One other important thing about running an external NXOpen .Net program, (.exe) is that you have to copy the NXOpen*.dll files from ...ugii\managed into the same folder where your .EXE is running.

 

Best regards,

 

Steve

 

Re: how to run execute external nx journal in C#.net

Esteemed Contributor
Esteemed Contributor

SteveLabout wrote:

One other important thing about running an external NXOpen .Net program, (.exe) is that you have to copy the NXOpen*.dll files from ...ugii\managed into the same folder where your .EXE is running.


This is no longer needed if you use the "%UGII_BASE_DIR%\UGII\run_managed.exe" or "%UGII_BASE_DIR%\NXBIN\run_managed.exe", which makes sure to set the correct environment for .NET executables. More details can be found in the NXOpen documentation.

For not compiled Journals there is the run_journal.exe executable available.

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX11.0 EAP, NX12.0 EAP

How to Get the Most from Your Signature in the Community