Cancel
Showing results for 
Search instead for 
Did you mean: 

NX Open - c#: Which command/method returns the max. stress result of my solution?

Experimenter
Experimenter

There are two ways to do it manually:

 

First:Toggle on Annotations under the Post View on the Post Processing Navigator. The min and max values are automatically flagged by an annotation in the graphics window.

 

Second: Use Identify. Select the entire model. The min, max, sum and average are available in the Identify dialog, along with options to write more detailed information to the listing window, text file or excel spreadsheet.

 

So far so good. But I need this information (value) in my c# program code. Therefor i need a function which asks for the max. result. I dont know how to get/call the max/min result. I dont know which function or method or class i have to use and to get the same value as described above (First / Second).

 

In order to solve this problem i have a recorded a journal. I saw the max. result (Stress Element Nodal - Max Principal) hardcoded in my journal code so i could not use it. I need an command which asks for the max. result. I dont need a hardcoded value like in my journal.

 

pic.PNG

 

 

4 REPLIES 4

Re: NX Open - c#: Which command/method returns the max. stress result of my solution?

Legend
Legend

Hello Philipp_K,

 

We solved it with a workaround by using theSession.Post.PostviewExportDisplay and then getting from the file what we need.

Below is the code for the function (I suggest to remove all overlay references, or call with false)

 

    Public Function GetPlotHeader(PostviewId As Integer, Plotname As String, Overlay As Boolean) As PlotHeader
        Dim MyPlotHeader As PlotHeader = Nothing

        'Set field to 1 in case of overlay, such that the results are taken from the main postViewId and not the overlay plot
        Dim overlayInt As Integer = 0
        If Overlay Then
            overlayInt = 1
        End If

        'Export plot as temporary ascii file to get access to plot header data
        theSession.Post.PostviewExportDisplay(PostviewId - overlayInt, "H:\temp\StressPlotTemp.txt", CAE.Post.Export.Ascii, True, False)

        'Open temporary ascii file to read header data
        Dim strData As String
        strData = My.Computer.FileSystem.ReadAllText("H:\temp\StressPlotTemp.txt")
        Dim LinesInFile() As String  'remove carriage return
        LinesInFile = strData.Split(New String() {ControlChars.CrLf}, StringSplitOptions.RemoveEmptyEntries)


        Dim i As Integer = 0
        Do While LinesInFile(i) <> "Legend"
            i = i + 1
        Loop
        MyPlotHeader.NameOfPlot = Plotname
        MyPlotHeader.SimResult = LinesInFile(i + 3)
        MyPlotHeader.Subcase = LinesInFile(i + 4)
        MyPlotHeader.StressType = LinesInFile(i + 5)
        MyPlotHeader.ShellSection = LinesInFile(i + 6)
        MyPlotHeader.MinMaxResult = LinesInFile(i + 7)

        Dim j As Integer = 0
        Do Until LinesInFile(i + j).Split(New String() {" "}, StringSplitOptions.RemoveEmptyEntries)(0) = "*21"
            j = j + 1
        Loop



        MyPlotHeader.MinScale = LinesInFile(i + j + 1)
        MyPlotHeader.MaxScale = LinesInFile(i + j + Convert.ToInt32(LinesInFile(i + j).Split(New String() {" "}, StringSplitOptions.RemoveEmptyEntries)(2)))

        'Delete temporary file
        File.Delete("H:\temp\StressPlotTemp.txt")

        Return MyPlotHeader
    End Function

Hope this puts you in the right direction.

 

Regards,

Frederik

Re: NX Open - c#: Which command/method returns the max. stress result of my solution?

Siemens Phenom Siemens Phenom
Siemens Phenom

You need functions in the NXOpen.CAE.ResultAccess class:

 

  • AskMinimum()
  • AskMaximum()

 

  • AskNMinMaxLocation()
  • AskMinMaxLocation()

 

See the documetation at:

 

NXOpen.CAE.ResultAccess Class Reference

Re: NX Open - c#: Which command/method returns the max. stress result of my solution?

Experimenter
Experimenter

Thank you for your answer. Last question. For me its very hard to use this function correct because i am new in programming. Do you know how does the structure looks like? How i use

  • AskMinimum()
  • AskMaximum()
  • AskNMinMaxLocation()
  • AskMinMaxLocation()

in my c# code?

This is the code from my collague. How can i implement it here? Thank you so much for any advice.

Re: NX Open - c#: Which command/method returns the max. stress result of my solution?

Legend
Legend
The AskMinimum() functions as suggested by JimB are indeed better to use. However, we needed the max/min for only the items in the display. AskMinimum() functions give you the value for the entire model, and not a subset.