Aveva Marine VBNET 编程系列===>读取drawing explorer的第一层级 view

今天我们研究下读取drawing expolrer的第一层级:view

下面的图纸的层级目录示意图,我们今天需要获取所有的view

 

主要用到2个方法:

1# 获取第一个元素

MarDrafting.ElementChildFirstGet Method ()

 

2# 获取相邻的元素

MarDrafting.ElementSiblingNextGet Method 

 

Imports Aveva.ApplicationFramework.Presentation
Imports Aveva.Marine.Drafting
Imports Aveva.Marine.UI ' marAPI.dll
Imports Aveva.Marine.Utility ' marAPI.dll
Imports System.IO
Imports System.Reflection
Imports System.Windows.Forms
Public Class 读取DrawingExplorer
<MyAmFunctionAtt(NameOf(读取DrawingExplorer), NameOf(读取视图名称))>
Public Sub 读取视图名称(wm As WindowManager)
Try
Dim amEnv As New AmEnvironment()
'检查是否已经开了图纸
If Not amEnv.DraftApp.DwgCurrent() Then MsgBox("当前未开启任何图纸,结束命令!", MsgBoxStyle.Critical) : Exit Sub
'读取第一个view
Dim vh As MarElementHandle, index As Integer = 1
Try
vh = amEnv.DraftApp.ElementChildFirstGet()
amEnv.MarUI.MessageNoConfirm($"第{index}个view的名字是:" + amEnv.DraftApp.SubpictureNameGet(vh) + Environment.NewLine)
index += 1
Catch ex As Exception
MsgBox("图纸中无任何内容!", MsgBoxStyle.Critical) : Exit Sub
End Try
'读取第2个view
Dim nextVh As MarElementHandle
Try
nextVh = amEnv.DraftApp.ElementSiblingNextGet(vh)
amEnv.MarUI.MessageNoConfirm($"第{index}个view的名字是:" + amEnv.DraftApp.SubpictureNameGet(nextVh) + Environment.NewLine)
index += 1
Catch ex As Exception
MsgBox("图纸中无任何内容!", MsgBoxStyle.Critical) : Exit Sub
End Try
Dim errFlag As Boolean = True
Do
Try
nextVh = amEnv.DraftApp.ElementSiblingNextGet(nextVh)
amEnv.MarUI.MessageNoConfirm($"第{index}个view的名字是:" + amEnv.DraftApp.SubpictureNameGet(nextVh) + Environment.NewLine)
index += 1
Catch ex As Exception
errFlag = False
End Try
Loop While errFlag
Catch ex As Exception
MsgBox(ex.StackTrace)
End Try
End Sub
End Class

程序运行结果如下:

posted @   南胜NanSheng  阅读(47)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· AI 智能体引爆开源社区「GitHub 热点速览」
· 写一个简单的SQL生成工具
点击右上角即可分享
微信分享提示