TheSwamp

Code Red => .NET => Topic started by: WILL HATCH on November 07, 2013, 09:41:54 AM

Title: Extension dictionary and UNDO
Post by: WILL HATCH on November 07, 2013, 09:41:54 AM
Not sure how to handle this, but reading the docs implies that the UNDO command could completely trash my application and this is indeed the case :(
Quote from: docs on DBDictionary.SetAt Method
Description
This function adds a new entry specified by newValue into the dictionary, if searchKey does not already exist in the dictionary. If the entry with key searchKey already exists, the existing entry is erased, the dictionary is removed from its reactor list, and it is replaced by the newValue object is added to the dictionary in its place. The name of the object is specified by searchKey. The object's objectId entry is returned.

Notes
The UNDO command does not restore the data of the Xrecord in your dictionary after you have used the SetAt() method. You would find that the Xrecord is deleted after an UNDO command.

I store data in an extension dictionary under a given name which previously held some value

Code - C#: [Select]
  1.                 Xrecord revPrev = new Xrecord();
  2.                 revPrev.Data = new ResultBuffer(new TypedValue[2] { new TypedValue((int)DxfCode.Text, Revision.RevName), new TypedValue((int)DxfCode.Int32, (int)Revision.RevType) });
  3.                 if (!revDict.IsWriteEnabled) revDict.UpgradeOpen();
  4.                 revDict.SetAt(RevPrevious, revPrev);
  5.                 tr.AddNewlyCreatedDBObject(revPrev, true);

so that I can find it later

Code - C#: [Select]
  1.  DBDictionary revDict;
  2.                 if (db.GetCreateRevDict(out revDict))
  3.                 {
  4.                     string value = ((Xrecord)tr.GetObject(revDict.GetAt(RevPrevious), OpenMode.ForRead)).Data.AsArray()[0].Value.ToString();

but after undo it is not reverted to its previous value, it is deleted.  I suspect I'll need to throw a reactor onto the entry and watch for its erase so I can add the previous one (or something) has anybody dealt with this issue before?
Title: Re: Extension dictionary and UNDO
Post by: WILL HATCH on November 07, 2013, 09:46:40 AM
nvm I'm retarded http://adndevblog.typepad.com/autocad/2012/07/undo-removes-updated-dictionary-entry.html (http://adndevblog.typepad.com/autocad/2012/07/undo-removes-updated-dictionary-entry.html)

writing this post made me think differently about my google keywords