Quantcast
Channel: NX Design Forum topics
Viewing all articles
Browse latest Browse all 5175

NX Journal Error: file already exists

$
0
0

Hi Folks,

 

I have written a NX Journal file but still get  an error message. To solve it, I need your help.

 

The code is shown in the following. Summarised, it imports an .exp-file, adapts a parametric model according to its entries, exports an .exp-file and then saves and closes the .prt file.

 

However, I am still getting an error (see attached picture). It states, that a file in my tmp-directory C:\Users\XXX\AppData\Local\NXJournal already exists but I cannot find the mentioned folder or file.

 

I tried this with NX 11 and NX 9.0.2.5 and Win 7 and Win 10. Hope you can help me. Smiley HappyUnbenannt.png

 

' NX 9.0.2.5
' Journal created by me on Wed Mar 28 11:46:19 2018 W. Europe Daylight Time

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports Excel = Microsoft.Office.Interop.Excel
Module NXJournal

Dim selObj As NXObject = Nothing

Sub Main (ByVal args() As String)
Dim theSession As Session = Session.GetSession()
Dim fileName As String
fileName=theSession.ExecutingJournal & "\..\..\01_NX_parts\scaling.prt"

 

'OPEN NX PART
Dim part1 As Part
part1 = theSession.Parts.OpenDisplay(fileName, Nothing)
Dim workPart As Part = theSession.Parts.Work()
Dim displayPart As Part = theSession.Parts.Display

'import expressions file -->
theSession.Preferences.Modeling.UpdatePending = False
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Expression")
Dim expModified1 As Boolean
Dim errorMessages1() As String
workPart.Expressions.ImportFromFile(theSession.ExecutingJournal & "\..\..\02_NX_exchange_files\NX_import.exp", ExpressionCollection.ImportMode.Replace, expModified1, errorMessages1)
theSession.Preferences.Modeling.UpdatePending = False
Dim nErrs1 As Integer
nErrs1 = theSession.UpdateManager.DoUpdate(markId1)

'export expressions file -->
theSession.Preferences.Modeling.UpdatePending = False
workPart.Expressions.ExportToFile(ExpressionCollection.ExportMode.WorkPart, theSession.ExecutingJournal & "\..\..\02_NX_exchange_files\NX_export", ExpressionCollection.SortType.AlphaNum)

'save .prt-file
Dim partSaveStatus1 As PartSaveStatus
partSaveStatus1 = workPart.Save(BasePart.SaveComponents.True, BasePart.CloseAfterSave.False)
partSaveStatus1.Dispose()

theSession.Parts.CloseAll(BasePart.CloseModified.CloseModified, Nothing)
workPart = Nothing
displayPart = Nothing

End Sub
End Module


Viewing all articles
Browse latest Browse all 5175

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>