Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Connecting Visual Studio with NX

Status
Not open for further replies.

Polynom3000

Mechanical
Apr 30, 2014
21
Hello community!

My aim is to write VB code within Visual Studio and execute it directly in NX. I usually copied the source code from Studio and pasted it into the NX Journal Editor. Since the code is pretty easy there are no problems with this method. While working on complex projects with forms, images etc. it is not possible anymore to simply copy and paste. I know there exists some workarounds but it should be possible to launch a project directly from Studio in NX.

None of the information I researched for could finally solve the problem mentioned above.

Further information about the system:
Microsoft Visual Studio Professional 2013 (30 days trial)
NX 8.0.3.4
Windows 7 Professional, SP1, 64bit

The NX documentation gives a hint:
NX Open Programmer's Guide -> Wizard Setup said:
For each wizard, copy any files and/or folders under each subdirectory from the kit to the Visual Studio installation. This example is for the C language so substitute VB or VC# and the appropriate subdirectory for the other languages. Copy:
%UGII_BASE_DIR%\UGOPEN\vs_files\VC\VCWizardsto
C:/program Files\Microsoft Visual Studio *\VC\VCWizardsand
%UGII_BASE_DIR%\UGOPEN\vs_files\VC\vcprojects\
to
C:/program Files\Microsoft Visual Studio *\VC\vcprojects\
Repeat for each language.
* represents the current version of the Studio software

After doing so and clicking in Studio on start -> new project there appears a new entry which is called “NX8 Open VB Wizard” under templates/Visual Basic. I select a save as path for the new project, hit OK and instantly get the error message: "creating project “NX8_Open_VB_Wizard1”... Project Creation Failed". The screen shows the old Studio welcome page again and nothing has happened at all.

Finally I have two questions:
1) What causes the error in Studio? Am I missing any point?
2) Do I still have to edit the “ufvars.bat“ file [%UGII_BASE_DIR%\UGOPEN] or is this step redundant in the latest Studio versions? Anyway I changed the MSVCDir variable several times, but without any success.
Latest try: set MSVCDir=C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE

Thanks in advance. ;-)
 
Replies continue below

Recommended for you

Is there any possibility to solve this problem?
 
For me the wizard don't work too.

To correct this I create a blank Project, then:

Project>Properties>References>Add:
...\UII\managed\NXOpen.dll
...\UII\managed\NXOpen.UF.dll
...\UII\managed\NXOpen.Utilities.dll
...\UII\managed\NXOpenUI.dll

And

Project>Properties>Resources>Add Resource
...\UGOPEN\NXSigningResource.res

Regards,

Gelson Z. Nicoletto
Eng. Supervisor
Mould Desing
Brazil
 
Thanks for your help gelsonnicoletto!
I read your steps but still having some trouble with Studio.

What I did so far:
Studio 13: Visual Basic -> Windows -> blank project
After configuring the properties (as described):
Project map explorer: project -> right-click add windows forms (select Windows Form from list)
After doing so there appears some default Form1.vb inside the project map explorer.

I just placed a simple button on this form and wanted to start the program inside NX simply by pressing the F5 (start…) key in Studio.

Code:
Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        MsgBox("Hello World")
	‘NX Code to edit parts and do stuff
    End Sub
End Class

After pressing the F5 key I always get the following error message:
Project creation failed. Do you want to continue and execute the latest stable build?
YES -> Studio cannot start the debugging process due to the fact that some *MyProjectName.exe does not exist.

Additionally, I got an error in the error list:
“Sub main” wasn’t found in your project
Why do I need this? What’s the problem with the private sub?

Regards,
Polynom3000
 
Hi gelsonnicoletto,

Could you please provide me a full list of steps you followed in order to connect Studio with NX?
What is your Visual Studio Version (I am using a trial of Prof. 2013)?

Thanks a lot!

Regards,
Polynom3000
 
You can follow the below steps.

Creation of Windows form Project in Visual Studio:
--------------------------------------------------

1) Launch Visual Studio
2) Go to Menu File->New->Project
3) Select Windows Form Application Project in window.( Specify Project Name and Location)
4) Click Ok
5) Now you a pre created structure in Solution Explorer with Form1.cs, References, Properties, Program.cs items.


Linking the NX Libraries with Windows Form Project:
--------------------------------------------------

1) Right click on the References folder in Solution Explorer and click "Add References"
2) Now Go to Browse tab and browse for below libraries.
<NX Installation Dir>\UII\managed\NXOpen.dll
<NX Installation Dir>\UII\managed\NXOpen.UF.dll
<NX Installation Dir>\UII\managed\NXOpen.Utilities.dll
<NX Installation Dir>\UII\managed\NXOpenUI.dll
3) Select the above mentioned libraries and Click ok.
4) Add resource file as mentioned by "gelsonnicoletto"
5) Now Add the NX library namespace in Form1.cs file. ( Like "using NXOpen;" "using NXOpen.UF;")
6) Add your customization code, Build and execute in NX.

Regards,
Mukundh


 
Now I am confused. After configuring as mentioned and clicking on debug -> start debugging (F5 key), I am still inside Visual Studio and the form1 window with my modifications (radiobuttons, labels etc.) appears on the screen (but inside Studio and not NX).

My aim is to write VB code only inside Visual Studio. I am developing inside Studio, so there still might be some errors while testing the results inside NX. Then I want to click on the start button inside Studio and my personally written program should automatically appear inside NX (therfore not in Studio). This means that all forms and other stuff is compiled “on the fly” and transferred to NX.

Is it possible to turn on a switch to “forward” or ”outsource” the debugging process to NX by only clicking the start button in Studio?
I don’t have a finished program yet, it is still growing, but I want to check the available results step by step and then extend it.
Sorry for all the confusion. ;-)

Regards,
Polynom3000
 
Ok, as per my understanding that you want to debug the code written in Visual studio while running in NX.

1) Build the application. (Debug mode)
2) Execute the application in NX using Ctrl+U and browsing.
3) Now attach the visual studio program from Menu Tools->Attach to the process.
4) Browse for the ugraf.exe application and click attach.
5) Keep the beak point wherever required.


There is no direct process to launch NX and run your program to debug.

Regards,
Mukundh
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor