Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

linking ugopen to visual studio

Status
Not open for further replies.

lugan2

Mechanical
Apr 10, 2013
42
Hi all
Is there a documentation about how to configure visual studio when it tries to link with ugopen? I am currently using visual studio 2012.
when I try to build a simple program using uf functions (only had two functions been called from uf.h, i.e., UF_initialize and UF_terminate), it gives me such errors:

1>------ Build started: Project: NXTest1, Configuration: Debug Win32 ------
1>NXTest1.obj : error LNK2019: unresolved external symbol __imp__UF_initialize referenced in function _main
1>NXTest1.obj : error LNK2019: unresolved external symbol __imp__UF_terminate referenced in function _main
1>D:\Gan_Software\VisualStudio\projects\NXTest1\Debug\NXTest1.exe : fatal error LNK1120: 2 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

If I use the variables defined by nx, such as, "uf_list_p_t", it works ok. The compiler only gives error msg when it calls the functions from ugopen. I guess the solution could be very simple, maybe it because that it cannot find the source code for the functions and just need to include some library paths. But I tried to include all lib directories in the visual studio, and still doesn't work.

Someone please help!

Many thanks!

 
Replies continue below

Recommended for you

Do You think of this:

NX Open Visual Basic (VB) wizard
Creating a Visual Basic project using the NX Open VB wizard
The following topic describes how to develop an NX Open Visual Basic application using Microsoft Visual Studio. It is recommended that all NX Open Visual Basic program development on Windows be done from a Visual Basic project

Starting Visual Studio
You can start Visual Studio by typing "devenv.exe" from an NX command prompt window. Studio will pick up the required NX environment variables necessary to compile and link a project.

Creating a Visual Basic project
Use the Visual Basic wizard whenever you need to create a new NX Open automation program in Visual Studio with the Visual Basic language. The wizard automatically adds the required references to NX Open libraries in the new project.

Using the NX Open VB wizard
To use the NX Open VB wizard:

Step 1. Select the File→New→Project menu item to activate the New dialog box.

Step 2. Under Project Types, expand Other languages and select Visual Basic.

Step 3. Select NX#_VB from the list of Templates (where # is the NX version).

Step 4. Enter a project name into the "Project name:" dynamic input box. By default this becomes the name portion of the program being built. For instance, a project named "MyNXOpenApp" produces either a "MyNXOpenApp.dll" or "MyNXOpenApp.exe". You can override this later, if necessary.

Step 5. Click OK and follow the on-screen instructions to create your Visual Basic project.
?

I have installed both NX and VS2010express, but I have no devenv.exe at all..
What is the problem? What is devenv.exe?

----
kukelyk
 
Hello, the problem has been solved. It due to the environment setting and 64/32 bit version issue.

Many thanks for your help!
Gan
 
Could You write me the steps needed?

----
kukelyk
 
Sorry, I only used VS C++ to implement my program, and I don't use vb.
 
If you want, I can post the vs c++ project files online.
 
Hello.
I have similar issues in attempting to link UG (NX7.5) to Visual Studio Professional 2012 (Version 11.0.60610.1 Q11REL). I've copied all network NX files to the VB folders as described below:
• 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 8\VC\VCWizardsand
%UGII_BASE_DIR%\UGOPEN\vs_files\VC\vcprojects\
to
C:/program Files\Microsoft Visual Studio 8\VC\vcprojects\


But when I use the NX Command prompt, then change the path to the location of the devenv.exe, then type devenv.exe <return>, it starts Visual Studio as normal and without the NX Wizard. Any suggestions on how to get the NX Wizard within Visual Studio operational?

Thank you for your help.
 
I have successfully used the NX wizards with VB.net 2010 express. I downloaded VB.net 2012 express a while back, but was never able to get the wizards to work. NX 7.5 came out well before VS 2012, my best guess is that MS changed something that broke the NX wizards.

Using the 2012 version, I started a new project, copied & pasted the boiler plate code from the NX wizards, added references to the NX .dll files, and saved it as a template. Not quite as handy as the code wizards, but it is a workable solution.

www.nxjournaling.com
 
Thank you cowski for your directions.

Since I have not been able to get the NX wizards to run ever, could you please let me know what boiler plate code you used (or which files I might search to locate this initial code) as well as what references used to the NX .dll driver files so I can build my template too?

Thank you once again for your tremendous help.
 
If you open a windows explorer and browse to [NX install directory]\UGOPEN\vs_files\VB\VBWizards\NX7_VB\Templates\1033\vbfile.vb, you will see all the code that the wizards reference. This file contains several if/end if statements that will build up the starting code based on inputs to the wizard.

I most often use the "explicit activation" and "import NXOpen.UF" options; the resulting code looks something like this:

Code:
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

Module Module1

    Sub Main()

        Dim theSession As Session = Session.GetSession()
        Dim theUfSession As UFSession = UFSession.GetUFSession

        'TO DO: add your code here

    End Sub


    Public Function GetUnloadOption(ByVal dummy As String) As Integer

        'Unloads the image when the NX session terminates
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination

        '----Other unload options-------
        'Unloads the image immediately after execution within NX
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

        'Unloads the image explicitly, via an unload dialog
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
        '-------------------------------

    End Function

End Module

From the [NX install directory]\UGII\managed directory, the referenced .dll's are:
[ul][li]NXOpen.dll[/li]
[li]NXOpen.UF.dll[/li]
[li]NXOpen.Utilities.dll[/li]
[li]NXOpenUI.dll[/li][/ul]

From the .net framework folder, the referenced .dll's are:
[ul][li]System.dll[/li]
[li]System.Data.dll[/li]
[li]System.Deployment.dll[/li]
[li]System.Xml.dll[/li][/ul]

www.nxjournaling.com
 
Cowski said:
I have successfully used the NX wizards with VB.net 2010 express. I downloaded VB.net 2012 express a while back, but was never able to get the wizards to work. NX 7.5 came out well before VS 2012, my best guess is that MS changed something that broke the NX wizards.

Using the 2012 version, I started a new project, copied & pasted the boiler plate code from the NX wizards, added references to the NX .dll files, and saved it as a template. Not quite as handy as the code wizards, but it is a workable solution.

Here is my work around for this issue since Microsoft killed the wizards after 2010:
I downloaded VS2013(Visual Studio), I created a project using the wizard in 2010 Express(Free), imported it into 2013, and exported it as a template. This allows me to run all the code analysis and use full capabilities of projects in VS, I do not have an Author license so I can't sign any of the products of compilation but the .vb file generated from it is exactly what I need for journaling.

This should be able to work for 2012 as well, but I do not have a seed to confirm.

DHuskic
Data Prep NX7.5
Kettering University Class of '17
 
Thank you very much cowski for your boiler plate code, driver files, and locations of them. Over the next few days at work, I'll have to see if I can get my template created to work along with having VB forms linked to the code, which is where I'm always stumped. Afterwards, I'll let you know if I am successful.
Thank you again for your awesome help!

Also, thank you DHuskic for your excellent input as well. But for my position at work, we are not allowed to load software (even freeware) onto our workstations. But if worse comes worse, I might see if one of the IT guys can load it with proper approvals and attempt making the modifications as you've suggested. Thank you.
 
I am running NX 8.0.3.4 and have Visual Express 2010.
I copied all the Wizard files from UG to Microsoft Visual Studio 10.0.

1) Can someone give me detailed instructions on how to set the MSVCDir environment variable?

When I run NX tools --> comand prompt I get that message MSVCDir environment variable not defined.
It states that i must modify the ufvars.bat file.
I tried modifying but it doesnt work.

Can the MSVCDir be created in regedit ? If yes then where exactly ?

2) Also the devenv.exe is not recognized as a command? How do you fix this?
 
Install the Visual Studio Professional.

devenv.exe should be found. If not the installation is incorrect.

Regards,
Mukundh
 
I found out that express doesnt have the devenv.exe

Express has vbexpress.exe
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\vbexpress.exe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor