Aveva Marine VBNET 编程系列 获取文字
此系列的教程,暂时不更新,因为没多少人愿意加入一起学习的行列,有需要学习的可以加我微信或者QQ讨论
电话:17607170146(微信同号)
QQ:442024898
提取图纸中的文字,
<MyAmFunctionAtt(NameOf(用户交互), NameOf(选择单个文字))> Public Sub 选择单个文字(wm As WindowManager)
Dim amEnv As New AmEnvironment()
Try
If Not amEnv.DraftApp.DwgCurrent() Then MsgBox("当前未开启任何图纸,结束命令!", MsgBoxStyle.Critical) : Exit Sub
Dim pt As MarPointPlanar = Pick2dPt(amEnv)
If pt Is Nothing Then
MsgBox("拾取点失败", MsgBoxStyle.Critical)
amEnv.Dispose()
Return
End If
Try
Dim ele = amEnv.DraftApp.TextIdentify(pt)
Dim t As MarText = amEnv.DraftApp.TextPropertiesGet(ele)
MsgBox(t.String)
Catch ex As Exception
MsgBox("拾取文字失败", MsgBoxStyle.Critical)
amEnv.Dispose()
Return
End Try
Catch ex As Exception
MsgBox(ex.StackTrace)
Finally
amEnv.Dispose()
End Try
End Sub
Public Shared Function Pick2dPt(env As AmEnvironment, Optional promptstr As String = "Pick one Point") As MarPointPlanar
Dim ptrtn As MarPointPlanar = New MarPointPlanar()
Dim flag As Boolean = env.MarUI.PointPlanarReq(promptstr, ptrtn) = env.MarUtility.Ok()
Dim result As MarPointPlanar
If flag Then
env.DraftApp.PointHighlight(ptrtn)
result = ptrtn
Else
result = Nothing
End If
Return result
End Function