Aveva Marine VBNET 编程系列-新建图纸,创建文字
根据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
标签:
AVEVA MARINE
, VBNET
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· winform 绘制太阳,地球,月球 运作规律
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· AI 智能体引爆开源社区「GitHub 热点速览」
· 写一个简单的SQL生成工具