Export Von-Mises Maximum value

Hi,

I'm trying to export some results in a .xls file.

To do so, I would like to implement a loop on elements or nodes of my CAE model, in order to evaluate the maximum Von Mises value (among all elements or nodes), and then export this value in Excel.

I am already using a code which seems to work, excepting a specific line :

Dim mesh As CAE.Mesh = CType(grpItem, CAE.Mesh)

I would like to use it in order to do something like that :

For Each grpItem As TaggedObject In group1Items
Dim mesh As CAE.Mesh = CType(grpItem, CAE.Mesh)

If mesh Is Nothing Then
Else
Dim method As CAE.RelatedNodeMethod = mgr.CreateRelatedNodeMethod(mesh)
Dim nodes() As CAE.FENode = method.GetNodes()

For Each node As CAE.FENode In nodes
Dim nodeIndex As Integer = solResult.AskNodeIndex(node.Label)
Dim nodeValues() As Double = Nothing
resultAccess.AskNodalResultAllComponents(nodeIndex, nodeValues)
Dim mag As Double = nodeValues(nodeValues.Length - 1)

If mag > stress Then
stress = mag
End If

Next node

Next grpItem

Does someone have any idea to help me ?

According to the error message, the problem seems to come from interactions between 'NXOpen.CAE.FEElement' and 'NXOpen.CAE.Mesh'.

PS : When I replace Dim mesh As CAE.Mesh = CType(grpItem, CAE.Mesh) by Dim mesh As CAE.Mesh = TryCast(grpItem, CAE.Mesh), the code runs correctly and I succeed to obtain all the images in an excel file (but consequently, the value of maximum constraint in the xsl file are "0" for each group).

So it seems to be the CType(grpItem, CAE.Mesh) that doesn't work... Any idea ?

Thanks for your response,

Best regards,

Baptiste