Extracting XY data from an afu record - How to?

to all

Going through the documentation, it looks like there is a function to extract the afudata (of a record). As the examples are non-existent in the documentation, could someone give me a "push" in the right direction? I would like to "extract" the XYdata of a specific afu record (a force time history for a CBEAM in my example/test) to be able to search for specific data. Ideally I would like the XY data to be passed into an array. Looking at the doc it seems that the following should do the trick;

Public Function GetAfuData ( _
afuFileName As String, _
recordIndex As Integer, _
ByRef afuData As AfuData) As String
Return Value: Time stamp string indicates the last time the AFU Data Record was edited

which I attempted as follows

Dim myafudata() As AfuData
theSession.AfuManager.GetAfuData(strPathSimAFU,2,m​yafudata)

but (as expected/anticipated) didn't work(!)

Thanks

Regards

JXB

The following journal may get you started:

Option Strict Off
Imports System
Imports NXOpen

Module Module1

Sub Main()

Dim theSession As Session = Session.GetSession()
If IsNothing(theSession.Parts.Work) Then
'active part required
Return
End If

Dim workPart As Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()

Dim myAfuFile As String = "path_to_your_AFUfile.afu"

Dim myAfuData As CAE.AfuData
theSession.AfuManager.GetAfuData(myAfuFile, 1, myAfuData)

Dim theAbscissaType As CAE.AfuData.AbscissaType
Dim theXunit As CAE.XyFunctionUnit
Dim theYunit As CAE.XyFunctionUnit
Dim theOrdinateType As CAE.AfuData.OrdinateType

myAfuData.GetAxisDefinition(theAbscissaType, theXunit, theOrdinateType, theYunit)

lw.WriteLine("function data type: " & myAfuData.FunctionDataType.ToString)
lw.WriteLine("record name: " & myAfuData.RecordName)
lw.WriteLine("abscissa type: " & theAbscissaType.ToString)
lw.WriteLine("ordinate type: " & theOrdinateType.ToString)
lw.WriteLine("X unit: " & theXunit.ToString)
lw.WriteLine("Y unit: " & theYunit.ToString)

Dim theXvalues() As Double
Dim theYvalues() As Double
Dim xMin As Double
Dim xIncrement As Double
Dim numPts As Integer

If theAbscissaType = CAE.AfuData.AbscissaType.Even Then
myAfuData.GetEvenData(xMin, xIncrement, numPts)
lw.WriteLine("X minimum: " & xMin.ToString)
lw.WriteLine("X increment: " & xIncrement.ToString)
lw.WriteLine("number of points: " & numPts.ToString)
End If

If theOrdinateType = CAE.AfuData.OrdinateType.Real Then
theYvalues = myAfuData.GetRealData(theXvalues)
End If

If theOrdinateType = CAE.AfuData.OrdinateType.RealImaginary Then
myAfuData.GetComplexData(theXvalues, theYvalues)
End If

lw.WriteLine("")
For i As Integer = 0 To theXvalues.Length - 1
lw.WriteLine("point: " & i.ToString)
lw.WriteLine("X: " & theXvalues(i))
lw.WriteLine("Y: " & theYvalues(i))
lw.WriteLine("")
Next
lw.Close()

End Sub

End Module

Thanks for that. It seems the "only" thing I needed to start was the "CAE.AfuData". The methods to extract the X&Y values (and other bits of info) were very welcome too. The Y values are passed to another function so that comparison can be made between 3 set of Y values (I just need to add a loop to extract the 3 sets) and it preliminary progress are looking good.

Thanks again

JXB

Thanks
Regards