.NET

Reply
Distinguished Contributor
wesbird
Posts: 359
Registered: ‎12-05-2003
Message 1 of 1 (38 Views)

read dictionary in event handle function

38 Views, 0 Replies
02-02-2006 09:18 AM
Hi
In my project, I plan to check the drawing status when end user switch back and forth between the multiple drawings. So I save id as dictionary in each drawing, in the event function, I like to read this id back. Now got this problem
if any one like to take look and point out what wrong, I would read appreacite it.



here is my read dictionary function:
[code]
public static void ReadXrecord(string strDictionaryName, string strDictionaryKey,
out TypedValue[] dataDict)
{

Database db = HostApplicationServices.WorkingDatabase;
Transaction trans = db.TransactionManager.StartTransaction();

// Get the Dictionary
dataDict = null;
DBDictionary dictWX;
try
{
DBDictionary WX = (DBDictionary)trans.GetObject(db.NamedObjectsDictionaryId, OpenMode.ForWrite,false);
try
{
//if it exists, just get it
dictWX = (DBDictionary)trans.GetObject(WX.GetAt(strDictionaryName), OpenMode.ForRead,false);
}
catch (System.Exception caught)
{

trans.Abort();
return;
}
//
Xrecord xrecWX;
try
{
xrecWX = (Xrecord)trans.GetObject(dictWX.GetAt(strDictionaryKey),OpenMode.ForRead,false);
}
catch (System.Exception caught)
{
trans.Abort();
return;
}
ResultBuffer data = xrecWX.Data;
if (data==null) { trans.Abort(); return;}
dataDict=data.AsArray();

trans.Commit();
}
catch (System.Exception caught)
{
trans.Abort();
}
finally { trans.Dispose(); }

}
[/code]


Wes
Vault Pro 2014, Windows 7 64 bit, AutoCAD (ACA, Map) 2014
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.