I used some of your code and some code from this post
I hop this can helping (run journal in an opened part assembly No selection needed)
Option Strict Off
Imports System
Imports System.Collections
Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI
Imports NXOpen.Assemblies
Module changeColorOfPreSelectedFaces_v3
Dim theSession As Session = Session.GetSession()
Sub Main()
Dim disPart As Part = theSession.Parts.Display
Dim i As Integer = 0
Dim faceArray(-1) As DisplayableObject
Dim allComp1 As ArrayList = New ArrayList
Dim root As Component = disPart.ComponentAssembly.RootComponent
If Not IsNothing(root) Then
getAllComponents2(root, allComp1)
Dim dispobj As DisplayableObject = Nothing
Dim cnt1 As Integer = allComp1.Count
Dim objectArray1(cnt1 - 1) As DisplayableObject
For i = 0 To cnt1 - 1
dispobj = DirectCast(allComp1(i), DisplayableObject)
ReDim Preserve faceArray(i)
faceArray(i) = dispobj
Next
End If
Dim changeBodytransluency As DisplayModification = _
theSession.DisplayManager.NewDisplayModification()
With changeBodytransluency
.ApplyToAllFaces = true
' .NewColor = newColorCode
.NewTranslucency = 75
.Apply(faceArray)
.Dispose()
End With
End Sub
Sub getAllComponents2(ByVal comp As Component, ByRef allComp As ArrayList)
Dim child As Component = Nothing
Dim space As String = Nothing
For Each child In comp.GetChildren()
allComp.Add(child)
getAllComponents2(child, allComp)
Next
End Sub
Public Function GetUnloadOption(ByVal dummy As String) As Integer
GetUnloadOption = NXOpen.UF.UFConstants.UF_UNLOAD_IMMEDIATELY
End Function
End Module