Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.Features
Module HoleColours
Sub Main()
Dim s As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()
Dim dp As Part = s.Parts.Work
Dim expstring As String = Nothing
Dim index2 As Integer = -1
Dim exps() As Expression
Dim holewiththread As Boolean = False
Dim holeexpstring As String = "Threaded"
Dim hole As BodyFeature
Dim faces() As Face
Dim nFaces As Integer = 0
Dim obj(-1) As DisplayableObject
Dim displayModification1 As DisplayModification
Dim featcoll As FeatureCollection = dp.Features
For Each f As Feature In featcoll
If f.FeatureType = "SIMPLE HOLE" Then
holewiththread = False
exps = f.GetExpressions()
index2 = exps(0).Description.IndexOf(holeexpstring)
If index2 > 0 Then
holewiththread = True
End If
If holewiththread = True Then
hole = DirectCast(f, BodyFeature)
faces = hole.GetFaces()
nFaces = faces.Length
ReDim obj(nFaces - 1)
For i As Integer = 0 To nFaces - 1
obj(i) = faces(i)
Next
displayModification1 = s.DisplayManager.NewDisplayModification()
displayModification1.ApplyToAllFaces = False
displayModification1.NewColor = 6
displayModification1.Apply(obj)
Else 'holewiththread is false
'hole = DirectCast(f, BodyFeature)
'faces = hole.GetFaces()
'nFaces = faces.Length
'ReDim obj(nFaces - 1)
'For i As Integer = 0 To nFaces - 1
' obj(i) = faces(i)
'Next
'displayModification1 = s.DisplayManager.NewDisplayModification()
'displayModification1.ApplyToAllFaces = False
'displayModification1.NewColor = 211
'displayModification1.Apply(obj)
End If
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