https://forums.autodesk.com/t5/net/unnamed-ucs/td-p/4345297
<DllImport("acdb19.dll", CallingConvention:=CallingConvention.Cdecl, EntryPoint:="?acdbGetAdsName@@YA?AW4ErrorStatus@Acad@@AEAY01_JVAcDbObjectId@@@Z")> _
Public Shared Function acdbGetAdsName_R19_64(name As Long(), objId As ObjectId) As Integer
End Function
<DllImport("accore.dll", CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Cdecl, EntryPoint:="acdbEntGet")> _
Public Shared Function acdbEntGet(ename As Long()) As System.IntPtr
End Function
<DllImport("accore.dll", CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Cdecl, EntryPoint:="acdbEntGetX")> _
Public Shared Function acdbEntGetX(ename As Long(), rb As IntPtr) As System.IntPtr
End Function
<CommandMethod("GetEntityDxf")> _
Public Shared Sub GetEntityDxf()
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim ed As Editor = doc.Editor
Dim per As PromptEntityResult = ed.GetEntity(vbLf & "Select an Entity: ")
If per.Status <> PromptStatus.OK Then
Return
End If
Dim ename As Long() = New Long() {0, 0}
' extract the id into an ename
Dim result As Integer = acdbGetAdsName_R19_64(ename, per.ObjectId)
' now I have the ename lets entget it into a result buffer
Dim rb As New ResultBuffer()
Interop.AttachUnmanagedObject(rb, acdbEntGet(ename), True)
' print out what we have
Dim iter As ResultBufferEnumerator = rb.GetEnumerator()
While iter.MoveNext()
Dim TmpVal As TypedValue = iter.Current
Dim strValue As String = (If(TmpVal.Value IsNot Nothing, TmpVal.Value.ToString(), "*Nothing*"))
ed.WriteMessage(vbLf & " - Code: " & TmpVal.TypeCode.ToString() & " = " & strValue)
End While
End Sub
暂时没有评论