|
请老大提修改意见
Public Sub cxb_bg()
'统一修改标高值
Dim acDbobject As DBObject
Dim acText As DBText
Dim acValue As Double
Dim acPromptEntityOptions As PromptEditorOptions = New PromptEntityOptions(vbLf & "选择将改变数值以层为标准的标准文字:")
Dim acPromptEntityResult As PromptEntityResult = acDocEd.GetEntity(acPromptEntityOptions)
If acPromptEntityResult.Status = PromptStatus.OK Then
Using acTrans As Transaction = acdoc.TransactionManager.StartTransaction()
acDbobject = acTrans.GetObject(acPromptEntityResult.ObjectId, OpenMode.ForRead)
If TypeOf (acDbobject) Is DBText Then
acText = acDbobject
Else
Exit Sub
End If
If acText.TextString Like "*#.##*" Then
'' 创建一个 TypedValue 数组,用于定义过滤条件 Create a TypedValue array to define the filter criteria
Dim acTypValAr(1) As TypedValue
acTypValAr.SetValue(New TypedValue(DxfCode.Start, "Text"), 0)
acTypValAr.SetValue(New TypedValue(DxfCode.LayerName, acText.Layer), 1)
'' 赋值过滤条件给 SelectionFilter 对象 Assign the filter criteria to a SelectionFilter object
Dim acSelFtr As SelectionFilter = New SelectionFilter(acTypValAr)
'' 要求在图形区域中选择对象 Request for objects to be selected in the drawing area
Dim acSSPrompt As PromptSelectionResult
acDocEd.WriteMessage(vbLf & "选择将改变数值的文字:")
acSSPrompt = acDocEd.GetSelection(acSelFtr)
'' 如果提示状态是 OK,对象就被选择了 If the prompt status is OK, objects were selected
If acSSPrompt.Status = PromptStatus.OK Then
Dim acSSet As SelectionSet = acSSPrompt.Value
Dim acPromptDoubleOptions As PromptDoubleOptions = New PromptDoubleOptions(vbLf & "输入标高差值:")
Dim acPromptDoubleResult As PromptDoubleResult = acDocEd.GetDouble(acPromptDoubleOptions)
If Not IsDBNull(acPromptDoubleResult) Then
acValue = acPromptDoubleResult.Value
Else
Exit Sub
End If
'' 遍历选择集中的对象 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)
acText = acTrans.GetObject(acSSObj.ObjectId, OpenMode.ForWrite)
If Not IsDBNull(acText) Then
acText.TextString = Format(Val(acText.TextString) + acValue, "0.00")
End If
End If
Next
End If
End If
acTrans.Commit()
End Using
End If
End Sub |
|