krz177
Mechanical
- Jan 11, 2015
- 14
I have wrote a program that sets the assembly load options to specific folders for a particular set of jobs and then opens the selected assembly with these options. The program works great on my box but it was meant to run on the viewer. All of the functions I am using are available in gateway and the program does run about half way letting the user select the assembly they want to open but then errors out when the actual NX functions are called upon in the program. I am using the "OpenFileDialog" function from windows which is the only part that runs.
Is what I am trying to do even possible on a viewer? I assumed it was because it would let me run a signed .dll and I can carry out all of these functions out manually in gateway, any thoughts?
Is what I am trying to do even possible on a viewer? I assumed it was because it would let me run a signed .dll and I can carry out all of these functions out manually in gateway, any thoughts?
Code:
Option Strict Off
Option Infer On
Imports NXOpen, System, System.IO, System.Windows.Forms
Public Class OpenMssc
Public Shared Sub Main()
Dim fd As OpenFileDialog = New OpenFileDialog()
Dim strFileName As String
fd.Title = "Open MSSC Assembly"
fd.InitialDirectory = "T:\Die_Dept\"
fd.Filter = "Part files (*.prt*)|*.prt*"
fd.FilterIndex = 1
fd.RestoreDirectory = True
If fd.ShowDialog() = DialogResult.OK Then
strFileName = fd.FileName
End If
Dim fileNumberExt As String
fileNumberExt = strFileName.Substring(12, 4)
Dim theSession As Session = Session.GetSession()
theSession.Parts.LoadOptions.LoadLatest = False
theSession.Parts.LoadOptions.ComponentLoadMethod = LoadOptions.LoadMethod.SearchDirectories
Dim searchDirectories1(1) As String
'file locations to search
searchDirectories1(0) = "T:\Die_Dept\" & fileNumberExt & "\" & fileNumberExt & "_dd\"
searchDirectories1(1) = "T:\Die_Dept\4333_Kanban\4333_dd\"
Dim searchSubDirs1(1) As Boolean
searchSubDirs1(0) = False
searchSubDirs1(1) = False
theSession.Parts.LoadOptions.SetSearchDirectories(searchDirectories1, searchSubDirs1)
theSession.Parts.LoadOptions.ComponentsToLoad = LoadOptions.LoadComponents.All
theSession.Parts.LoadOptions.UsePartialLoading = True
theSession.Parts.LoadOptions.UseLightweightRepresentations = False
Dim basePart1 As BasePart
Dim partLoadStatus1 As PartLoadStatus
basePart1 = theSession.Parts.OpenBaseDisplay(strFileName, partLoadStatus1)
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
partLoadStatus1.Dispose()
'revert load settings back to default option
theSession.Parts.LoadOptions.ComponentLoadMethod = LoadOptions.LoadMethod.FromDirectory
End Sub
End Class