.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

read dictionary in event handle function

0 REPLIES 0
Reply
Message 1 of 1
wesbird
131 Views, 0 Replies

read dictionary in event handle function

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
Windows 10 64 bit, AutoCAD (ACA, Map) 2023
0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost