NX_OPEN file creation

hi
i want to create a NX open file in NX 9.0.

Nature of my work is
1) opening the nx_drawing file
2) add one drawing sheet
3) delete the same sheet created last time
4) save and close

i created a journal for above mentioned work. i need to do above activity for set of files in one folder.
Please guide me for this work.

If you want to process all the files in a given folder, a good place to start would be:
http://nxjournaling.com/content/process-files-directory

hi,
i need to do below generated journal activity for set *_dwg.prt file in supplied folder. i need to open every dwg file (1234567_dwg.prt) and add one more drawing sheet. and delete the same sheet created in last step. finally save and close the dwg file. i need to do above activity for set *_dwg.prt file in supplied folder. please guide me, i am new for NX

below i pasted the journal recorded for that process.

' NX 9.0.0.19
' Journal created ezf
'
Option Strict Off
Imports System
Imports NXOpen

Module NXJournal
Sub Main (ByVal args() As String)

Dim theSession As Session = Session.GetSession()
' ----------------------------------------------
' Menu: File->Open...
' ----------------------------------------------
Dim basePart1 As BasePart
Dim partLoadStatus1 As PartLoadStatus
basePart1 = theSession.Parts.OpenBaseDisplay("E:\nx_journaling\1234567_dwg1.prt", 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.Visible, "Enter Modeling")

' ----------------------------------------------
' Menu: Application->Drafting...
' ----------------------------------------------
Dim drawingSheet1 As Drawings.DrawingSheet = CType(workPart.DrawingSheets.FindObject("Sheet 1"), Drawings.DrawingSheet)

drawingSheet1.Open()

Dim markId3 As Session.UndoMarkId
markId3 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Enter Drafting")

workPart.Views.WorkView.UpdateCustomSymbols()

workPart.Drafting.SetTemplateInstantiationIsComplete(True)

' ----------------------------------------------
' Menu: Insert->Sheet...
' ----------------------------------------------
Dim markId4 As Session.UndoMarkId
markId4 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start")

Dim nullDrawings_DrawingSheet As Drawings.DrawingSheet = Nothing

Dim drawingSheetBuilder1 As Drawings.DrawingSheetBuilder
drawingSheetBuilder1 = workPart.DrawingSheets.DrawingSheetBuilder(nullDrawings_DrawingSheet)

drawingSheetBuilder1.AutoStartViewCreation = True

drawingSheetBuilder1.MetricSheetTemplateLocation = "C:\Program Files\Siemens\NX 9.0\ugii\templates\Drawing-A0-Size2D-template.prt"

drawingSheetBuilder1.EnglishSheetTemplateLocation = "C:\Program Files\Siemens\NX 9.0\ugii\templates\Drawing-A-Size2D-template.prt"

drawingSheetBuilder1.Height = 841.0

drawingSheetBuilder1.Length = 1189.0

drawingSheetBuilder1.StandardMetricScale = Drawings.DrawingSheetBuilder.SheetStandardMetricScale.S11

drawingSheetBuilder1.StandardEnglishScale = Drawings.DrawingSheetBuilder.SheetStandardEnglishScale.S11

drawingSheetBuilder1.ScaleNumerator = 1.0

drawingSheetBuilder1.ScaleDenominator = 1.0

drawingSheetBuilder1.Units = Drawings.DrawingSheetBuilder.SheetUnits.Metric

drawingSheetBuilder1.ProjectionAngle = Drawings.DrawingSheetBuilder.SheetProjectionAngle.Third

drawingSheetBuilder1.Number = "2"

drawingSheetBuilder1.SecondaryNumber = ""

drawingSheetBuilder1.Revision = "A"

theSession.SetUndoMarkName(markId4, "Sheet Dialog")

drawingSheetBuilder1.MetricSheetTemplateLocation = "C:\Program Files\Siemens\NX 9.0\ugii\templates\Drawing-A0-Size2D-template.prt"

drawingSheetBuilder1.MetricSheetTemplateLocation = "C:\Program Files\Siemens\NX 9.0\ugii\templates\Drawing-A0-Size2D-template.prt"

Dim markId5 As Session.UndoMarkId
markId5 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Sheet")

theSession.DeleteUndoMark(markId5, Nothing)

Dim markId6 As Session.UndoMarkId
markId6 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Sheet")

Dim nXObject1 As NXObject
nXObject1 = drawingSheetBuilder1.Commit()

theSession.DeleteUndoMark(markId6, Nothing)

theSession.SetUndoMarkName(markId4, "Sheet")

drawingSheetBuilder1.Destroy()

workPart.Drafting.SetTemplateInstantiationIsComplete(True)

Dim markId7 As Session.UndoMarkId
markId7 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start")

Dim titleblocks1(0) As Annotations.TitleBlock
Dim titleBlock1 As Annotations.TitleBlock = CType(workPart.FindObject("ENTITY 25 1 1"), Annotations.TitleBlock)

titleblocks1(0) = titleBlock1
Dim editTitleBlockBuilder1 As Annotations.EditTitleBlockBuilder
editTitleBlockBuilder1 = workPart.DraftingManager.TitleBlocks.CreateEditTitleBlockBuilder(titleblocks1)

Dim titleBlockCellBuilderList1 As Annotations.TitleBlockCellBuilderList
titleBlockCellBuilderList1 = editTitleBlockBuilder1.Cells

theSession.SetUndoMarkName(markId7, "Populate Title Block Dialog")

Dim taggedObject1 As TaggedObject
taggedObject1 = titleBlockCellBuilderList1.FindItem(0)

Dim titleBlockCellBuilder1 As Annotations.TitleBlockCellBuilder = CType(taggedObject1, Annotations.TitleBlockCellBuilder)

Dim taggedObject2 As TaggedObject
taggedObject2 = titleBlockCellBuilderList1.FindItem(1)

Dim titleBlockCellBuilder2 As Annotations.TitleBlockCellBuilder = CType(taggedObject2, Annotations.TitleBlockCellBuilder)

Dim taggedObject3 As TaggedObject
taggedObject3 = titleBlockCellBuilderList1.FindItem(2)

Dim titleBlockCellBuilder3 As Annotations.TitleBlockCellBuilder = CType(taggedObject3, Annotations.TitleBlockCellBuilder)

Dim taggedObject4 As TaggedObject
taggedObject4 = titleBlockCellBuilderList1.FindItem(3)

Dim titleBlockCellBuilder4 As Annotations.TitleBlockCellBuilder = CType(taggedObject4, Annotations.TitleBlockCellBuilder)

Dim taggedObject5 As TaggedObject
taggedObject5 = titleBlockCellBuilderList1.FindItem(4)

Dim titleBlockCellBuilder5 As Annotations.TitleBlockCellBuilder = CType(taggedObject5, Annotations.TitleBlockCellBuilder)

Dim markId8 As Session.UndoMarkId
markId8 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Populate Title Block")

' ----------------------------------------------
' Dialog Begin Populate Title Block
' ----------------------------------------------
theSession.DeleteUndoMark(markId8, Nothing)

Dim markId9 As Session.UndoMarkId
markId9 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Populate Title Block")

theSession.DeleteUndoMark(markId9, Nothing)

Dim markId10 As Session.UndoMarkId
markId10 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Populate Title Block")

editTitleBlockBuilder1.Destroy()

theSession.UndoToMark(markId7, Nothing)

theSession.DeleteUndoMark(markId7, Nothing)

' ----------------------------------------------
' Menu: Edit->Delete...
' ----------------------------------------------
Dim markId11 As Session.UndoMarkId
markId11 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Delete")

Dim notifyOnDelete1 As Boolean
notifyOnDelete1 = theSession.Preferences.Modeling.NotifyOnDelete

theSession.UpdateManager.ClearErrorList()

Dim markId12 As Session.UndoMarkId
markId12 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Delete")

Dim objects1(0) As NXObject
Dim view1 As View = CType(workPart.Views.FindObject("Sheet 2@0"), View)

objects1(0) = view1
Dim nErrs1 As Integer
nErrs1 = theSession.UpdateManager.AddToDeleteList(objects1)

Dim notifyOnDelete2 As Boolean
notifyOnDelete2 = theSession.Preferences.Modeling.NotifyOnDelete

Dim nErrs2 As Integer
nErrs2 = theSession.UpdateManager.DoUpdate(markId12)

theSession.DeleteUndoMark(markId11, Nothing)

' ----------------------------------------------
' Menu: File->Close->Save and Close
' ----------------------------------------------
Dim partSaveStatus1 As PartSaveStatus
partSaveStatus1 = workPart.Save(BasePart.SaveComponents.True, BasePart.CloseAfterSave.True)

workPart = Nothing
displayPart = Nothing
partSaveStatus1.Dispose()
' ----------------------------------------------
' Menu: Tools->Journal->Stop Recording
' ----------------------------------------------

End Sub
End Module

balaji.L