NXOpenUI.FormUtilities.ReparentForm

Has someone have a working example of using this method for winforms?

NXOpenUI.FormUtilities.ReparentForm

It should allow you keep a journal form active and allow normal work in NX.

I saw it is possible when a compiled .dll is run, but is it possible in journal?

The reparent form method ties the winform to the main NX application. It will ensure that the winform dialog is shown on top of the NX window and will minimize the dialog along with the main NX window. It DOES NOT allow you to interact freely with NX while the form is shown. If you run the code as a journal (uncompiled), the winform must be used with the .ShowDialog method which will lock out NX functionality while the dialog form is shown.

You can get more interaction with NX while a winform is shown, within limitations, if you compile the code and use a "modeless" form. In this case, the unload option will need to be set to something other than "immediately" and you may need to take care of a few more "housekeeping" tasks within your code.

I am using this section of code to interact with NX, and unload files from the NX after the usage is over.
I don’t know somehow when this program is run in a Session, in that same session, I am not able to run any of standard company Automations.

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.Utilities
Imports NXOpen.Features
Imports System.Windows.Forms
Imports System.Runtime.InteropServices
Imports System.Linq
Imports System.Threading
Imports System.Reflection
Imports System.IO

Module NXModule

Sub Main()
Dim theSession As Session = Session.GetSession()
Dim theUI As UI = UI.GetUI()
Dim theUfSession As UFSession = UFSession.GetUFSession()
Try
If System.Windows.Forms.Application.OpenForms.OfType(Of mytempForm).Any Then

Exit Sub
Else
myform = New mytempForm
myform.Show()
Dim checkThread As New Thread(New ThreadStart(AddressOf IsFormDismissed))
checkThread.Start()
End If
Catch ex As Exception
End Try
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
myBasePart = workPart

End Sub

Public Function GetUnloadOption(ByVal dummy As String) As Integer
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
End Function

Dim myform As New Windows.Forms.Form

Sub UnloadNXLibrary()
Dim ufs As UFSession = UFSession.GetUFSession()
Dim runningProgram As Assembly = Assembly.GetExecutingAssembly()
ufs.UF.UnloadLibrary(runningProgram.Location)
End Sub

Public Sub IsFormDismissed()
Do
If myform.IsDisposed() = True Then
UnloadNXLibrary()
End If
Thread.Sleep(100)
Loop
End Sub

End Module

All I want is to unload the .dll once my form is closed. and also not to create any instance of the form, if clicked on it more than once.
Please help.

Regards
Pradeep
#If it works, it works.