根据MarApi,创建图形文件,新建文字
Imports Aveva.ApplicationFramework.Presentation
Imports Aveva.Marine.Drafting ' marAPI.dll
Public Class 绘图控制
<MyAmFunctionAtt(NameOf(绘图控制), NameOf(新建图纸))>
Public Sub 新建图纸(wm As WindowManager)
Dim draftApp As New MarDrafting
Try
'am是单文档模式。不可以同时开2个文件
If draftApp.DwgCurrent() Then
If Not draftApp.DwgIsModified() Then '图纸未改动直接退出
draftApp.DwgClose()
Else
If MsgBox("检测到图纸有改动", MsgBoxStyle.Question, "是否保存当前图纸?") = MsgBoxResult.Ok Then
draftApp.DwgSave()
Else
draftApp.DwgClose()
End If
End If
End If
draftApp.DwgNew(DateTime.Now.ToString("yyyyMMdd-HHmmss"))
Catch ex As Exception
MsgBox(ex.StackTrace)
Finally
draftApp.Dispose()
End Try
End Sub
<MyAmFunctionAtt(NameOf(绘图控制), NameOf(新建文字))>
Public Sub 新建文字(wm As WindowManager)
Dim draftApp As New MarDrafting
Try
If Not draftApp.DwgCurrent() Then
MsgBox("未开启任何图纸无法创建文字", MsgBoxStyle.Critical, "错误提示")
Return
End If
Dim tstr = InputBox("输入文字内容", "输入", DateTime.Now.ToString("yyyyMMdd-HHmmss"))
Using t As New MarText(tstr)
t.Position = New Aveva.Marine.Geometry.MarPointPlanar(0, 0)
t.Height = 5.0
t.TextColour = New MarColour("Red")
draftApp.TextNew(t)
End Using
Catch ex As Exception
MsgBox(ex.StackTrace)
Finally
draftApp.Dispose()
End Try
End Sub
<MyAmFunctionAtt(NameOf(绘图控制), NameOf(新建多行文字))>
Public Sub 新建多行文字(wm As WindowManager)
Dim draftApp As New MarDrafting
Try
If Not draftApp.DwgCurrent() Then
MsgBox("未开启任何图纸无法创建文字", MsgBoxStyle.Critical, "错误提示")
Return
End If
Dim tstr = InputBox("输入文字内容", "输入", DateTime.Now.ToString("yyyyMMdd-HHmmss") + Environment.NewLine + "我是第二行")
Using t As New MarText(tstr)
t.Position = New Aveva.Marine.Geometry.MarPointPlanar(0, 0)
t.Height = 5.0
t.TextColour = New MarColour("Red")
draftApp.TextNew(t)
End Using
Catch ex As Exception
MsgBox(ex.StackTrace)
Finally
draftApp.Dispose()
End Try
End Sub
End Class