Transferring control from WinForm to NX Selection Dialog

Hi everyone. I'm currently working on an application that creates a Windows Form and executes some NX code through it. One of the button opens up a selection menu in NX but the problem is that I cannot interact with the NX selection menu when its open. I can only interact with the WinForms window.

My form code looks like this:


Private Sub MainForm_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Me.Icon = NXOpenUI.FormUtilities.GetNXIcon()
End Sub

Private Sub btn_SelectChainElements_Click(sender As System.Object, e As System.EventArgs) Handles btn_SelectChainElements.Click

SelectChainElements(chainElements)
End Sub

And the SelectChainElements() function calls a SelectionManager.SelectTaggedObjects() dialog.

Any ideas?

Windows forms shown in a journal are "modal"; this means that the dialog must be dealt with by the user before you can continue working with NX. If you have an author license, you can use a "modeless" dialog box which will remain open while the user interacts with NX. These are more difficult to code as more can go wrong during the execution of your program (e.g. NX may be put in a state that your program didn't anticipate).

Modal dialogs sound more constricting than they really are. The form only has to be closed while the user interacts with NX, it doesn't have to be unloaded. I suggest using form properties to communicate with the journal code. The user interacts with the form, important information is saved to the form's properties, the user presses the "make selection" button, the form closes, the journal reads the form properties and the logic branches accordingly, the user makes one or more selections, the journal can write new information to the form's properties if needed, and you can reopen the form for additional interaction if you so desire.

I tried what you wrote above
me.close
called selection
but the Windows Form does let go.

Carlo Tony Daristotile

I figured it out.

Carlo Tony Daristotile

Can you show us your code, please.
Or, at least, describe what you did. Thanks.