贡献VB.net源码
- <CommandMethod("TcTxtJieQu")>
- Public Sub TcTxtJieQu()
- On Error Resume Next
- Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
- Dim acCurDb As Database = acDoc.Database
- Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
- Dim acTypValAr(0) As TypedValue
- acTypValAr.SetValue(New TypedValue(DxfCode.Start, "TEXT"), 0)
- Dim acSelFtr As SelectionFilter = New SelectionFilter(acTypValAr)
- Dim acSSPrompt As PromptSelectionResult = acDoc.Editor.GetSelection(acSelFtr)
- If acSSPrompt.Status = PromptStatus.OK Then '选择成功
- Dim acSSet As SelectionSet = acSSPrompt.Value
- Dim acSSObj As SelectedObject
- For Each acSSObj In acSSet
- Dim acText As DBText = acTrans.GetObject(acSSObj.ObjectId, OpenMode.ForWrite)
- Dim T As String = acText.TextString.Substring(0, 1)
- If T.Contains("-") = True Then '字符必须含有“-”
- Dim s As String() = T.Split("-") '以“-”分割成数组
- If s.Length = 6 Then '数组长度必须为6
- acText.TextString = s(3) '保留序号为3的,其余删除
- End If
- End If
- Next
- End If
- acTrans.Commit()
- End Using
- End Sub
|