NXJockey
Automotive
- Feb 9, 2009
- 104
i am trying to create a simple vb script to cycle through all the views in a drawing sheet and reset them to the customer defaults.
I have created the attached code, but it fails, and I cant work out why:- 'Object reference not set to an instance of object' so I think its something to do with the array of the views????
Any help or advice is welcomed,
Thanks in advance,
Nxj
Here is the code;-
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.Drawings
Imports NXOpen.UI
Imports NXOpen.Utilities
Module ir_6775305
Dim s As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Sub Main()
Dim dp As Part = s.Parts.Display()
s.ListingWindow.Open()
For Each dwg As DrawingSheet In dp.DrawingSheets
dwg.Open()
s.ListingWindow.WriteLine("Drawing: " & dwg.Name.ToString)
For Each thisView As DraftingView In dwg.GetDraftingViews()
s.ListingWindow.WriteLine(" " & thisView.Name.ToString)
Dim views() as view
Dim editViewSettingsBuilder1 As Drawings.EditViewSettingsBuilder
editViewSettingsBuilder1 = workPart.SettingsManager.CreateDrawingEditViewSettingsBuilder(views)
editViewSettingsBuilder1.InheritSettingsFromCustomerDefault()
thisView.UpdateDisplay()
Next
Next
End Sub
Public Function GetUnloadOption(ByVal dummy As String) As Integer
Return Session.LibraryUnloadOption.Immediately
End Function
End Module
I have created the attached code, but it fails, and I cant work out why:- 'Object reference not set to an instance of object' so I think its something to do with the array of the views????
Any help or advice is welcomed,
Thanks in advance,
Nxj
Here is the code;-
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.Drawings
Imports NXOpen.UI
Imports NXOpen.Utilities
Module ir_6775305
Dim s As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Sub Main()
Dim dp As Part = s.Parts.Display()
s.ListingWindow.Open()
For Each dwg As DrawingSheet In dp.DrawingSheets
dwg.Open()
s.ListingWindow.WriteLine("Drawing: " & dwg.Name.ToString)
For Each thisView As DraftingView In dwg.GetDraftingViews()
s.ListingWindow.WriteLine(" " & thisView.Name.ToString)
Dim views() as view
Dim editViewSettingsBuilder1 As Drawings.EditViewSettingsBuilder
editViewSettingsBuilder1 = workPart.SettingsManager.CreateDrawingEditViewSettingsBuilder(views)
editViewSettingsBuilder1.InheritSettingsFromCustomerDefault()
thisView.UpdateDisplay()
Next
Next
End Sub
Public Function GetUnloadOption(ByVal dummy As String) As Integer
Return Session.LibraryUnloadOption.Immediately
End Function
End Module