Showing results for 
Search instead for 
Do you mean 
Solved! Go to solution

Auto balloon integrity checker

[ Edited ]

Dear community


how can I achieve a check for completeness when I have set up a part list and ballons with callouts for each component listed in that partlist. what is the matching function or workflow for this?







Re: Auto balloon integrity checker

I mean a function to check if all partlist callouts are ballooned on the drawing views
Accepted by topic author mascaritas
‎11-18-2016 09:58 AM

Re: Auto balloon integrity checker

mascaritas wrote:
I mean a function to check if all partlist callouts are ballooned on the drawing views

'January 20, 2015
'NX 8.5
'Journal to report which items in a parts list do not have corresponding balloon callouts.
'Inspired by and based on the GTAC sample "report_missing_balloons_of_parts_lists" (nxapi_5333)
'by Frank Berger.
'The GTAC sample will only work with NX 9 or higher; this journal will work with NX 8.5,
'and possibly with older versions back to NX 5.

Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF

Module report_missing_balloons_v3

Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession()

Dim lw As ListingWindow = theSession.ListingWindow

Sub Main()

If IsNothing(theSession.Parts.Work) Then
'active part required
End If

Dim workPart As Part = theSession.Parts.Work

Dim partListTags() As Tag = Nothing
Dim numPartLists As Integer = 0
theUfSession.Plist.AskTags(partListTags, numPartLists)

If numPartLists = 0 Then
lw.WriteLine("No parts list found in the work part")
End If


If numPartLists > 1 Then
lw.WriteLine("ERROR: Cannot evaluate AutoBalloons with multiple parts lists.")
lw.WriteLine("Check environment variable UGII_UPDATE_ALL_ID_SYMBOLS_WITH_PLIST")
End If

Dim numRows As Integer
theUfSession.Tabnot.AskNmRows(partListTags(0), numRows)

Dim plistPrefs As UFPlist.Prefs = Nothing
theUfSession.Plist.AskPrefs(partListTags(0), plistPrefs)

Dim colCallout As Tag = PartListCalloutColumn(partListTags(0))
If colCallout = Tag.Null Then
lw.WriteLine("parts list callout column not found")
End If

Dim plBalloonList As New List(Of String)
CollectPartsListBalloons(plBalloonList, plistPrefs.symbol_type)

Dim missingBalloons As New List(Of String)

Dim startTime As DateTime = Now

'loop through rows of the parts list, look for corresponding autoballoon callout
For i As Integer = 0 To numRows - 1

Dim rowTag As Tag
theUfSession.Tabnot.AskNthRow(partListTags(0), i, rowTag)

Dim cellTag As Tag
theUfSession.Tabnot.AskCellAtRowCol(rowTag, colCallout, cellTag)

Dim calloutEvText As String = ""
theUfSession.Tabnot.AskEvaluatedCellText(cellTag, calloutEvText)

If plBalloonList.Contains(calloutEvText) Then
'balloon found, remove it from the list so future searches are potentially faster
'balloon not found, add callout to the "missing" list
End If


Dim endTime As DateTime = Now

If missingBalloons.Count = 0 Then
lw.WriteLine("Tutti i componenti della PART LIST risultano pallinati !")
lw.WriteLine("Hmmm... It seems that " & missingBalloons.Count.ToString & " parts in the list do NOT have corresponding balloon callouts.")
For Each missing As String In missingBalloons
End If

Dim elapsedTime As TimeSpan = endTime.Subtract(startTime)
'lw.WriteFullline("elapsed time: " & elapsedTime.ToString)


End Sub

Function PartListCalloutColumn(ByVal partListTag As Tag) As Tag

Dim numColumns As Integer
theUfSession.Tabnot.AskNmColumns(partListTag, numColumns)

Dim rowTag As Tag
theUfSession.Tabnot.AskNthRow(partListTag, 0, rowTag)

For j As Integer = 0 To numColumns - 1
Dim colTag As Tag
theUfSession.Tabnot.AskNthColumn(partListTag, j, colTag)

Dim cellTag As Tag
theUfSession.Tabnot.AskCellAtRowCol(rowTag, colTag, cellTag)

'get the current cell text
Dim cellText As String = ""
theUfSession.Tabnot.AskCellText(cellTag, cellText)
If cellText = "$~C" Then
'callout column
Return colTag

End If


Return Nothing

End Function

Sub CollectPartsListBalloons(ByRef theBalloonList As List(Of String), ByVal plSymbolType As Integer)

For Each tempId As Annotations.IdSymbol In theSession.Parts.Work.Annotations.IdSymbols

Dim theIdSymbolBuilder As Annotations.IdSymbolBuilder = theSession.Parts.Work.Annotations.IdSymbols.CreateIdSymbolBuilder(tempId)

If plSymbolType = theIdSymbolBuilder.Type + 1 Then
'symbol matches type used in parts list
'symbol not the type used in parts list, skip it
Continue For
End If

'add unique callouts to the list

'assumes the callout is in the ".UpperText" property
'change this to .LowerText if needed

If Not theBalloonList.Contains(theIdSymbolBuilder.UpperText) Then
End If



End Sub

Public Function GetUnloadOption(ByVal dummy As String) As Integer

'Unloads the image when the NX session terminates
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination

'----Other unload options-------
'Unloads the image immediately after execution within NX
'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

'Unloads the image explicitly, via an unload dialog
'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly

End Function

End Module


Thank you...

Using NX 10 / RuleDesigner PDM

Testing NX 11 on production
Testing NX 12 Beta on production

Re: Auto balloon integrity checker

As noted in the code above, it was written for NX 8.5 and lower. If you are using NX 9 or higher, I suggest using this version.