Retrieve Custom data from DBDictionary

Retrieve Custom data from DBDictionary

waseefur.rahman
Advocate Advocate
790 Views
4 Replies
Message 1 of 5

Retrieve Custom data from DBDictionary

waseefur.rahman
Advocate
Advocate

Hi everyone,

I am trying to retrieve custom data which stored in DBDictionary

below method used in objectarx, it works fine

		AcDbObject::dwgInFields(pFilter);

		//read data from acad model
		Int32 size;
		pFilter->readInt32(&size);
		TVector<char> mem(size);
		pFilter->readBytes(mem.begin(), size);


but in .net i was not able to retrive the data, 

                    Dim pNamedobj As DBDictionary = tr.GetObject(db.NamedObjectsDictionaryId, OpenMode.ForRead, False)
                    'Dim DBDict As DBDictionary
                    Dim DBDict As DBObject
                    Try
                        DBDict = tr.GetObject(pNamedobj.GetAt(s_cLVScene), OpenMode.ForRead)
                    Catch ex As Autodesk.AutoCAD.Runtime.Exception
                        MsgBox(ex.Message)
                        Exit Sub
                    End Try

                    Dim pFilter As DwgFiler
                    DBDict.DwgIn(pFilter)

                    Dim XMLDATA = pFilter.ReadByte()

could anyone please advice, what needs to be modified to achieve the output.



0 Likes
791 Views
4 Replies
Replies (4)
Message 2 of 5

dhaverstick
Advocate
Advocate

What type of data was stored in the custom dictionary and how was it stored?

 

I use DBDictionaries to store data in Xrecords. Here is some code that shows how I get that data in and out of a DBDictionary.

Writing data:

    Private Sub CreateDictionaryXRecord(ByRef TransactionObject As Transaction, ByRef DictionaryObject As DBDictionary, ByVal XRecordName As String, ByVal DxfCodeType As String, ByVal XRecordValue As Object)
        Dim BufferObject As New ResultBuffer
        Dim XRecordObject As New Xrecord

        If DxfCodeType.ToUpper = "INT16" Then
            BufferObject.Add(New TypedValue(DxfCode.Int16, CType(XRecordValue, Int16)))
        ElseIf DxfCodeType.ToUpper = "REAL" Then
            BufferObject.Add(New TypedValue(DxfCode.Real, CType(XRecordValue, Double)))
        ElseIf DxfCodeType.ToUpper = "TEXT" Then
            BufferObject.Add(New TypedValue(DxfCode.Text, CType(XRecordValue, String)))
        End If

        XRecordObject.Data = BufferObject
        DictionaryObject.SetAt(XRecordName, XRecordObject)
        TransactionObject.AddNewlyCreatedDBObject(XRecordObject, True)
    End Sub

 

Reading data:

                DictionaryObject = TransactionObject.GetObject(DictionaryObjectID, OpenMode.ForRead)
                XRecordObject = TransactionObject.GetObject(DictionaryObject.GetAt(NameOfXRecord), OpenMode.ForRead)
                XDataValueOut = XRecordObject.Data.AsArray

                If TypeOf XDataValueOut(0).Value Is String Then
                    DataValue = XDataValueOut(0).Value.ToString
                ElseIf TypeOf XDataValueOut(0).Value Is Integer Then
                    DataValue = CInt(XDataValueOut(0).Value)
                Else
                    DataValue = CDbl(XDataValueOut(0).Value)
                End If

 

I hope this helps!

 

Darren

0 Likes
Message 3 of 5

waseefur.rahman
Advocate
Advocate

Hi @dhaverstick ,

Thanks you for replay,

i tried you code and got this error,

 
 

Screenshot 2021-02-08 161803.png


Actually its a Proxy Object, which is stored in DBDictionary,
Can you please guide me on ow to retrive data from Proxyobject?

Thanks

0 Likes
Message 4 of 5

_gile
Consultant
Consultant

Hi,

you cannot get other data from a ProxyObject the the ProxyObject properties.

To get more, you must have the application wich creates the underlying custom object.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 5 of 5

dhaverstick
Advocate
Advocate

The code I shared was not intended to be used verbatim. It was an example of how I get data in and out of a DBDictionary using Xrecords. I have no idea what data you are trying to store and retrieve.

 

Darren

0 Likes