- 积分
- 549
- 明经币
- 个
- 注册时间
- 2014-5-23
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
在网上找了段代码,设置元素的XData,第一次是可以的,XData都设置成功了,但是我想修改这个元素的XData,调用这个方法就不行了,程序没有报错。修改的数据写不进去,还是原来的XData,有知道怎么修改XData的朋友可以帮下忙吗,谢谢!
===============================================================
Public Shared Sub addXData(ByVal regAppName As String, ByVal ent As Entity, ByVal attribles As Dictionary(Of String, String))
Try
Using trans As Transaction = mDB.TransactionManager.StartTransaction
Dim obj As DBObject = trans.GetObject(ent.ObjectId, OpenMode.ForWrite)
AddRegAppTableRecord(regAppName)
Dim rb As New ResultBuffer()
rb.Add(New TypedValue(1001, regAppName))
Dim pair As KeyValuePair(Of String, String)
For Each item As Object In attribles
pair = item
Dim str As String = pair.Key & "=" & pair.Value
rb.Add(New TypedValue(1000, str))
Next
obj.XData = rb
rb.Dispose()
trans.Commit()
trans.Dispose()
End Using
Catch ex As Exception
mEdt.WriteMessage(vbCrLf & "addXData err " & ex.Message)
End Try
End Sub
Private Shared Sub AddRegAppTableRecord(ByVal regAppName As String)
Using trans As Transaction = mDoc.TransactionManager.StartTransaction()
Dim rat As RegAppTable = DirectCast(trans.GetObject(mDB.RegAppTableId, OpenMode.ForRead, False), RegAppTable)
If Not rat.Has(regAppName) Then
rat.UpgradeOpen()
Dim ratr As New RegAppTableRecord()
ratr.Name = regAppName
rat.Add(ratr)
trans.AddNewlyCreatedDBObject(ratr, True)
End If
trans.Commit()
trans.Dispose()
End Using
End Sub
|
|