NX Create NXOpen VB.NET project

2023-04-17T07:01:34Z
NX Open

Summary


Details

How to create NXOpen VB.NET project

Solution

Prerequisites to create NXOpen for VB.NET Project: - (NX2212) 

Visual Studio 2019 Version 16.0.5

.NET Framework 4.8.4536.0

Installing the NX Open wizards:-

Note: Microsoft Visual Studio must be installed on the same workstation as the wizards.

In the %UGII_BASE_DIR%\ugopen\NXOpenWizard\NXOpenVBApplication\ directory,

double-click the NXOpenVBWizard.vsix file to run the installer for the NX Open wizard.

Steps: - 

1.Launch the Visual Studio 2019 application

2.File->New->Project

3.Select "NXOpenVBApplication"->Click on "Next" button of "Create a new project" dialog.

4.Enter Project name->Click on "Create" button of "Configure your new project" dialog.

5.Set required "Application Type" option as "An internal application that can be activated from an NX session (DLL)"

6. Set "Unload Application" option as "Automatically when Application completes"

7.Click on the "Create" button of "NXOpen VB Wizard" dialog. 

8.Now add your application code in Module1.vb

9.To build the code perform Build->Build Solution.

Sample NX Open .NET Visual Basic program:-

=======================

Option Strict Off

Option Explicit On

Imports System

Imports NXOpen

Module Module1

' Explicit Activation

' This entry point is used to activate the application explicitly

Sub Main()

Dim thesession As Session = Session.GetSession()

Dim lw As ListingWindow = thesession.ListingWindow()

lw.Open()

lw.WriteLine("Executed Sample NX Open .NET Visual Basic program")

' TODO: Add your application 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

====================================

KB Article ID# PL8703925

Contents

SummaryDetails

Associated Components

NX Open - All Languages