×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Programming Pure VB 2012 with forms and dialog boxes together with NX 7.5

Programming Pure VB 2012 with forms and dialog boxes together with NX 7.5

Programming Pure VB 2012 with forms and dialog boxes together with NX 7.5

(OP)
Hello all,

Can anyone please help me? I am working with NX 7.5 - mostly the drafting side as well as some modeling. And I just had the full Visual Studio with Visual Basic (VB) 2012 loaded.

I've been able to generate simple VB code to run inside of NX 7.5. But I would like to write code as well as developing forms with buttons, scroll bars, etc. that allows the user to have multiple options to run the programs.

Subsequently, can you please provide me with sample code(s) including how to set the entire code to speak to NX and/or direct me to websites containing examples of the full VB package with example codes containing connections to NX?

Thank you very much for your response(s) ahead of time!

RE: Programming Pure VB 2012 with forms and dialog boxes together with NX 7.5

In the NX help, Automation -> programmer's guide, there is a section called "wizard setup" that explains how to make VS aware of NX. It is fairly simple, involving copying a few files from the NX folders to the VS template folders. I don't think VS 2012 was out when NX7.5 released, you may have to tweak the instructions a bit to get your setup to work (folder locations may be different).

www.nxjournaling.com

RE: Programming Pure VB 2012 with forms and dialog boxes together with NX 7.5

(OP)
Thank you very much cowski for responding to my post.

Currently, the following softwares and installations are on my machine:
Teamcenter (TC) -> NX7.5 – not loaded on individual machines, but running off of a server
Native NX7.5 (rarely used, less than 0.1%) – also not loaded on individual machines, but running off of a server
Visual Studio 2012 – installed last week directly on my machine

I located both the “NX Open Visual Basic (VB) Wizard” and the “Visual Studio (VS) Application Wizard Setup,” in which I copied the directions in the attached file (NX Open VB & VS App Wizards.docx). Which wizard should I run first once I locate them?

From the NX Open Visual Basic (VB) Wizard, it reads “You can start Visual Studio by typing ‘devenv.exe’ from an NX command prompt window.” Do you know where the “NX command prompt window” is located? I’ve searched all over NX as well as going through numerous Help files and still cannot find it.
Also, as indicated in this same directions file (NX Open Visual Basic (VB) Wizard) under the “Using the NX Open VB wizard” section, Step 1 says “Select the File→New→Project menu item to activate the New dialog box.” I found this to be within VS according to directions from another web page (http://share.pdfonline.com/1843125f096349ccb6b1c02...). But I’m having difficulties getting to Step 2 – “Under Project Types, expand Other languages and select Visual Basic.” Is this because NX 7.5 is not loaded directly on my machine, but instead is running off a server and running through TC?

Within the “Visual Studio Application Wizard Setup,” how can you determine if the “appropriate version Microsoft Visual Studio has been installed”? Also, with my license of TC→NX7.5 running off a server, should the “%UGII_BASE_DIR%\UGOPEN\vs_files\VB\VBWizards\” and “%UGII_BASE_DIR%\UGOPEN\vs_files\VB\vbprojects\” folders have the same folder structure as licenses loaded in individual machines? (I only ask this because our Helpdesk IT support staff will want to know once I put in a Helpdesk ticket).

Thank you again for your help, which I greatly appreciate!

NXProf

RE: Programming Pure VB 2012 with forms and dialog boxes together with NX 7.5

Quote (NXProf)

From the NX Open Visual Basic (VB) Wizard, it reads “You can start Visual Studio by typing ‘devenv.exe’ from an NX command prompt window.” Do you know where the “NX command prompt window” is located?

The NX command prompt window can be started from Start -> NX 7.5 -> NX Tools -> Command Prompt.
But I never start VS this way. Once the wizards are setup you can just start VS the normal way, start a new project and select the NX template.


Quote (NXProf)

Also, with my license of TC→NX7.5 running off a server, should the “%UGII_BASE_DIR%\UGOPEN\vs_files\VB\VBWizards\” and “%UGII_BASE_DIR%\UGOPEN\vs_files\VB\vbprojects\” folders have the same folder structure as licenses loaded in individual machines?

I imagine the folder structure will be the same, but you will have to look on the server to find the %UGII_BASE_DIR%.

www.nxjournaling.com

RE: Programming Pure VB 2012 with forms and dialog boxes together with NX 7.5

(OP)
Hello cowski,

I have been able to do the following 4 steps with no issues:
1) Copied all NX files/folders from the network drive … \vs_files\VB\VBWizards\
to D:\Microsoft Visual Studio 11.0\VB\VBWizards\
and copied all NX files/folders from the network drive
…\vs_files\VB\VBprojects\
to D:\Microsoft Visual Studio 11.0\VB\VBprojects\

2) Within the D:\Microsoft Visual Studio 11.0\VB\VBprojects\NX7_VB.vsz file, I changed the 2nd line from “Wizard=VsWizard.VsWizardEngine.9.0” to “…VsWizardEngine.11.0” since my VS version is 11.0.

3) I found the NX command prompt via Start -> All Programs -> Technical Applications -> Teamcenter -> NX command prompt and changed the current folder as D:\Microsoft Visual Studio 11.0\Common7\IDE\, then typed devenv.exe, which started Visual Studio 2012, but appeared to be a normal startup session without establishing any Wizard settings. But I can’t tell.

4) I followed the directions to “Creating a Visual Basic project using the NX Open VB wizard” up to the point where is says “Step 1 Select the File→New→Project menu item to activate the New dialog box.”
When I get to VS, the actual starting of a project is File→NewProject (and not File→New→Project), which I start. Then when expanding the “Installed” tree for a New Project to go to Step 2 “Under Project Types, expand Other languages and select Visual Basic,” Visual Basic is listed under the Templates tree limb, but not under Other Languages. (Please see attached, which shows all expanded). Then Step 3 says “Select NX#_VB from the list of Templates (where # is the NX version).”

But at this point, I do not see “NX#_VB from the list of Templates.” Is there something I might be missing to properly get the NX Open VB wizard started?

Thank you again for your help!

RE: Programming Pure VB 2012 with forms and dialog boxes together with NX 7.5

I recently downloaded the VS2012 version to try it out. I could not get the wizards to work with it. I suggest downloading the VS2010 version, I know you can get the wizards to work with that version.

www.nxjournaling.com

RE: Programming Pure VB 2012 with forms and dialog boxes together with NX 7.5

(OP)
Thank you cowski!

I'll see if I can get VS2010. Do you know what version of NX works with VS2010? Currently I'm running NX 7.5.

Thank you again for your outstanding help!

RE: Programming Pure VB 2012 with forms and dialog boxes together with NX 7.5

I've used it successfully with NX 7.5 and 8. It also works with NX 8.5, though I haven't used it there much yet.

www.nxjournaling.com

RE: Programming Pure VB 2012 with forms and dialog boxes together with NX 7.5

I should also note that the 2012 version would also work if you add the references yourself. I wasn't able to get the NX code wizard to work with 2012, but that doesn't mean you can't write journals for NX with it.

www.nxjournaling.com

RE: Programming Pure VB 2012 with forms and dialog boxes together with NX 7.5

(OP)
Thank you again cowski!

I'll have to see if I can downgrade my VS from 2012 to 2010 and then see if the wizard will work. But before downgrading, I might attempt to "add the references." Do you know how I can get started?

Best regards.


RE: Programming Pure VB 2012 with forms and dialog boxes together with NX 7.5

Start a class library project, go to project -> add reference; browse to your <NX install folder>\UGII\managed and add references to NXOpen.dll, NXOpen.Utilities.dll, NXOpen.UF.dll, and NXOpenUI.dll.

Now replace the existing code in the .vb file with this:

CODE

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

Module Module1

    '  Explicit Activation
    '      This entry point is used to activate the application explicitly
    Sub Main()

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

        ' TODO: Add your application code here 

    End Sub


    Public Function GetUnloadOption(ByVal dummy As String) As Integer

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

        '----Other unload options-------
        'Unloads the image when the NX session terminates
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination

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

    End Function

End Module 

www.nxjournaling.com

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources