Author Topic: Xrecord Question  (Read 2980 times)

0 Members and 1 Guest are viewing this topic.

ReneRam

  • Guest
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]
        AcadEntity.UpgradeOpen()
        ' Append XRecord
        Dim xRec As New Xrecord()
        xRec.Data = New ResultBuffer(New TypedValue(DxfCode.Text, myString))
        AcadEntity.CreateExtensionDictionary()
        Dim myAcadEntXDict As DBDictionary = _
            myTrans.GetObject(AcadEntity.ExtensionDictionary(), _
            OpenMode.ForWrite, False)
        myAcadEntXDict.SetAt("myData", xRec)
        myTrans.AddNewlyCreatedDBObject(xRec, True)
        AcadEntity.DowngradeOpen()
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)
                Try
                    Dim GtaXDict As DBDictionary = myTrans.getobject(myAcadEnt.ExtensionDictionary(), OpenMode.ForRead, False)
                    GtaXrec = myTrans.getobject(GtaXDict.GetAt("myData"), OpenMode.ForRead, False)
                Catch
                    bHasGtaDict = False
                End Try
                If bHasGtaDict Then
                    Dim resBuf() As TypedValue = GtaXrec.Data.AsArray()
                End If
            Next
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
René

Kerry

  • 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.




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