Lennoluinge
Marine/Ocean
- May 27, 2009
- 4
Hi,
I have to change the color of a large number of JT files in a folder. I recorded a journal in NX5 to change the color, but I can't find a way to let NX open all files in the folder one by one. Now it only opens Part1, but I like to create some kind of a batch proces.
Any ideas?
Thanks...
' NX 5.0.4.1
' Journal created by llu on Wed May 27 11:11:17 2009 W. Europe Daylight Time
'
Option Strict Off
Imports System
Imports NXOpen
Module NXJournal
Sub Main
Dim theSession As Session = Session.GetSession()
' ----------------------------------------------
' Menu: File->Open...
' ----------------------------------------------
Dim basePart1 As BasePart
Dim partLoadStatus1 As PartLoadStatus
basePart1 = theSession.Parts.OpenBaseDisplay("C:\Documents and Settings\llu\Desktop\FOLDER1\FILE1.jt", partLoadStatus1)
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
partLoadStatus1.Dispose()
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Enter Gateway")
Dim markId2 As Session.UndoMarkId
markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Open Part Navigator")
Dim markId3 As Session.UndoMarkId
markId3 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Enter Gateway")
' ----------------------------------------------
' Menu: View->Operation->Fit
' ----------------------------------------------
workPart.ModelingViews.WorkView.Fit()
' ----------------------------------------------
' Menu: Edit->Object Display...
' ----------------------------------------------
Dim markId4 As Session.UndoMarkId
markId4 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Start")
theSession.SetUndoMarkName(markId4, "Class Selection")
' Refer to the sample NXOpen application, Selection for "Select All" alternatives.
Dim markId5 As Session.UndoMarkId
markId5 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Class Selection")
theSession.DeleteUndoMark(markId5, Nothing)
theSession.DeleteUndoMark(markId4, Nothing)
' ----------------------------------------------
' Dialog Begin Edit Object Display
' ----------------------------------------------
Dim markId6 As Session.UndoMarkId
markId6 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Edit Object Display")
Dim displayModification1 As DisplayModification
displayModification1 = theSession.DisplayManager.NewDisplayModification()
displayModification1.ApplyToAllFaces = False
displayModification1.NewColor = 128
Dim objects1(0) As DisplayableObject
Dim facetedBody1 As Facet.FacetedBody = CType(workPart.FacetedBodies.FindObject("HANDLE R-96"), Facet.FacetedBody)
objects1(0) = facetedBody1
displayModification1.Apply(objects1)
displayModification1.Dispose()
' ----------------------------------------------
' Menu: File->Save
' ----------------------------------------------
Dim partSaveStatus1 As PartSaveStatus
partSaveStatus1 = workPart.Save(BasePart.SaveComponents.True, BasePart.CloseAfterSave.False)
partSaveStatus1.Dispose()
Dim partCloseResponses1 As PartCloseResponses
partCloseResponses1 = theSession.Parts.NewPartCloseResponses()
workPart.Close(BasePart.CloseWholeTree.False, BasePart.CloseModified.UseResponses, partCloseResponses1)
workPart = Nothing
displayPart = Nothing
partCloseResponses1.Dispose()
' ----------------------------------------------
' Menu: File->Open...
' ----------------------------------------------
' ----------------------------------------------
' Menu: Tools->Journal->Stop
' ----------------------------------------------
End Sub
End Module
I have to change the color of a large number of JT files in a folder. I recorded a journal in NX5 to change the color, but I can't find a way to let NX open all files in the folder one by one. Now it only opens Part1, but I like to create some kind of a batch proces.
Any ideas?
Thanks...
' NX 5.0.4.1
' Journal created by llu on Wed May 27 11:11:17 2009 W. Europe Daylight Time
'
Option Strict Off
Imports System
Imports NXOpen
Module NXJournal
Sub Main
Dim theSession As Session = Session.GetSession()
' ----------------------------------------------
' Menu: File->Open...
' ----------------------------------------------
Dim basePart1 As BasePart
Dim partLoadStatus1 As PartLoadStatus
basePart1 = theSession.Parts.OpenBaseDisplay("C:\Documents and Settings\llu\Desktop\FOLDER1\FILE1.jt", partLoadStatus1)
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
partLoadStatus1.Dispose()
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Enter Gateway")
Dim markId2 As Session.UndoMarkId
markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Open Part Navigator")
Dim markId3 As Session.UndoMarkId
markId3 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Enter Gateway")
' ----------------------------------------------
' Menu: View->Operation->Fit
' ----------------------------------------------
workPart.ModelingViews.WorkView.Fit()
' ----------------------------------------------
' Menu: Edit->Object Display...
' ----------------------------------------------
Dim markId4 As Session.UndoMarkId
markId4 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Start")
theSession.SetUndoMarkName(markId4, "Class Selection")
' Refer to the sample NXOpen application, Selection for "Select All" alternatives.
Dim markId5 As Session.UndoMarkId
markId5 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Class Selection")
theSession.DeleteUndoMark(markId5, Nothing)
theSession.DeleteUndoMark(markId4, Nothing)
' ----------------------------------------------
' Dialog Begin Edit Object Display
' ----------------------------------------------
Dim markId6 As Session.UndoMarkId
markId6 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Edit Object Display")
Dim displayModification1 As DisplayModification
displayModification1 = theSession.DisplayManager.NewDisplayModification()
displayModification1.ApplyToAllFaces = False
displayModification1.NewColor = 128
Dim objects1(0) As DisplayableObject
Dim facetedBody1 As Facet.FacetedBody = CType(workPart.FacetedBodies.FindObject("HANDLE R-96"), Facet.FacetedBody)
objects1(0) = facetedBody1
displayModification1.Apply(objects1)
displayModification1.Dispose()
' ----------------------------------------------
' Menu: File->Save
' ----------------------------------------------
Dim partSaveStatus1 As PartSaveStatus
partSaveStatus1 = workPart.Save(BasePart.SaveComponents.True, BasePart.CloseAfterSave.False)
partSaveStatus1.Dispose()
Dim partCloseResponses1 As PartCloseResponses
partCloseResponses1 = theSession.Parts.NewPartCloseResponses()
workPart.Close(BasePart.CloseWholeTree.False, BasePart.CloseModified.UseResponses, partCloseResponses1)
workPart = Nothing
displayPart = Nothing
partCloseResponses1.Dispose()
' ----------------------------------------------
' Menu: File->Open...
' ----------------------------------------------
' ----------------------------------------------
' Menu: Tools->Journal->Stop
' ----------------------------------------------
End Sub
End Module