Oh my god,不好找,问版主另外一个问题吧,唉,最近问题比较多,
我的一个块参照定义了扩展记录,现在问题是当我移动了这个块参照之后,修改扩展记录就出错,而如果不移动这个块参照,修改扩展记录没有问题,不知道什么原因,可以肯定的是移动块参照时候不对扩展记录做任何读写,我的修改扩展记录代码如下:
g trans As Transaction = db.TransactionManager.StartTransaction Dim temp As String = "" temp = inp.iedName + SpecChar + inp.ldInst + SpecChar + inp.prefix + SpecChar + inp.lnClass + SpecChar + inp.lnInst + SpecChar + inp.doName + SpecChar + inp.daName + SpecChar + inp.intAddr Dim ent As Entity = trans.GetObject(id, OpenMode.ForWrite) '判断所选对象是否已包含扩展记录 If ent.ExtensionDictionary = ObjectId.Null Then '新建一个扩展记录对象 Dim xrec As New Xrecord() Dim rb As ResultBuffer = New ResultBuffer() rb.Add(New TypedValue(Int(DxfCode.Text), temp)) xrec.Data = rb '为所选择的对象创建一个扩展字典 ent.CreateExtensionDictionary() Dim dictEntId As ObjectId = ent.ExtensionDictionary() Dim entXrecord As DBDictionary = trans.GetObject(dictEntId, OpenMode.ForWrite) '在扩展字典中加入上面新建的扩展记录对象,并指定它的搜索关键字为MyXrecord entXrecord.SetAt("DeviceXRecord", xrec) '通知事务处理完成扩展记录对象的加入 trans.AddNewlyCreatedDBObject(xrec, True) Else Dim dictEntId As ObjectId = ent.ExtensionDictionary() Dim entXrecord As DBDictionary = trans.GetObject(dictEntId, OpenMode.ForWrite) '在扩展字典中加入上面新建的扩展记录对象,并指定它的搜索关键字为MyXrecord Dim xrecordId As ObjectId = entXrecord.GetAt("DeviceXRecord") '打开找到的扩展记录对象 Dim xrecord As Xrecord = trans.GetObject(xrecordId, OpenMode.ForWrite) '获取扩展记录中包含的数据列表并循环遍历显示它们 Dim r As ResultBuffer = xrecord.Data r.Add(New TypedValue(Int(DxfCode.Text), temp)) xrecord.Data = r End If trans.Commit() |