' =============================================================================
' NX Journal: probe how to SET the display part + locate DexManager (NX 2506)
'
' Last test failed: Parts.Display is ReadOnly. Need to find the correct API to
' set the display part (so the STEP translator's DisplayPart mode can see the
' solids in batch mode). Also re-confirm where DexManager lives (Session vs
' Part vs BasePart) to know which export API to use.
'
' Dumps (reflection only, no risky calls):
'   Session         members containing "Display" / "Dex"
'   PartCollection  members containing "Display" / "Set" / "Work"
'   Part            members containing "Display" / "Dex"
'   BasePart        members containing "Display" / "Dex"
'
' Run: WorkingDirectory = catalog-masters\KC; run_journal.exe <this file>
' Result: <cwd>\probe-display-api.txt
'
' Note: English comments only (avoids GBK/BOM mojibake on no-BOM .vb files).
' =============================================================================
Option Strict Off
Imports System
Imports System.IO
Imports System.Text
Imports NXOpen
Imports NXOpen.UF

Module ProbeDisplayApi

    Sub DumpMembers(sb As StringBuilder, prefix As String, t As System.Type, filter As String)
        For Each mi As System.Reflection.MemberInfo In t.GetMembers()
            If filter.Length = 0 OrElse mi.Name.IndexOf(filter, StringComparison.OrdinalIgnoreCase) >= 0 Then
                If mi.MemberType = System.Reflection.MemberTypes.Method OrElse
                   mi.MemberType = System.Reflection.MemberTypes.Property Then
                    sb.AppendLine(prefix & ": " & mi.MemberType & " " & mi.Name)
                End If
            End If
        Next
    End Sub

    Sub Main()
        Dim sb As New StringBuilder()

        sb.AppendLine("=== Session members (Display) ===")
        DumpMembers(sb, "S", GetType(Session), "Display")
        sb.AppendLine("=== Session members (Dex) ===")
        DumpMembers(sb, "S", GetType(Session), "Dex")

        sb.AppendLine("=== PartCollection members (Display) ===")
        DumpMembers(sb, "PC", GetType(PartCollection), "Display")
        sb.AppendLine("=== PartCollection members (Set) ===")
        DumpMembers(sb, "PC", GetType(PartCollection), "Set")
        sb.AppendLine("=== PartCollection members (Work) ===")
        DumpMembers(sb, "PC", GetType(PartCollection), "Work")

        sb.AppendLine("=== Part members (Display) ===")
        DumpMembers(sb, "P", GetType(Part), "Display")
        sb.AppendLine("=== Part members (Dex) ===")
        DumpMembers(sb, "P", GetType(Part), "Dex")

        sb.AppendLine("=== BasePart members (Display) ===")
        DumpMembers(sb, "B", GetType(BasePart), "Display")
        sb.AppendLine("=== BasePart members (Dex) ===")
        DumpMembers(sb, "B", GetType(BasePart), "Dex")

        ' Also: does BasePart have a SetDisplay-style method?
        sb.AppendLine("=== BasePart members (Set) ===")
        DumpMembers(sb, "B", GetType(BasePart), "Set")

        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "probe-display-api.txt"), sb.ToString(), New UTF8Encoding(True))
    End Sub

End Module
