Modifying an XRecord changes all xrecords in dictionary

Modifying an XRecord changes all xrecords in dictionary

SRSDS
Advisor Advisor
899 Views
2 Replies
Message 1 of 3

Modifying an XRecord changes all xrecords in dictionary

SRSDS
Advisor
Advisor

Hi all,  This is really strange and I can't quite figure it out.

I have a dictionary in the NOD with several xrecords. I want to change an entry value in one but the others in the dictionary also get changed. How would they be connected?

This is some simlified code that looks at two xrecords, changes one, then reports the new values. Wierd thing is that both xrecords get changed.

 

        For i = 1 To 2
            XRecId = MyAppDict.GetAt(i)
            XRec = trans.GetObject(XRecId, OpenMode.ForRead)
            ed.WriteMessage(vbLf + "XRecord: " & i & " First Entry: " & XRec.Data(0).value)
        Next
        XRecId = MyAppDict.GetAt(2)
        XRec = trans.GetObject(XRecId, OpenMode.ForWrite)
        Dim data As ResultBuffer = New ResultBuffer(New TypedValue(DxfCode.Int16, 2), New TypedValue(DxfCode.Text, XRec.Data(1).value))
        XRec.Data = data
        For i = 1 To 2
            XRecId = MyAppDict.GetAt(i)
            XRec = trans.GetObject(XRecId, OpenMode.ForRead)
            ed.WriteMessage(vbLf + "XRecord: " & i & " First Entry: " & XRec.Data(0).value)
        Next

 

 

 

0 Likes
Accepted solutions (1)
900 Views
2 Replies
Replies (2)
Message 2 of 3

Alfred.NESWADBA
Consultant
Consultant
Accepted solution

Hi,

 

try to do a trans.Commit (and create a new transaction) after modifying the data/before starting the loop testreading it.

To make it easier (less work) for us to test this, help us with uploading a drawing with your XRecords attached.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
Message 3 of 3

SRSDS
Advisor
Advisor

Thanks Alfred.

I committed the transaction but also removed the xrecord then replaced it in the next transaction.

Strange that it was doing that.

0 Likes