Forums:
I'm attempting to create a Journal script to search through all drawing sheets in a file and delete any Pattern features found. I found a post with similar code (https://community.sw.siemens.com/s/question/0D54O000061xREWSA2/nx-journa...) and tried modifying to suit my needs. I've been unable to get it to select Patterns. The code below currently finds all radius dimensions and deletes them. I suspect the displayPart.Dimensions needs to be something else but I've not been able to figure out what. I haven't found anything in the NX Open documentation that works.
Option Strict Off Imports System Imports NXOpen Imports NXOpen.UF Imports NXOpen.Annotations Imports NXOpenUI Module delete_all_patterns Dim s As Session = Session.GetSession() Dim ufs As UFSession = UFSession.GetUFSession() Dim lw As ListingWindow = s.ListingWindow() Sub Main() Dim myUndoMark As Session.UndoMarkId = s.SetUndoMark(Session.MarkVisibility.Visible, "Delete Patterns") Dim displayPart As Part = s.Parts.Display For Each thisPattern As Object in displayPart.Dimensions If is_Pattern(thisPattern) Then s.UpdateManager.AddToDeleteList(thisPattern) End If Next Dim count As Integer = s.UpdateManager.GetDeleteList.Length s.UpdateManager.DoUpdate(myUndoMark) lw.Open() lw.WriteLine("Deleted " + count.ToString() + " Objects") End Sub Function is_Pattern(thePattern As Object) As Boolean Dim objType As Integer Dim objSubtype As Integer ufs.Obj.AskTypeAndSubtype(thePattern.Tag, objType, objSubtype) If objSubtype = 9 Then Return True End If Return False End Function Public Function GetUnloadOption(ByVal dummy As String) As Integer Return Session.LibraryUnloadOption.Immediately End Function End Module