Showing results for 
Search instead for 
Do you mean 
Reply

Connection between NX and Matlab

Dear all,
Is it possible to run NX from within Matlab software?
I want to open NX and export coordinates of 1000 points to NX to make a surface.
But this procedure should be done repeatedly.
Sina shojaee
2 REPLIES

Re: Connection between NX and Matlab

Hello Sina!

 

As far as I know there is no 'simple' solution to connect an application within Matlab to
a current NX-Session. But here's a little workaround (from NX to Matlab):

 

One thing you can do is creating a C/C++/C#/VB application (*.dll) to handle the communication between Matlab and NX.

To establish a connection between NX and Matlab you can use the COM-Automation-Server in VB/C#.
If you are working with projects (e.g. Visual C#/VB) the first step is to include a
reference to the COM-Server (Project -> Add Reference -> COM -> Matlab Application)

 

If you are using C/C++ you should use the MATLAB ENGINE API instead of the Automation-Server.

 

Since using the COM-Automation-Server is very easy here is a C# example code which

handles the basic connection:
1) Include the COM-Reference
2) Create an instance of MATLAB

MLApp.MLApp matlab = new MLApp.MLApp();

Please note: If you are running an instance of Matlab, the application will connect to the running one.

If you didn't started Matlab yet, there will be created an instance 'Matlab Console'. I prefer using the

Matlab GUI..

3) Sending an execution command to Matlab:

matlab.Execute("a = 1+1;");

4) You can evaluate some functions with

matlab.FEval(...);

5) To get some variables you can use

matlab.GetVariable(...);

 6) The rest should be some NX programming. (e.g. createBSurfThruPts..)

 

You don't need a GUI in your application, so you can just load the *.dll, connect to the current Matlab instance, get your data and create a surface. I know that you were asking for a solution the other way

(MATLAB-->NX), but perhaps you can use it this way.

 

Hope that helps! If you need any further information, please let me know.

 

Bye,

 

Flo

Re: Connection between NX and Matlab

Why don't you write the points out to a file, and then import them into NX?
山田
yamada