I am running into some very strange behavior in AutoCAD 2008 when I try writing text strings to an XRecord. When I write a ResultBuffer with a text length of 51367 characters to resultbuffer.Data all is well. When I try to write an ResultBuffer with a text length of 68480 characters to resultbuffer.Data it drops most of my string and only hold on to 2946 characters of the text string.
Is there a max length of a DxfCode.Text (1) Xrecord? I've been digging around for quite a while now and I'm at a loss here.
Here is the code I'm using. Please note that this portion of code was run through a "translator" to convert from some old Boo code I had to C# so I could use it on my project and I haven't had time to refactor it. Hence the ugliness.
public void WriteBOMToDwgDatabase()
{
Database database;
IDisposable dbDis = (database = HostApplicationServices.WorkingDatabase) as IDisposable;
try
{
Transaction transaction;
IDisposable trDis = (transaction = database.TransactionManager.StartTransaction()) as IDisposable;
try
{
try
{
DBDictionary dictionary = (DBDictionary) transaction.GetObject(database.NamedObjectsDictionaryId, OpenMode.ForWrite);
DBDictionary newValue = null;
try
{
newValue = (DBDictionary) transaction.GetObject(dictionary.GetAt("ks_bom"), OpenMode.ForRead);
}
catch (Exception)
{
newValue = new DBDictionary();
dictionary.SetAt("ks_bom", newValue);
database.TransactionManager.AddNewlyCreatedDBObject(newValue, true);
}
DBDictionary bomItem = null;
try
{
bomItem = (DBDictionary) transaction.GetObject(newValue.GetAt("bom_item"), OpenMode.ForWrite);
}
catch (Exception)
{
bomItem = new DBDictionary();
newValue.SetAt("bom_item", bomItem);
database.TransactionManager.AddNewlyCreatedDBObject(bomItem, true);
}
Xrecord xrecord = null;
try
{
xrecord = (Xrecord)transaction.GetObject(bomItem.GetAt("bomItem"), OpenMode.ForWrite);
TypedValue[] values = new TypedValue[] { new TypedValue(1, this.writestring) };
ResultBuffer resbuf = new ResultBuffer(values);
xrecord.Data = resbuf;
}
catch (Exception)
{
xrecord = new Xrecord();
TypedValue[] values = new TypedValue[] { new TypedValue(1, this.writestring) };
ResultBuffer resbuf = new ResultBuffer(values);
xrecord.Data = resbuf;
bomItem.SetAt("bomItem", xrecord);
database.TransactionManager.AddNewlyCreatedDBObject(xrecord, true);
}
transaction.Commit();
}
finally
{
transaction.Dispose();
}
}
finally
{
if (trDis != null)
{
trDis.Dispose();
trDis = null;
}
}
}
finally
{
if (dbDis != null)
{
dbDis.Dispose();
dbDis = null;
}
}
}