OK. I threw this together in iLogic. See if this will work for you.
Keep in mind that this is just a test which searches for threads that were either created as a tapped hole feature, or as a ThreadFeature, so if your model only has physically modeled threads, and neither of the other two, it may not work properly. For now I'm just using MsgBox to return the result of the test, but this could be put into its own Function, to return a String (like "Bolt", "Nut", "Washer", "Unknown").
Dim oPDoc As PartDocument = ThisApplication.ActiveDocument
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
'Build a list of Strings that represent all the Class identifiers for Internal threads and a List for External threads.
Dim oInList As New List(Of String) 'for every internal thread Class
oInList.Add("1B") : oInList.Add("2B") : oInList.Add("3B") : oInList.Add("6H") : oInList.Add("7H")
Dim oExList As New List(Of String) 'for every external thread Class
oInList.Add("1A") : oInList.Add("2A") : oInList.Add("3A") : oInList.Add("6g") : oInList.Add("4g6g") : oInList.Add("7e")
Dim oClass As String
Dim oThreadFound As Boolean = False
Dim oClassFound As Boolean = False
Dim oInternal As Boolean = False
Dim oFeats As PartFeatures = oPDef.Features
Dim oThreadInfo As HoleTapInfo
If oFeats.HoleFeatures.Count > 0 Then
'It has to be either a Nut or a Washer, depending on how they were modeled
'But if the Nut or Washer were created as an extrude feature that already had the hole included, then there won't be any HoleFeatures..
For Each oHole As HoleFeature In oFeats.HoleFeatures
If oHole.HoleType = HoleTypeEnum.kDrilledHole And oHole.Tapped Then
oThreadFound = True
oThreadInfo = oHole.TapInfo
For Each oClass In oInList
If oThreadInfo.Class = oClass Then 'It is an internal thread, and so it is a Nut
oClassFound = True
oInternal = True
End If
Next
For Each oClass In oExList
If oThreadInfo.Class = oClass Then 'It is an internal thread, and so it is a Nut
oClassFound = True
oInternal = False
End If
Next
If oClassFound = False Then
MsgBox("The Class of the hole's threads did not match any value of either list.", vbOKOnly, "INCONCLUSIVE")
End If
End If
Next
End If
If oFeats.ThreadFeatures.Count > 0 Then
For Each oTFeat As ThreadFeature In oFeats.ThreadFeatures
oInternal = oTFeat.ThreadInfo.Internal
oThreadFound = True
Next
End If
If oThreadFound = False Then
MsgBox("No threads found in this part, so it must be a Washer.", vbOKOnly + vbInformation, " ")
Return
End If
If oInternal = True Then
MsgBox("The part has internal threads, so it must be a Nut.", vbOKOnly + vbInformation, " ")
ElseIf oInternal = False Then
MsgBox("The part has external threads, so it must be a Bolt.", vbOKOnly + vbInformation, " ")
End If
Wesley Crihfield

(Not an Autodesk Employee)