cancel
Showing results for 
Search instead for 
Did you mean: 

Connecting to NX Model Externally without executing inside NX

Creator
Creator

All,

 

I am looking to connect a VB.NET program with an active NX session externally. I have found the RemotingExample, but even it seems unable to connect to NX without running something from inside NX.

 

The directions state:

1. Start NX through the NX command prompt.
2. Type Ctrl-U to open the "Execute NXOpen" dialog.

3. Navigate to Server.dll(Server\obj\Debug\Server.dll) and press OK.
4. Using the same NX command prompt, run the Client.exe(Client\obj\Debug\Client.exe).

 

I am looking for a way to connect with the NX Session without having to type Ctrl-U inside NX and running a program. The end goal would be that my program searches for and connects to an active NX session, or reports to the user that no session could be found.

 

I have also found the run_managed.exe program, but this seems to create a new NX session, and doesn't seem able to connect to the active NX session. This would be okay if I didn't need to reload large parts/models, but I was hoping to access these large parts/models after they had already been loaded.

 

For Femap, I can get a Femap model object using GetObject("femap.model",), which gives me access to the active Femap session on my machine (if there is one). There doesn't seem to be an equivalent in NX.

 

Is this possible, or does NX require at least something to be activated manually inside NX by the user in order to make the session available?

 

Thanks,

Ryan

4 REPLIES

Re: Connecting to NX Model Externally without executing inside NX

Genius
Genius

Hi Ryan,

 

NX remote is the way to go if you want to connect to an active session with loaded parts.

You don't need to load the DLL manually in the session. It can be loaded automatically at startup.

You need to set the environment variable UGII_USER_DIR. Add sub-fulder startup and copy you dll there.

 

below a little sample:

 

:NxRemote
echo.
echo.NX Remote server DLL
set UGII_USER_DIR=\\SERVER\PLMShare\NX9_config\UGII_USER_DIR
copy /Y "c:\GIT\Automatic Order\NX Remote Server\bin\debug\SG_NX_Remote_Server.dll" %UGII_USER_DIR%\startup\*.*

 

br

fred

 

 

Re: Connecting to NX Model Externally without executing inside NX

Creator
Creator

Fred,

 

Thank you for your help. I have set up a CUSTOM_APPS folder in my NX installation folder, given it a CUSTOM_APPS\startup subfolder, and put the compiled Server.dll inside.

 

I have set UGII_USER_DIR=%UGII_BASE_DIR%\CUSTOM_APPS, both as a system enviornmnet variable and also by editing %UGII_BASE_DIR%\UGII\ugii_env.dat

 

For some reason, the dll doesn't seem to run (correctly) on startup. While NX is open, I am unable to delete the file because it is being used, so I assume it was started correctly. However, it doesn't work when I attempt to run client programs. If I run the dll again inside NX (ctrl-U), my client programs connect and work correctly. 

 

I used the remoting example from:  %UGII_BASE_DIR%\UGOPEN\SampleNXOpenApplications\.NET\RemotingExample\Server

 

I tried changing

public static int GetUnloadOption(string dummy) 
    { 
        return (int)Session.LibraryUnloadOption.Explicitly; 
    }

to

public static int GetUnloadOption(string dummy) 
    { 
        return (int)Session.LibraryUnloadOption.AtTermination; 
    }

but it made no difference.

 

Is there an extra step I need to add to the server for it to work correctly on startup? It is running but the remote Session object and remote UFSession object are unavailable unless I manually run it inside NX after it has initialized.

 

Thanks,

Ryan

Re: Connecting to NX Model Externally without executing inside NX

Genius
Genius

What does the syslog say?

 

did you define function startup?

 

    Public Shared Function Startup() As Integer
        Start()
        Return 0
    End Function

I had similar issue a few months ago.

https://community.plm.automation.siemens.com/t5/NX-Programming-Customization-Forum/DLL-for-NX-Remote...

 

Re: Connecting to NX Model Externally without executing inside NX

Creator
Creator

That was my problem! Thank you so much for your help!

 

Ryan