- 积分
- 2271
- 明经币
- 个
- 注册时间
- 2004-1-10
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
<CommandMethod("S3")> _
Public Sub SelectObjectsOnscreen3()
'' 获得当前文档和数据库 Get the current document and database
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim acCurDb As Database = acDoc.Database
''启动一个事务 Start a transaction
Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
'' 要求在图形区域中选择对象 Request for objects to be selected in the drawing area
Dim acSSPrompt As PromptSelectionResult = acDoc.Editor.GetSelection()
'' 如果提示状态是 OK,对象就被选择了 If the prompt status is OK, objects were selected
If acSSPrompt.Status = PromptStatus.OK Then
Dim acSSet As SelectionSet = acSSPrompt.Value
'' 遍历选择集中的对象 Step through the objects in the selection set
For Each acSSObj As SelectedObject In acSSet
'' 检查以确定返回的 SelectedObject 对象是有效的 Check to make sure a valid SelectedObject object was returned
If Not IsDBNull(acSSObj) Then
'' 以写的方式打开选择的对象 Open the selected object for write
Dim acEnt As Entity = acTrans.GetObject(acSSObj.ObjectId, _
OpenMode.ForWrite)
If Not IsDBNull(acEnt) Then
'' 修改对象的颜色为绿色 Change the object's color to Green
acEnt.ColorIndex = 3
Dim df As ResultBuffer = New ResultBuffer
df.Add(New TypedValue(DxfCode.ExtendedDataRegAppName, "AppName"))
df.Add(New TypedValue(DxfCode.ExtendedDataAsciiString, "objll"))
acEnt.XData = df
End If
End If
Next
'' 保存新对象到数据库中 Save the new object to the database
acTrans.Commit()
End If
'' 销毁事务 Dispose of the transaction
End Using
End Sub
此处报错 acEnt.XData = df eRegappIdNotFound
|
|