I will be grateful to you, if you could write some code about how to solve this.
Best regards,
if (entity != null) { #region XRecord if (entity.ExtensionDictionary != null && entity.ExtensionDictionary.IsValid) { DBDictionary extensionDic = transaction.GetObject(entity.ExtensionDictionary, OpenMode.ForRead) as DBDictionary; ObjectId rb1 = extensionDic.GetField(); DbDictionaryEnumerator iterator = extensionDic.GetEnumerator(); while (iterator.MoveNext()) { DBDictionaryEntry dbdEntry = iterator.Current; Xrecord xr = transaction.GetObject(dbdEntry.Value, OpenMode.ForRead) as Xrecord; if (xr != null) { try { ResultBuffer xrrb = xr.Data; if (xrrb != null) { datalog.WriteNormalLog("找到XRECORD!"); int n = 1; foreach (TypedValue tv in xrrb) { datalog.WriteNormalLog("the " + n + "th xrecord: " + tv.Value); n++; } xrrb.Dispose(); } } catch (System.Exception ex) { ex = null; } } } } #endregion #region XData ResultBuffer rb = entity.XData; if (rb != null) { int n = 1; foreach (TypedValue tv in rb) { datalog.WriteNormalLog("the " + n + "th xdata: "+ tv.Value); n++; } rb.Dispose(); } #endregion }
Hi,
Sorry for the delay.
I do not see any obvious issues with your code and it worked ok in AutoCAD 2014.
I tried it on an entity which had its extension dictionary created using the ArxDbg as shown in the attached screenshot.
But, you cannot say for sure that the "dbdEntry.Value" will always be an ObjectId to an Xrecord. It could also be other DBDictionary which are sub dictionaries. So you may need to test if that is the case and if so, get its enumerator to enumerate further.
If you can provide a non-confidential sample drawing that gives you the error message, I can look into it.
Regards,
Balaji
THX!
I'll test whether it's a sub dictionaries.
Attached please find my test dwg file.