How to open Multiple files at a time in UG NX open Dialog box

Hi All,
The subject says everything,
i would like to open multiple files at a time....in open dialog box by holding CTRL as like in other software,
is there any journal available to replace default OPEN command in UG NX?
Thanks in advance.

I don't have any code to do that, but I don't think it would be too difficult for you to make it with the help of the .net file open dialog box.

https://msdn.microsoft.com/en-us/library/system.windows.forms.openfiledi...(v=vs.110).aspx

Thanks for the reply,
I'm absolutely ZERO in programing,
I know only record and execute.. willing to learn....

-[]-

Here is a simple example; it does no real error checking. Run the journal, it will allow you to select multiple files from the chosen folder; each of the chosen files will be opened in NX.

Option Strict Off
Imports System
Imports System.Windows.Forms
Imports NXOpen

Module Module1

Sub Main()

Dim theSession As Session = Session.GetSession()
If IsNothing(theSession.Parts.BaseWork) Then
'active part required
Return
End If

Dim workPart As Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()

Dim openFileDialog1 As New OpenFileDialog()

openFileDialog1.InitialDirectory = "c:\"
openFileDialog1.Filter = "prt files (*.prt)|*.prt"
openFileDialog1.FilterIndex = 1
openFileDialog1.RestoreDirectory = True
openFileDialog1.Multiselect = True

If openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
Try
For Each prt As String In openFileDialog1.FileNames
lw.WriteLine(prt)
Dim basePart1 As BasePart
Dim partLoadStatus1 As PartLoadStatus
basePart1 = theSession.Parts.OpenBaseDisplay(prt, partLoadStatus1)

partLoadStatus1.Dispose()

Next
Catch Ex As Exception
lw.WriteLine("Error: " & Ex.Message)
End Try
End If

lw.Close()

End Sub

Public Function GetUnloadOption(ByVal dummy As String) As Integer

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

End Function

End Module

Thank you very much ,
its working exactly as I wanted.

-[]-

Hi,
How to add 'read only' property in this dialog box....???

-[]-

What are you wanting to be read only? The files? If so that can be done through the file properties or file permissions.

Not .Def file,
This is a other issue,
Please check whole thread.

-[]-

You can add the "read only" check box to the file open dialog by adding the line before the call to openFileDialog1.ShowDialog:

openFileDialog1.ShowReadOnly = True

Note: you will need to add your own code to check if the box is checked and change the file permissions as needed on the appropriate files.

Added given code ,
but not functioning

-[]-

Did you see my NOTE in the previous post? You will need to add code to change the file permission as needed. I'd suggest starting here:
https://msdn.microsoft.com/en-us/library/system.io.fileinfo.isreadonly%2...

Some web-searching will turn up example code in your language of choice for setting/removing the read-only property.

Searched through many forums, but no luck,

-[]-

Try the following code.

'NXJournaling.com
'April 29, 2016

'Open multiple .prt files, change files to read-only before opening.
'Checking the read-only box will attempt to change the files to read-only before opening them.
'Unchecking the box has no effect.

Option Strict Off
Imports System
Imports System.Windows.Forms
Imports NXOpen

Module Module2

Sub Main()

Dim theSession As Session = Session.GetSession()
If IsNothing(theSession.Parts.BaseWork) Then
'active part required
Return
End If

Dim workPart As Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()

Dim openFileDialog1 As New OpenFileDialog()

openFileDialog1.InitialDirectory = "c:\"
openFileDialog1.Filter = "prt files (*.prt)|*.prt"
openFileDialog1.FilterIndex = 1
openFileDialog1.RestoreDirectory = True
openFileDialog1.Multiselect = True
openFileDialog1.ShowReadOnly = True

If openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then

For Each prt As String In openFileDialog1.FileNames

lw.WriteLine(prt)

If openFileDialog1.ReadOnlyChecked Then
'try to set all the files to read-only
Dim fInfo As New IO.FileInfo(prt)
Try
fInfo.IsReadOnly = True
lw.WriteLine(" read-only: " & fInfo.IsReadOnly.ToString)
Catch ex As UnauthorizedAccessException
lw.WriteLine(" you do not have the authority to change the read-only status of part: " & prt)
End Try
End If

Dim basePart1 As BasePart
Dim partLoadStatus1 As PartLoadStatus = Nothing
Try
basePart1 = theSession.Parts.OpenBaseDisplay(prt, partLoadStatus1)
Catch ex As Exception
lw.WriteLine("** Error opening file **")
Finally
partLoadStatus1.Dispose()
End Try

Next
End If

lw.Close()

End Sub

Public Function GetUnloadOption(ByVal dummy As String) As Integer

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

End Function

End Module

Thank You very much.....
Working but its setting read-only property in file properties, which need to remove manually.....I just need it should be read only for current session only....if i close the session that read only property should be false......

-[]-