一般来讲我们使用MARAPI里面的
ElementChildFirstGet 和 ElementSiblingNextGet 函数去遍历而获得图元
''' <summary>
''' 获取当前视图的全部的子视图的句柄
''' </summary>
''' <param name="draftApp">MarDrafting对象</param>
''' <param name="viewHandle">视图的句柄</param>
''' <returns>子视图句柄的list集合</returns>
Public Shared Function ViewSubViews(draftApp As MarDrafting, viewHandle As MarElementHandle) As List(Of MarElementHandle)
If Not draftApp.ElementIsView(viewHandle) Then
Return Nothing
End If
Dim rtns As New List(Of MarElementHandle)
Try
Dim subvh As MarElementHandle
Try
subvh = draftApp.ElementChildFirstGet(viewHandle)
rtns.Add(subvh)
Catch ex As Exception
Return Nothing
End Try
'读取第2个view
Dim nextsubVh As MarElementHandle
Try
nextsubVh = draftApp.ElementSiblingNextGet(subvh)
rtns.Add(nextsubVh)
Catch ex As Exception
End Try
Dim errFlag As Boolean = True
Do
Try
nextsubVh = draftApp.ElementSiblingNextGet(nextsubVh)
rtns.Add(nextsubVh)
Catch ex As Exception
errFlag = False
End Try
Loop While errFlag
Catch ex As Exception
MsgBox(ex.StackTrace)
End Try
Return rtns
End Function
今天看一个不一样的
MarDrafting mDrafting = new MarDrafting();
if (!mDrafting.DwgCurrent()) return;
var marW = new MarWrapper();
try
{
var xmlFn = marW.PicGetData(4, -1, -1);
if (File.Exists(xmlFn))
{
Interaction.MsgBox(xmlFn, MsgBoxStyle.OkOnly | MsgBoxStyle.Information);
}
}
catch (Exception ex)
{
Interaction.MsgBox(ex.StackTrace, MsgBoxStyle.OkOnly | MsgBoxStyle.Exclamation);
}
有没有很熟悉就是XML的树形数据结构
标签:nextsubVh,C#,TREE,MarElementHandle,AVEVA,rtns,Try,ex,End From: https://www.cnblogs.com/NanShengBlogs/p/17988057