multicaduser
Industrial
- Jan 29, 2013
- 261
Tested this again today, this journal runs without issues in 2212 but errors out in 2306. It depends on a specific directory structure and errors out and any project, so it doesn't look like a file system issue.
Thanks in advance for any help.
NX 2212 Windows 10
Thanks in advance for any help.
Code:
'NX 12
'journal creates burn assembly from displayed part
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI
Module NXJournal
Sub Main ()
Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession()
Dim ufs As UFSession = UFSession.GetUFSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Dim CurrentPath As String = IO.Path.GetDirectoryName(workPart.FullPath)
Dim CurrentFile As String = IO.Path.GetFileNameWithoutExtension(workPart.FullPath)
Dim lw As ListingWindow = theSession.ListingWindow
Dim fileNew1 As NXOpen.FileNew = Nothing
fileNew1 = theSession.Parts.FileNew()
Dim theUI As UI = UI.GetUI
lw.Open()
'check file location for correctness
Dim PathPosition As Integer = Instr(1,CurrentPath,"CAD")
PathPosition = Instr(1,CurrentPath,"CAD")
Dim restName As String = CurrentFile.Substring(0,CurrentFile.Length)
Dim BasePath As String = CurrentPath.Substring(0,PathPosition-1)
lw.writeline(restname)
lw.Writeline(BasePath)
' lw.WriteLine(PathPosition)
If (PathPosition = 0) Then
lw.WriteLine("Source file is not in Mold CAD directory")
lw.WriteLine("Exiting")
theUFSession.UI.UpdateListingWindow()
Exit Sub
End If
'suffix for burn assembly file
Dim suffixString As String = "_burn"
'build new file/path strings
Dim BurnFile = RestName & suffixString & ".prt"
lw.WriteLine(Burnfile)
Dim BurnPath As String = BasePath & "CAM\Electrode\" & BurnFile
lw.WriteLine(BurnPath)
'create new file and make it displayed part
fileNew1.Units = NXOpen.Part.Units.Inches
fileNew1.TemplateFileName = "model-plain-1-inch-template.prt"
fileNew1.TemplatePresentationName = "Model"
fileNew1.NewFileName = BurnPath
fileNew1.MakeDisplayedPart = True
fileNew1.DisplayPartOption = NXOpen.DisplayPartOption.AllowAdditional
fileNew1.Commit()
workPart = theSession.Parts.Work
displayPart = theSession.Parts.Display
fileNew1.Destroy()
End Sub
End Module
NX 2212 Windows 10