I am in need of an custom application to programatically query a selected part to see if it contains a symbolic thread. If the part contains a symbolic thread, I would like to extract the "Callout" value for that specific thread. Any help would be greatly appreciated.
Solved! Go to Solution.
Run the following code on a part that has a symbolic thread applied to a face.
Option Strict Off Imports System Imports NXOpen Imports NXOpen.UF Module Module3 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 Return End If Dim workPart As Part = theSession.Parts.Work lw.Open() Const undoMarkName As String = "report symbolic thread parameters" Dim markId1 As Session.UndoMarkId markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName) For Each tempFeat As Features.Feature In workPart.Features If tempFeat.FeatureType <> "SYMBOLIC_THREAD" Then 'skip to next feature Continue For End If lw.WriteLine(tempFeat.GetFeatureName) Dim myThreadParms As UFModl.SymbThreadData Try theUfSession.Modl.AskSymbThreadParms(tempFeat.Tag, myThreadParms) lw.WriteLine("callout: " & myThreadParms.callout) lw.WriteLine("form: " & myThreadParms.form) If myThreadParms.rotation = UFConstants.UF_MODL_RIGHT_HAND Then lw.WriteLine("right hand thread") Else lw.WriteLine("left hand thread") End If Catch ex As NXException theSession.UndoToMark(markId1, undoMarkName) MsgBox(ex.Message) Finally End Try lw.WriteLine("") Next lw.Close() End Sub Public Function GetUnloadOption(ByVal dummy As String) As Integer 'Unloads the image when the NX session terminates GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination End Function End Module
Hey Cowski, thanks for the reply and the code works great. I failed to mention one thing when making my original post. In order to select the correct symbolic feature (as there could be miltiplr symbolic features) I have changed the feature name to "Conn Thread" so in the part I am testing it on the part navigator shows "Symbolic Thread (65) "Conn Thread". I have looked through the object browser in Visual Studio for the options on UGModl.SymbThreadData and have not found anything to extract that portion of the feature. Any ideas on that one?
In that case, you have supplied a custom name for the feature. You can look for it in the loop, something like:
For Each tempFeat As Features.Feature In workPart.Features 'look for named feature If tempFeat.Name <> "Conn Thread" Then 'skip to next feature Continue For End If 'make sure it is the right feature type If tempFeat.FeatureType <> "SYMBOLIC_THREAD" Then 'skip to next feature Continue For End If
You won't find the custom feature name in the thread data, rather it can be found as part of the feature object itself (you can rename any feature type, not just thread features).