Author Topic: Xrecord Question  (Read 1948 times)

0 Members and 1 Guest are viewing this topic.


  • Newt
  • Posts: 80
  • The great gig in the sky
Xrecord Question
« on: March 21, 2008, 11:22:31 AM »

A simple question on XData, XRecord, Dictionary, ...

I have come out with these two snippets of code:

Code: [Select]
        ' Append XRecord
        Dim xRec As New Xrecord()
        xRec.Data = New ResultBuffer(New TypedValue(DxfCode.Text, myString))
        Dim myAcadEntXDict As DBDictionary = _
            myTrans.GetObject(AcadEntity.ExtensionDictionary(), _
            OpenMode.ForWrite, False)
        myAcadEntXDict.SetAt("myData", xRec)
        myTrans.AddNewlyCreatedDBObject(xRec, True)
that I use to attach data to and entity, and:
Code: [Select]
    Dim myObjIds As DatabaseServices.ObjectIdCollection = _
                 New DatabaseServices.ObjectIdCollection(mySS.GetObjectIds)
            Dim bHasGtaDict As Boolean = True
            Dim GtaXrec As Xrecord = Nothing
            For Each myObjId As DatabaseServices.ObjectId In myObjIds
                Dim myAcadEnt As DatabaseServices.Entity = myObjId.GetObject(OpenMode.ForRead)
                    Dim GtaXDict As DBDictionary = myTrans.getobject(myAcadEnt.ExtensionDictionary(), OpenMode.ForRead, False)
                    GtaXrec = myTrans.getobject(GtaXDict.GetAt("myData"), OpenMode.ForRead, False)
                    bHasGtaDict = False
                End Try
                If bHasGtaDict Then
                    Dim resBuf() As TypedValue = GtaXrec.Data.AsArray()
                End If
that I use to retrieve the same data from my ent.

I know that with
Code: [Select]
xRec.Data = New ResultBuffer(New TypedValue(DxfCode.Text, myString1), New TypedValue(DxfCode.Text, myString2))
I can add many different types of data to my entity, and that it can be of different types.
Now since I want to append different data to the entity in different working (drafting) sessions, and that, depending on the contest I'm working with the drawing, I will be updating this data, can anybody explain me the following:

1. Can I append more than one Xrecord to one Entity or can an Entity have more than one Xrecord...
2. ... if not, can I update the Xrecord data or am I supposed to retrieve the data, update it and then reattach it.
Thanks in advance for any help
"A clever person solves a problem. A wise person avoids it." - Albert Einstein


  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Xrecord Question
« Reply #1 on: March 21, 2008, 11:59:15 PM »
My understanding is :

each XRecord in a Dictionary is identified by it's unique name key ...

and the XRecord Class documentation (ARX) states :
The AcDbXrecord class provides two member functions for setting and obtaining resbuf chains, the setfromRbChain() and rbChain() functions:
The AcDbXrecord::setFromRbChain() function replaces the existing resbuf chain with the chain passed in.

This could be fairly easily demonstrated.
I believe you should aim at rebuilding the resBuf chain to include the existing data you want retained.

Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--