很好,反射成功。结果说明,DxfName和Entity Type不存在固定的对应关系。要让lisp和.NET有一致的类型限定,还得找别的方法。- <CommandMethod("TTT")> Public Sub TTT()
- Dim doc = Application.DocumentManager.MdiActiveDocument
- Dim ed = doc.Editor
- Dim et As Type = GetType(Entity)
- Dim typs() As Type = Assembly.GetAssembly(et).GetTypes
- Dim var = From typ As Type In typs Where typ.IsSubclassOf(et)
- Dim dict As New Dictionary(Of String, Type)
- For Each typ As Type In var
- Dim cls As RXClass = RXClass.GetClass(typ)
- If cls IsNot Nothing Then
- Dim dxf As String = cls.DxfName
- If dxf <> Nothing Then
- If Not dict.ContainsKey(dxf) Then
- dict.Add(dxf, typ)
- Else
- ed.WriteMessage(vbLf & "Same DXF: {0}({1})", dxf, typ.Name)
- End If
- Else
- ed.WriteMessage(vbLf & "DXF Nothing: {0}", typ.Name)
- End If
- Else
- ed.WriteMessage(vbLf & "RXClass Nothing: {0}", typ.Name)
- End If
- Next
- For Each s In dict
- ed.WriteMessage(vbLf & "{0}:{1}", s.Key, s.Value.Name)
- Next
- End Sub
|