Hello, I´m new to NX, and new to NX Journaling (my programming abilities are mostly on embedded systems microcontrollers and PLC´s).
I need a simple program to extract balloons and notes information from a drawing, so far, I recorded a Journal. In this journal I follow the next menu path: menu>information>Object
There I apply 2 filters: type-filter where I select Notes and symbol, then I select detail filtering to only select balloons, finally I select a color filter (color #6). After the filters, I click all objects and last I proceed to extract the info (click).
The problem is I don´t know how to get rid of the selection stickiness.
I appreciate your help beforehand. And appreciate the effort you've invested to crate and maintaining this community.
Here is the recorded Code (I've deleted sticky objects that where created except the first two and the last ones).
NX 10.0.3.5
Option Strict Off
Imports System
Imports NXOpen
Module NXJournal
Sub Main (ByVal args() As String)
Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()
Dim workPart As NXOpen.Part = theSession.Parts.Work
Dim displayPart As NXOpen.Part = theSession.Parts.Display
' ----------------------------------------------
' Menu: Information->Object...
' ----------------------------------------------
Dim markId1 As NXOpen.Session.UndoMarkId
markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Start")
theSession.SetUndoMarkName(markId1, "Class Selection Dialog")
' ----------------------------------------------
' Dialog Begin Select by Type
' ----------------------------------------------
' ----------------------------------------------
' Dialog Begin Symbol
' ----------------------------------------------
' ----------------------------------------------
' Dialog Begin Select by Type
' ----------------------------------------------
' ----------------------------------------------
' Dialog Begin Color
' ----------------------------------------------
' Refer to the sample NXOpen application, Selection for "Select All" alternatives.
Dim markId2 As NXOpen.Session.UndoMarkId
markId2 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Class Selection")
theSession.DeleteUndoMark(markId2, Nothing)
Dim markId3 As NXOpen.Session.UndoMarkId
markId3 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Class Selection")
theSession.DeleteUndoMark(markId3, Nothing)
theSession.SetUndoMarkName(markId1, "Class Selection")
theSession.DeleteUndoMark(markId1, Nothing)
Dim selectedObjects1(84) As NXOpen.NXObject
Dim note1 As NXOpen.Annotations.Note = CType(workPart.FindObject("HANDLE R-XXXXXXX"), NXOpen.Annotations.Note)
selectedObjects1(0) = note1
Dim note2 As NXOpen.Annotations.Note = CType(workPart.FindObject("HANDLE R-XXXXXXXX"), NXOpen.Annotations.Note)
selectedObjects1(11) = note12
Dim idSymbol1 As NXOpen.Annotations.IdSymbol = CType(workPart.FindObject("HANDLE R-XXXXXXXX"), NXOpen.Annotations.IdSymbol)
selectedObjects1(84) = note77
theSession.Information.DisplayObjectsDetails(selectedObjects1)
' ----------------------------------------------
' Menu: Edit->Undo List->1 Enter Drafting
' ----------------------------------------------
Dim marksRecycled1 As Boolean
Dim undoUnavailable1 As Boolean
theSession.UndoLastNVisibleMarks(1, marksRecycled1, undoUnavailable1)
' ----------------------------------------------
' Menu: Tools->Journal->Stop Recording
' ----------------------------------------------
End Sub
End Module
re: balloon information
Try the code below. It cycles through all the ID symbols in the part looking for parts list balloons that are the specified color.
Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF
Module Module1
Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession()
Dim theUI As UI = UI.GetUI()
Dim lw As ListingWindow = theSession.ListingWindow
Sub Main()
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "balloon info")
lw.Open()
Dim IdBalloons As New List(Of Annotations.IdSymbol)
CollectAutoBalloons(IdBalloons, 6)
'lw.WriteLine(IdBalloons.Count.ToString & " objects found")
theSession.Information.DisplayObjectsDetails(IdBalloons.ToArray)
lw.Close()
End Sub
Sub CollectAutoBalloons(ByRef theList As List(Of Annotations.IdSymbol), ByVal colorID As Integer)
'cycle through all ID symbols in the work part
For Each tempID As Annotations.IdSymbol In theSession.Parts.Work.Annotations.IdSymbols
Dim theCallout As Tag = Nothing
theUfSession.Drf.AskCalloutOfAnnotation(tempID.Tag, theCallout)
If theCallout = Tag.Null Then
'not an autoballoon (parts list balloon)
Continue For
End If
'only add symbols where the color ID = specified color ID
If tempID.Color = colorID Then
theList.Add(tempID)
End If
Next
End Sub
Public Function GetUnloadOption(ByVal dummy As String) As Integer
'Unloads the image immediately after execution within NX
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
End Function
End Module