' NX 2506 API 反射探针 2 (稳健版): 跨全部已加载程序集查找类型成员与枚举 Option Strict Off Imports System Imports System.IO Imports System.Text Imports NXOpen Imports NXOpen.UF Module ProbeApi2 Function FindType(n As String) As System.Type ' 探针1已验证: NXOpen 类型都在 GetType(Session).Assembly 里 (运行时程序集名不含 NXOpen) Dim t As System.Type = GetType(Session).Assembly.GetType(n, False) If t IsNot Nothing Then Return t For Each a As System.Reflection.Assembly In AppDomain.CurrentDomain.GetAssemblies() t = a.GetType(n, False) If t IsNot Nothing Then Return t Next Return Nothing End Function Sub Dump(out As StringBuilder, prefix As String, typeName As String) Dim t As System.Type = FindType(typeName) If t Is Nothing Then out.AppendLine(prefix & " [类型未找到: " & typeName & "]") Return End If out.AppendLine("=== " & typeName & " 成员 ===") For Each mi As System.Reflection.MemberInfo In t.GetMembers() If mi.MemberType = System.Reflection.MemberTypes.Method OrElse mi.MemberType = System.Reflection.MemberTypes.Property Then out.AppendLine(prefix & ": " & mi.Name) End If Next For Each nt As System.Type In t.GetNestedTypes() out.AppendLine(prefix & " NESTED: " & nt.Name) For Each f As System.Reflection.FieldInfo In nt.GetFields() If f.IsStatic Then out.AppendLine(prefix & " = " & f.Name) Next Next End Sub Sub Main() Dim out As New StringBuilder() Dump(out, "DM", "NXOpen.DexManager") Dump(out, "DB", "NXOpen.DexBuilder") Dump(out, "ST", "NXOpen.STLCreator") Dump(out, "PS", "NXOpen.ParasolidExporter") Dump(out, "UM", "NXOpen.UpdateManager") Dump(out, "UP", "NXOpen.Update") out.AppendLine("=== 全部已加载程序集 ===") For Each a As System.Reflection.Assembly In AppDomain.CurrentDomain.GetAssemblies() out.AppendLine("ASM: " & a.FullName) Next out.AppendLine("=== Session 所在程序集 ===") out.AppendLine("SES: " & GetType(Session).Assembly.FullName) File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "probe2.txt"), out.ToString(), Encoding.UTF8) End Sub End Module